From 1d7a751d34319a6f82bed24ecac2d6e308c45ee5 Mon Sep 17 00:00:00 2001 From: Tobias Linsefors Date: Wed, 19 Apr 2023 13:41:52 +0200 Subject: [PATCH 1/3] feat: listbox properties spec --- .../components/listbox/default-properties.js | 139 +++++++++++++- .../hooks/__tests__/useOnTheFlyModel.test.jsx | 6 +- apis/nucleus/src/index.js | 2 +- .../__tests__/filterpane-handler.test.js | 20 ++ apis/stardust/api-spec/spec.conf.js | 3 + apis/stardust/api-spec/spec.json | 174 +++++++++++++++++- apis/stardust/types/index.d.ts | 39 +++- 7 files changed, 377 insertions(+), 6 deletions(-) diff --git a/apis/nucleus/src/components/listbox/default-properties.js b/apis/nucleus/src/components/listbox/default-properties.js index 71c5fdfbe..145b27a99 100644 --- a/apis/nucleus/src/components/listbox/default-properties.js +++ b/apis/nucleus/src/components/listbox/default-properties.js @@ -1,7 +1,32 @@ +/** + * see: https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FValueExpression + * @name ValueExpression + * @type object + * @property {string} qValueExpression.qExpr + */ + +/** + * Extends `ListObjectDef`, see Engine API: `ListObjectDef`. + * @interface ListObjectDef + * @extends EngineAPI.IListObjectDef + * @property {boolean} [frequencyEnabled=false] Show frequency count. also requires qListObjectDef.qFrequencyMode to be set + */ + +/** + * @name ListboxProperties + * @type object + */ + +/** + * @lends ListboxProperties + */ const listdef = { qInfo: { qType: 'njsListbox', }, + /** + * @type {ListObjectDef} + */ qListObjectDef: { qStateName: '', qShowAlternatives: true, @@ -26,15 +51,125 @@ const listdef = { ], }, }, + /** + * Show histogram bar. + * also requires (qListObjectDef.qFrequencyMode 'V' and frequencyMax) or qListObjectDef.qFrequencyMode 'P' + * @type {boolean=} + * @default + */ histogram: false, + /** + * frequencyMax calculation + * needed for histogram when not using qListObjectDef.qFrequencyMode: 'P' + * use an expression in the form `Max(AGGR(Count([field]), [field]))` (when needed) + * or 'fetch' that triggers an extra engine call but needed for library dimension that could change field when using the object + * @type {('fetch' | ValueExpression)=} + */ + frequencyMax: undefined, + /** + * Show values as checkboxes instead of as fields. + * @type {boolean=} + * @default + */ checkboxes: false, + /** + * enables search. + * @type {boolean=} + * @default + */ + searchEnabled: true, + /** + * show title. + * @type {boolean=} + * @default + */ + showTitle: true, + /** + * start search with wildcard search. + * @type {boolean=} + * @default + */ + wildCardSearch: false, + /** + * layout settings. + * @type {object=} + */ layoutOptions: { + /** + * dense mode. + * @type {boolean=} + * @default + */ dense: false, + /** + * layout mode. + * @type {('singleColumn' | 'grid')=} + * @default + */ dataLayout: 'singleColumn', + /** + * layout order. + * Only used when dataLayout is 'grid' + * @type {('row' | 'column')=} + * @default + */ layoutOrder: 'row', - maxVisibleColumns: { auto: true }, - maxVisibleRows: { auto: true }, + /** + * max visible columns. + * Only used when dataLayout is 'grid' + * and layoutOrder is 'row' + * @type {object=} + */ + maxVisibleColumns: { + /** + * auto max visible columns. (as many as it can fit) + * Only used when dataLayout is 'grid' + * and layoutOrder is 'row' + * @type {boolean=} + * @default + */ + auto: true, + /** + * fixed number of max visible columns. + * Only used when dataLayout is 'grid' + * layoutOrder is 'row' + * and auto is false + * @type {number=} + * @default + */ + maxColumns: 3, + }, + /** + * max visible rows. + * Only used when dataLayout is 'grid' + * and layoutOrder is 'column' + * @type {object=} + */ + maxVisibleRows: { + /** + * auto max visible rows. (as many as it can fit) + * Only used when dataLayout is 'grid' + * and layoutOrder is 'column' + * @type {boolean=} + * @default + */ + auto: true, + /** + * fixed number of max visible rows. + * Only used when dataLayout is 'grid' + * layoutOrder is 'column' + * and auto is false + * @type {number=} + * @default + */ + maxRows: 3, + }, }, + /** + * listbox title + * @type {string=} + * @default + */ title: '', }; export default listdef; diff --git a/apis/nucleus/src/components/listbox/hooks/__tests__/useOnTheFlyModel.test.jsx b/apis/nucleus/src/components/listbox/hooks/__tests__/useOnTheFlyModel.test.jsx index 5cfb65c73..8e16a9d7f 100644 --- a/apis/nucleus/src/components/listbox/hooks/__tests__/useOnTheFlyModel.test.jsx +++ b/apis/nucleus/src/components/listbox/hooks/__tests__/useOnTheFlyModel.test.jsx @@ -109,9 +109,11 @@ describe('useExistingModel', () => { layoutOrder: 'row', maxVisibleColumns: { auto: true, + maxColumns: 3, }, maxVisibleRows: { auto: true, + maxRows: 3, }, }); @@ -121,7 +123,7 @@ describe('useExistingModel', () => { dense: false, dataLayout: 'grid', layoutOrder: 'column', - maxVisibleColumns: { auto: true }, + maxVisibleColumns: { auto: true, maxColumns: 3 }, maxVisibleRows: { auto: false, maxRows: 1 }, }); }); @@ -136,9 +138,11 @@ describe('useExistingModel', () => { layoutOrder: 'row', maxVisibleColumns: { auto: true, + maxColumns: 3, }, maxVisibleRows: { auto: true, + maxRows: 3, }, }); }); diff --git a/apis/nucleus/src/index.js b/apis/nucleus/src/index.js index 8696329be..59bebd953 100644 --- a/apis/nucleus/src/index.js +++ b/apis/nucleus/src/index.js @@ -480,7 +480,7 @@ function nuked(configuration = {}) { * @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields (not applicable for existing objects) * @param {boolean=} [options.dense=false] Reduces padding and text size (not applicable for existing objects) * @param {string=} [options.stateName="$"] Sets the state to make selections in (not applicable for existing objects) - * @param {object=} [options.properties={}] Properties object to extend default properties with + * @param {ListboxProperties=} [options.properties={}] Properties object to extend default properties with * @returns {Promise} A promise that resolves when the data is fetched. * * @since 1.1.0 diff --git a/apis/nucleus/src/object/__tests__/filterpane-handler.test.js b/apis/nucleus/src/object/__tests__/filterpane-handler.test.js index d2b0028ff..54ed2feb2 100644 --- a/apis/nucleus/src/object/__tests__/filterpane-handler.test.js +++ b/apis/nucleus/src/object/__tests__/filterpane-handler.test.js @@ -39,6 +39,9 @@ describe('filterpane-handler', () => { qType: expect.any(String), }, title: 'A', + searchEnabled: true, + showTitle: true, + wildCardSearch: false, checkboxes: false, histogram: false, layoutOptions: { @@ -47,9 +50,11 @@ describe('filterpane-handler', () => { layoutOrder: 'row', maxVisibleColumns: { auto: true, + maxColumns: 3, }, maxVisibleRows: { auto: true, + maxRows: 3, }, }, qListObjectDef: { @@ -95,6 +100,9 @@ describe('filterpane-handler', () => { qType: expect.any(String), }, title: 'lib dim title', + searchEnabled: true, + showTitle: true, + wildCardSearch: false, checkboxes: false, histogram: false, layoutOptions: { @@ -103,9 +111,11 @@ describe('filterpane-handler', () => { layoutOrder: 'row', maxVisibleColumns: { auto: true, + maxColumns: 3, }, maxVisibleRows: { auto: true, + maxRows: 3, }, }, qListObjectDef: { @@ -156,6 +166,9 @@ describe('filterpane-handler', () => { qType: expect.any(String), }, title: 'C', + searchEnabled: true, + showTitle: true, + wildCardSearch: false, checkboxes: true, histogram: false, layoutOptions: { @@ -164,9 +177,11 @@ describe('filterpane-handler', () => { layoutOrder: 'row', maxVisibleColumns: { auto: true, + maxColumns: 3, }, maxVisibleRows: { auto: true, + maxRows: 3, }, }, qListObjectDef: { @@ -218,6 +233,9 @@ describe('filterpane-handler', () => { qType: expect.any(String), }, title: 'My custom title', + searchEnabled: true, + showTitle: true, + wildCardSearch: false, checkboxes: true, histogram: false, layoutOptions: { @@ -226,9 +244,11 @@ describe('filterpane-handler', () => { layoutOrder: 'row', maxVisibleColumns: { auto: true, + maxColumns: 3, }, maxVisibleRows: { auto: true, + maxRows: 3, }, }, qListObjectDef: { diff --git a/apis/stardust/api-spec/spec.conf.js b/apis/stardust/api-spec/spec.conf.js index ce5f13a75..4b28b3297 100644 --- a/apis/stardust/api-spec/spec.conf.js +++ b/apis/stardust/api-spec/spec.conf.js @@ -40,6 +40,9 @@ module.exports = { 'EngineAPI.INxMeasure': { url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FNxMeasure', }, + 'EngineAPI.IListObjectDef': { + url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FListObjectDef', + }, Emitter: { url: 'https://nodejs.org/api/events.html#class-eventemitter', }, diff --git a/apis/stardust/api-spec/spec.json b/apis/stardust/api-spec/spec.json index 71adf600b..c7b858f6f 100644 --- a/apis/stardust/api-spec/spec.json +++ b/apis/stardust/api-spec/spec.json @@ -1077,7 +1077,7 @@ "description": "Properties object to extend default properties with", "optional": true, "defaultValue": "{}", - "type": "object" + "type": "#/definitions/ListboxProperties" } } } @@ -1699,6 +1699,178 @@ } } }, + "ValueExpression": { + "description": "see: https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FValueExpression", + "kind": "object", + "entries": { + "qValueExpression": { + "kind": "object", + "entries": { + "qExpr": { + "type": "string" + } + } + } + } + }, + "ListObjectDef": { + "description": "Extends `ListObjectDef`, see Engine API: `ListObjectDef`.", + "extends": [ + { + "type": "EngineAPI.IListObjectDef" + } + ], + "kind": "interface", + "entries": { + "frequencyEnabled": { + "description": "Show frequency count. also requires qListObjectDef.qFrequencyMode to be set", + "optional": true, + "defaultValue": false, + "type": "boolean" + } + } + }, + "ListboxProperties": { + "entries": { + "qListObjectDef": { + "type": "#/definitions/ListObjectDef" + }, + "histogram": { + "description": "Show histogram bar.\nalso requires (qListObjectDef.qFrequencyMode 'V' and frequencyMax) or qListObjectDef.qFrequencyMode 'P'", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "frequencyMax": { + "description": "frequencyMax calculation\nneeded for histogram when not using qListObjectDef.qFrequencyMode: 'P'\nuse an expression in the form `Max(AGGR(Count([field]), [field]))` (when needed)\nor 'fetch' that triggers an extra engine call but needed for library dimension that could change field when using the object", + "optional": true, + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'fetch'" + }, + { + "type": "#/definitions/ValueExpression" + } + ] + }, + "checkboxes": { + "description": "Show values as checkboxes instead of as fields.", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "searchEnabled": { + "description": "enables search.", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "showTitle": { + "description": "show title.", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "wildCardSearch": { + "description": "start search with wildcard search.", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "layoutOptions": { + "description": "layout settings.", + "optional": true, + "entries": { + "dense": { + "description": "dense mode.", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "dataLayout": { + "description": "layout mode.", + "optional": true, + "defaultValue": "singleColumn", + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'singleColumn'" + }, + { + "kind": "literal", + "value": "'grid'" + } + ] + }, + "layoutOrder": { + "description": "layout order.\nOnly used when dataLayout is 'grid'", + "optional": true, + "defaultValue": "row", + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'row'" + }, + { + "kind": "literal", + "value": "'column'" + } + ] + }, + "maxVisibleColumns": { + "description": "max visible columns.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", + "optional": true, + "entries": { + "auto": { + "description": "auto max visible columns. (as many as it can fit)\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "maxColumns": { + "description": "fixed number of max visible columns.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'row'\nand auto is false", + "optional": true, + "defaultValue": 3, + "type": "number" + } + }, + "kind": "object" + }, + "maxVisibleRows": { + "description": "max visible rows.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", + "optional": true, + "entries": { + "auto": { + "description": "auto max visible rows. (as many as it can fit)\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "maxRows": { + "description": "fixed number of max visible rows.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'column'\nand auto is false", + "optional": true, + "defaultValue": 3, + "type": "number" + } + }, + "kind": "object" + } + }, + "kind": "object" + }, + "title": { + "description": "listbox title", + "optional": true, + "defaultValue": "", + "type": "string" + } + }, + "kind": "object" + }, "ActionToolbarElement": { "availability": { "since": "2.1.0" diff --git a/apis/stardust/types/index.d.ts b/apis/stardust/types/index.d.ts index 1096405dc..cde833953 100644 --- a/apis/stardust/types/index.d.ts +++ b/apis/stardust/types/index.d.ts @@ -321,7 +321,7 @@ declare namespace stardust { checkboxes?: boolean; dense?: boolean; stateName?: string; - properties?: object; + properties?: stardust.ListboxProperties; }): Promise; /** @@ -524,6 +524,43 @@ declare namespace stardust { meta?: object; } + type ValueExpression = { + qValueExpression: { + qExpr: string; + }; + }; + + /** + * Extends `ListObjectDef`, see Engine API: `ListObjectDef`. + */ + interface ListObjectDef extends EngineAPI.IListObjectDef{ + frequencyEnabled?: boolean; + } + + type ListboxProperties = { + qListObjectDef: stardust.ListObjectDef; + histogram?: boolean; + frequencyMax?: "fetch" | stardust.ValueExpression; + checkboxes?: boolean; + searchEnabled?: boolean; + showTitle?: boolean; + wildCardSearch?: boolean; + layoutOptions?: { + dense?: boolean; + dataLayout?: "singleColumn" | "grid"; + layoutOrder?: "row" | "column"; + maxVisibleColumns?: { + auto?: boolean; + maxColumns?: number; + }; + maxVisibleRows?: { + auto?: boolean; + maxRows?: number; + }; + }; + title?: string; + }; + interface ActionToolbarElement extends HTMLElement{ className: "njs-action-toolbar-popover"; } From 9ab7b43340c6d0cde3f08ff058d0c78dd70cc1fb Mon Sep 17 00:00:00 2001 From: Tobias Linsefors Date: Tue, 25 Apr 2023 09:16:51 +0200 Subject: [PATCH 2/3] docs: update descriptions --- .../components/listbox/default-properties.js | 28 +++++++++---------- apis/stardust/api-spec/spec.json | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apis/nucleus/src/components/listbox/default-properties.js b/apis/nucleus/src/components/listbox/default-properties.js index 145b27a99..106c3692e 100644 --- a/apis/nucleus/src/components/listbox/default-properties.js +++ b/apis/nucleus/src/components/listbox/default-properties.js @@ -73,56 +73,56 @@ const listdef = { */ checkboxes: false, /** - * enables search. + * Enables search. * @type {boolean=} * @default */ searchEnabled: true, /** - * show title. + * Show title. * @type {boolean=} * @default */ showTitle: true, /** - * start search with wildcard search. + * Pre-fill search input field with wildcard characters. * @type {boolean=} * @default */ wildCardSearch: false, /** - * layout settings. + * Layout settings. * @type {object=} */ layoutOptions: { /** - * dense mode. + * Dense mode. * @type {boolean=} * @default */ dense: false, /** - * layout mode. + * Layout mode. * @type {('singleColumn' | 'grid')=} * @default */ dataLayout: 'singleColumn', /** - * layout order. + * Layout order. * Only used when dataLayout is 'grid' * @type {('row' | 'column')=} * @default */ layoutOrder: 'row', /** - * max visible columns. + * Max visible columns. * Only used when dataLayout is 'grid' * and layoutOrder is 'row' * @type {object=} */ maxVisibleColumns: { /** - * auto max visible columns. (as many as it can fit) + * Automatically fit as many columns as possible. * Only used when dataLayout is 'grid' * and layoutOrder is 'row' * @type {boolean=} @@ -130,7 +130,7 @@ const listdef = { */ auto: true, /** - * fixed number of max visible columns. + * Fixed number of max visible columns. * Only used when dataLayout is 'grid' * layoutOrder is 'row' * and auto is false @@ -140,14 +140,14 @@ const listdef = { maxColumns: 3, }, /** - * max visible rows. + * Max visible rows. * Only used when dataLayout is 'grid' * and layoutOrder is 'column' * @type {object=} */ maxVisibleRows: { /** - * auto max visible rows. (as many as it can fit) + * Automatically fits as many rows as possible. * Only used when dataLayout is 'grid' * and layoutOrder is 'column' * @type {boolean=} @@ -155,7 +155,7 @@ const listdef = { */ auto: true, /** - * fixed number of max visible rows. + * Fixed number of max visible rows. * Only used when dataLayout is 'grid' * layoutOrder is 'column' * and auto is false @@ -166,7 +166,7 @@ const listdef = { }, }, /** - * listbox title + * Listbox title * @type {string=} * @default */ diff --git a/apis/stardust/api-spec/spec.json b/apis/stardust/api-spec/spec.json index c7b858f6f..0ac11f9fe 100644 --- a/apis/stardust/api-spec/spec.json +++ b/apis/stardust/api-spec/spec.json @@ -1762,35 +1762,35 @@ "type": "boolean" }, "searchEnabled": { - "description": "enables search.", + "description": "Enables search.", "optional": true, "defaultValue": true, "type": "boolean" }, "showTitle": { - "description": "show title.", + "description": "Show title.", "optional": true, "defaultValue": true, "type": "boolean" }, "wildCardSearch": { - "description": "start search with wildcard search.", + "description": "Pre-fill search input field with wildcard characters.", "optional": true, "defaultValue": false, "type": "boolean" }, "layoutOptions": { - "description": "layout settings.", + "description": "Layout settings.", "optional": true, "entries": { "dense": { - "description": "dense mode.", + "description": "Dense mode.", "optional": true, "defaultValue": false, "type": "boolean" }, "dataLayout": { - "description": "layout mode.", + "description": "Layout mode.", "optional": true, "defaultValue": "singleColumn", "kind": "union", @@ -1806,7 +1806,7 @@ ] }, "layoutOrder": { - "description": "layout order.\nOnly used when dataLayout is 'grid'", + "description": "Layout order.\nOnly used when dataLayout is 'grid'", "optional": true, "defaultValue": "row", "kind": "union", @@ -1822,17 +1822,17 @@ ] }, "maxVisibleColumns": { - "description": "max visible columns.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", + "description": "Max visible columns.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", "optional": true, "entries": { "auto": { - "description": "auto max visible columns. (as many as it can fit)\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", + "description": "Automatically fit as many columns as possible.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", "optional": true, "defaultValue": true, "type": "boolean" }, "maxColumns": { - "description": "fixed number of max visible columns.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'row'\nand auto is false", + "description": "Fixed number of max visible columns.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'row'\nand auto is false", "optional": true, "defaultValue": 3, "type": "number" @@ -1841,17 +1841,17 @@ "kind": "object" }, "maxVisibleRows": { - "description": "max visible rows.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", + "description": "Max visible rows.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", "optional": true, "entries": { "auto": { - "description": "auto max visible rows. (as many as it can fit)\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", + "description": "Automatically fits as many rows as possible.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", "optional": true, "defaultValue": true, "type": "boolean" }, "maxRows": { - "description": "fixed number of max visible rows.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'column'\nand auto is false", + "description": "Fixed number of max visible rows.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'column'\nand auto is false", "optional": true, "defaultValue": 3, "type": "number" @@ -1863,7 +1863,7 @@ "kind": "object" }, "title": { - "description": "listbox title", + "description": "Listbox title", "optional": true, "defaultValue": "", "type": "string" From 436232b095017eaa2e28c572161399047238409d Mon Sep 17 00:00:00 2001 From: Tobias Linsefors Date: Wed, 26 Apr 2023 12:58:46 +0200 Subject: [PATCH 3/3] chore: split listbox to new api --- apis/nucleus/src/index.js | 2 +- apis/stardust/api-spec/listbox-spec.conf.js | 24 +++ apis/stardust/api-spec/listbox-spec.json | 185 ++++++++++++++++++++ apis/stardust/api-spec/spec.conf.js | 4 +- apis/stardust/api-spec/spec.json | 174 +----------------- apis/stardust/package.json | 4 +- apis/stardust/types/index.d.ts | 39 +---- apis/supernova/spec/spec.conf.js | 1 + 8 files changed, 217 insertions(+), 216 deletions(-) create mode 100644 apis/stardust/api-spec/listbox-spec.conf.js create mode 100644 apis/stardust/api-spec/listbox-spec.json diff --git a/apis/nucleus/src/index.js b/apis/nucleus/src/index.js index 59bebd953..8696329be 100644 --- a/apis/nucleus/src/index.js +++ b/apis/nucleus/src/index.js @@ -480,7 +480,7 @@ function nuked(configuration = {}) { * @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields (not applicable for existing objects) * @param {boolean=} [options.dense=false] Reduces padding and text size (not applicable for existing objects) * @param {string=} [options.stateName="$"] Sets the state to make selections in (not applicable for existing objects) - * @param {ListboxProperties=} [options.properties={}] Properties object to extend default properties with + * @param {object=} [options.properties={}] Properties object to extend default properties with * @returns {Promise} A promise that resolves when the data is fetched. * * @since 1.1.0 diff --git a/apis/stardust/api-spec/listbox-spec.conf.js b/apis/stardust/api-spec/listbox-spec.conf.js new file mode 100644 index 000000000..929a03780 --- /dev/null +++ b/apis/stardust/api-spec/listbox-spec.conf.js @@ -0,0 +1,24 @@ +module.exports = { + fromJsdoc: { + glob: ['../nucleus/src/components/listbox/default-properties.js'], + api: { + stability: 'experimental', + name: '@nebula.js/stardust:listbox', + description: 'nebula listbox properties definition', + }, + output: { + sort: { + alpha: true, + }, + file: './api-spec/listbox-spec.json', + }, + parse: { + types: { + undefined: {}, + 'EngineAPI.IListObjectDef': { + url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FListObjectDef', + }, + }, + }, + }, +}; diff --git a/apis/stardust/api-spec/listbox-spec.json b/apis/stardust/api-spec/listbox-spec.json new file mode 100644 index 000000000..4a4846949 --- /dev/null +++ b/apis/stardust/api-spec/listbox-spec.json @@ -0,0 +1,185 @@ +{ + "scriptappy": "1.1.0", + "info": { + "name": "@nebula.js/stardust:listbox", + "description": "nebula listbox properties definition", + "version": "4.0.0-alpha.9", + "license": "MIT", + "stability": "experimental" + }, + "entries": {}, + "definitions": { + "ListboxProperties": { + "entries": { + "checkboxes": { + "description": "Show values as checkboxes instead of as fields.", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "frequencyMax": { + "description": "frequencyMax calculation\nneeded for histogram when not using qListObjectDef.qFrequencyMode: 'P'\nuse an expression in the form `Max(AGGR(Count([field]), [field]))` (when needed)\nor 'fetch' that triggers an extra engine call but needed for library dimension that could change field when using the object", + "optional": true, + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'fetch'" + }, + { + "type": "#/definitions/ValueExpression" + } + ] + }, + "histogram": { + "description": "Show histogram bar.\nalso requires (qListObjectDef.qFrequencyMode 'V' and frequencyMax) or qListObjectDef.qFrequencyMode 'P'", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "layoutOptions": { + "description": "Layout settings.", + "optional": true, + "entries": { + "dataLayout": { + "description": "Layout mode.", + "optional": true, + "defaultValue": "singleColumn", + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'singleColumn'" + }, + { + "kind": "literal", + "value": "'grid'" + } + ] + }, + "dense": { + "description": "Dense mode.", + "optional": true, + "defaultValue": false, + "type": "boolean" + }, + "layoutOrder": { + "description": "Layout order.\nOnly used when dataLayout is 'grid'", + "optional": true, + "defaultValue": "row", + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'row'" + }, + { + "kind": "literal", + "value": "'column'" + } + ] + }, + "maxVisibleColumns": { + "description": "Max visible columns.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", + "optional": true, + "entries": { + "auto": { + "description": "Automatically fit as many columns as possible.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "maxColumns": { + "description": "Fixed number of max visible columns.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'row'\nand auto is false", + "optional": true, + "defaultValue": 3, + "type": "number" + } + }, + "kind": "object" + }, + "maxVisibleRows": { + "description": "Max visible rows.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", + "optional": true, + "entries": { + "auto": { + "description": "Automatically fits as many rows as possible.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "maxRows": { + "description": "Fixed number of max visible rows.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'column'\nand auto is false", + "optional": true, + "defaultValue": 3, + "type": "number" + } + }, + "kind": "object" + } + }, + "kind": "object" + }, + "qListObjectDef": { + "type": "#/definitions/ListObjectDef" + }, + "searchEnabled": { + "description": "Enables search.", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "showTitle": { + "description": "Show title.", + "optional": true, + "defaultValue": true, + "type": "boolean" + }, + "title": { + "description": "Listbox title", + "optional": true, + "defaultValue": "", + "type": "string" + }, + "wildCardSearch": { + "description": "Pre-fill search input field with wildcard characters.", + "optional": true, + "defaultValue": false, + "type": "boolean" + } + }, + "kind": "object" + }, + "ListObjectDef": { + "description": "Extends `ListObjectDef`, see Engine API: `ListObjectDef`.", + "extends": [ + { + "type": "EngineAPI.IListObjectDef" + } + ], + "kind": "interface", + "entries": { + "frequencyEnabled": { + "description": "Show frequency count. also requires qListObjectDef.qFrequencyMode to be set", + "optional": true, + "defaultValue": false, + "type": "boolean" + } + } + }, + "ValueExpression": { + "description": "see: https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FValueExpression", + "kind": "object", + "entries": { + "qValueExpression": { + "kind": "object", + "entries": { + "qExpr": { + "type": "string" + } + } + } + } + } + } +} diff --git a/apis/stardust/api-spec/spec.conf.js b/apis/stardust/api-spec/spec.conf.js index 4b28b3297..18273983d 100644 --- a/apis/stardust/api-spec/spec.conf.js +++ b/apis/stardust/api-spec/spec.conf.js @@ -9,6 +9,7 @@ module.exports = { '../theme/src/**/*.js', '../conversion/src/**/*.js', '../enigma-mocker/src/**/*.js', + '!../nucleus/src/components/listbox/default-properties.js', ], api: { stability: 'stable', @@ -40,9 +41,6 @@ module.exports = { 'EngineAPI.INxMeasure': { url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FNxMeasure', }, - 'EngineAPI.IListObjectDef': { - url: 'https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FListObjectDef', - }, Emitter: { url: 'https://nodejs.org/api/events.html#class-eventemitter', }, diff --git a/apis/stardust/api-spec/spec.json b/apis/stardust/api-spec/spec.json index 0ac11f9fe..71adf600b 100644 --- a/apis/stardust/api-spec/spec.json +++ b/apis/stardust/api-spec/spec.json @@ -1077,7 +1077,7 @@ "description": "Properties object to extend default properties with", "optional": true, "defaultValue": "{}", - "type": "#/definitions/ListboxProperties" + "type": "object" } } } @@ -1699,178 +1699,6 @@ } } }, - "ValueExpression": { - "description": "see: https://qlik.dev/apis/json-rpc/qix/schemas#%23%2Fdefinitions%2Fschemas%2Fentries%2FValueExpression", - "kind": "object", - "entries": { - "qValueExpression": { - "kind": "object", - "entries": { - "qExpr": { - "type": "string" - } - } - } - } - }, - "ListObjectDef": { - "description": "Extends `ListObjectDef`, see Engine API: `ListObjectDef`.", - "extends": [ - { - "type": "EngineAPI.IListObjectDef" - } - ], - "kind": "interface", - "entries": { - "frequencyEnabled": { - "description": "Show frequency count. also requires qListObjectDef.qFrequencyMode to be set", - "optional": true, - "defaultValue": false, - "type": "boolean" - } - } - }, - "ListboxProperties": { - "entries": { - "qListObjectDef": { - "type": "#/definitions/ListObjectDef" - }, - "histogram": { - "description": "Show histogram bar.\nalso requires (qListObjectDef.qFrequencyMode 'V' and frequencyMax) or qListObjectDef.qFrequencyMode 'P'", - "optional": true, - "defaultValue": false, - "type": "boolean" - }, - "frequencyMax": { - "description": "frequencyMax calculation\nneeded for histogram when not using qListObjectDef.qFrequencyMode: 'P'\nuse an expression in the form `Max(AGGR(Count([field]), [field]))` (when needed)\nor 'fetch' that triggers an extra engine call but needed for library dimension that could change field when using the object", - "optional": true, - "kind": "union", - "items": [ - { - "kind": "literal", - "value": "'fetch'" - }, - { - "type": "#/definitions/ValueExpression" - } - ] - }, - "checkboxes": { - "description": "Show values as checkboxes instead of as fields.", - "optional": true, - "defaultValue": false, - "type": "boolean" - }, - "searchEnabled": { - "description": "Enables search.", - "optional": true, - "defaultValue": true, - "type": "boolean" - }, - "showTitle": { - "description": "Show title.", - "optional": true, - "defaultValue": true, - "type": "boolean" - }, - "wildCardSearch": { - "description": "Pre-fill search input field with wildcard characters.", - "optional": true, - "defaultValue": false, - "type": "boolean" - }, - "layoutOptions": { - "description": "Layout settings.", - "optional": true, - "entries": { - "dense": { - "description": "Dense mode.", - "optional": true, - "defaultValue": false, - "type": "boolean" - }, - "dataLayout": { - "description": "Layout mode.", - "optional": true, - "defaultValue": "singleColumn", - "kind": "union", - "items": [ - { - "kind": "literal", - "value": "'singleColumn'" - }, - { - "kind": "literal", - "value": "'grid'" - } - ] - }, - "layoutOrder": { - "description": "Layout order.\nOnly used when dataLayout is 'grid'", - "optional": true, - "defaultValue": "row", - "kind": "union", - "items": [ - { - "kind": "literal", - "value": "'row'" - }, - { - "kind": "literal", - "value": "'column'" - } - ] - }, - "maxVisibleColumns": { - "description": "Max visible columns.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", - "optional": true, - "entries": { - "auto": { - "description": "Automatically fit as many columns as possible.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'row'", - "optional": true, - "defaultValue": true, - "type": "boolean" - }, - "maxColumns": { - "description": "Fixed number of max visible columns.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'row'\nand auto is false", - "optional": true, - "defaultValue": 3, - "type": "number" - } - }, - "kind": "object" - }, - "maxVisibleRows": { - "description": "Max visible rows.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", - "optional": true, - "entries": { - "auto": { - "description": "Automatically fits as many rows as possible.\nOnly used when dataLayout is 'grid'\nand layoutOrder is 'column'", - "optional": true, - "defaultValue": true, - "type": "boolean" - }, - "maxRows": { - "description": "Fixed number of max visible rows.\nOnly used when dataLayout is 'grid'\nlayoutOrder is 'column'\nand auto is false", - "optional": true, - "defaultValue": 3, - "type": "number" - } - }, - "kind": "object" - } - }, - "kind": "object" - }, - "title": { - "description": "Listbox title", - "optional": true, - "defaultValue": "", - "type": "string" - } - }, - "kind": "object" - }, "ActionToolbarElement": { "availability": { "since": "2.1.0" diff --git a/apis/stardust/package.json b/apis/stardust/package.json index 82c9dc8d0..14075e17a 100644 --- a/apis/stardust/package.json +++ b/apis/stardust/package.json @@ -34,7 +34,9 @@ "build:dev": "rollup --config ../../rollup.config.js", "build:watch": "rollup --config ../../rollup.config.js -w", "prepublishOnly": "rm -rf dist && yarn run build", - "spec": "sy from-jsdoc -c ./api-spec/spec.conf.js", + "spec:stardust": "sy from-jsdoc -c ./api-spec/spec.conf.js", + "spec:listbox": "sy from-jsdoc -c ./api-spec/listbox-spec.conf.js", + "spec": "yarn run spec:stardust && yarn run spec:listbox", "ts": "sy to-dts -c ./api-spec/spec.conf.js", "version": "yarn run spec && yarn run ts && git add ./api-spec/spec.json ./types/index.d.ts" }, diff --git a/apis/stardust/types/index.d.ts b/apis/stardust/types/index.d.ts index cde833953..1096405dc 100644 --- a/apis/stardust/types/index.d.ts +++ b/apis/stardust/types/index.d.ts @@ -321,7 +321,7 @@ declare namespace stardust { checkboxes?: boolean; dense?: boolean; stateName?: string; - properties?: stardust.ListboxProperties; + properties?: object; }): Promise; /** @@ -524,43 +524,6 @@ declare namespace stardust { meta?: object; } - type ValueExpression = { - qValueExpression: { - qExpr: string; - }; - }; - - /** - * Extends `ListObjectDef`, see Engine API: `ListObjectDef`. - */ - interface ListObjectDef extends EngineAPI.IListObjectDef{ - frequencyEnabled?: boolean; - } - - type ListboxProperties = { - qListObjectDef: stardust.ListObjectDef; - histogram?: boolean; - frequencyMax?: "fetch" | stardust.ValueExpression; - checkboxes?: boolean; - searchEnabled?: boolean; - showTitle?: boolean; - wildCardSearch?: boolean; - layoutOptions?: { - dense?: boolean; - dataLayout?: "singleColumn" | "grid"; - layoutOrder?: "row" | "column"; - maxVisibleColumns?: { - auto?: boolean; - maxColumns?: number; - }; - maxVisibleRows?: { - auto?: boolean; - maxRows?: number; - }; - }; - title?: string; - }; - interface ActionToolbarElement extends HTMLElement{ className: "njs-action-toolbar-popover"; } diff --git a/apis/supernova/spec/spec.conf.js b/apis/supernova/spec/spec.conf.js index a06dbe73f..39c2a9c8a 100644 --- a/apis/supernova/spec/spec.conf.js +++ b/apis/supernova/spec/spec.conf.js @@ -3,6 +3,7 @@ module.exports = { glob: [ './src/**/*.js', '!./src/**/*.spec.js', + '!../nucleus/src/components/listbox/default-properties.js', '../nucleus/src/hooks/useObjectSelections.js', '../locale/src/translator.js', '../theme/src/**/*.js',