From d26e374febcce091650da889a027f50b38f21d77 Mon Sep 17 00:00:00 2001 From: Tobias Linsefors Date: Wed, 26 Apr 2023 12:58:46 +0200 Subject: [PATCH] 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',