@vuu-ui/vuu-utils 0.8.64 → 0.8.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/column-utils.js +150 -116
- package/cjs/column-utils.js.map +1 -1
- package/cjs/feature-utils.js +7 -1
- package/cjs/feature-utils.js.map +1 -1
- package/cjs/html-utils.js +1 -1
- package/cjs/html-utils.js.map +1 -1
- package/cjs/index.js +3 -0
- package/cjs/index.js.map +1 -1
- package/cjs/protocol-message-utils.js +2 -0
- package/cjs/protocol-message-utils.js.map +1 -1
- package/esm/column-utils.js +149 -117
- package/esm/column-utils.js.map +1 -1
- package/esm/feature-utils.js +7 -1
- package/esm/feature-utils.js.map +1 -1
- package/esm/html-utils.js +1 -1
- package/esm/html-utils.js.map +1 -1
- package/esm/index.js +2 -2
- package/esm/protocol-message-utils.js +2 -1
- package/esm/protocol-message-utils.js.map +1 -1
- package/package.json +6 -6
- package/types/broadcast-channel.d.ts +16 -0
- package/types/column-utils.d.ts +12 -13
- package/types/feature-utils.d.ts +1 -0
- package/types/html-utils.d.ts +2 -2
- package/types/index.d.ts +1 -0
- package/types/protocol-message-utils.d.ts +2 -1
package/cjs/feature-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-utils.js","sources":["../src/feature-utils.ts"],"sourcesContent":["import type { TableSchema } from \"@vuu-ui/vuu-data-types\";\nimport type { VuuTable } from \"@vuu-ui/vuu-protocol-types\";\nimport type { FeatureProps } from \"@vuu-ui/vuu-shell\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\n\nexport type PathMap = { [key: string]: Pick<FeatureConfig, \"css\" | \"url\"> };\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport interface ViewConfig {\n closeable?: boolean;\n header?: boolean;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface FeatureConfig {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n schema?: \"*\" | VuuTable;\n schemas?: VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type Features = {\n [key: string]: FeatureConfig;\n};\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: FeatureConfig) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (schema?: \"*\" | VuuTable): schema is \"*\" =>\n schema === \"*\";\nexport const isTableSchema = (schema?: \"*\" | VuuTable): schema is VuuTable =>\n typeof schema === \"object\" &&\n typeof schema.module === \"string\" &&\n typeof schema.table === \"string\";\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<FeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: FeatureProps\n): props is FeaturePropsWithFilterTableFeature =>\n \"tableSchema\" in (props?.ComponentProps ?? {});\n\n// Sort TableScheas by module\nexport const byModule = (schema1: TableSchema, schema2: TableSchema) => {\n const m1 = schema1.table.module.toLowerCase();\n const m2 = schema2.table.module.toLowerCase();\n if (m1 < m2) {\n return -1;\n } else if (m1 > m2) {\n return 1;\n } else if (schema1.table.table < schema2.table.table) {\n return -1;\n } else if (schema1.table.table > schema2.table.table) {\n return 1;\n } else {\n return 0;\n }\n};\n\nexport type GetFeaturePaths = (params: {\n env: Environment;\n fileName: string;\n withCss?: boolean;\n}) => FeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths\n) =>\n schemas\n .sort(byModule)\n .map<FeatureProps<FilterTableFeatureProps>>((schema) => ({\n ...getFeaturePath({ env, fileName: \"FilterTable\" }),\n ComponentProps: {\n tableSchema: schema,\n },\n title: `${schema.table.module} ${schema.table.table}`,\n }));\n\nexport const assertComponentRegistered = (\n componentName: string,\n component: unknown\n) => {\n if (typeof component !== \"function\") {\n console.warn(\n `${componentName} module not loaded, will be unabale to deserialize from layout JSON`\n );\n }\n};\n\nexport const getCustomAndTableFeatures = (\n features: Features,\n vuuTables: Map<string, TableSchema>\n): [FeatureProps[], FeatureProps<FilterTableFeatureProps>[]] => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n Object.values(features),\n isCustomFeature\n );\n\n const customFeatures: FeatureProps[] = [];\n const tableFeatures: FeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { schema } = featureProps;\n if (isWildcardSchema(schema) && vuuTables) {\n for (const tableSchema of vuuTables.values()) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n title: `${tableSchema.table.module} ${wordify(\n tableSchema.table.table\n )}`,\n ViewProps: viewProps,\n });\n }\n } else if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n if (tableSchema) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { schema, schemas } = featureProps;\n if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n customFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n } else if (Array.isArray(schemas) && vuuTables) {\n customFeatures.push({\n ...feature,\n ComponentProps: schemas.reduce<Record<string, TableSchema>>(\n (map, schema) => {\n map[`${schema.table}Schema`] = vuuTables.get(\n schema.table\n ) as TableSchema;\n return map;\n },\n {}\n ),\n ViewProps: viewProps,\n });\n } else {\n customFeatures.push(feature);\n }\n }\n return [customFeatures, tableFeatures];\n};\n"],"names":["partition","wordify","schema"],"mappings":";;;;;AAQa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA,SAAA;
|
|
1
|
+
{"version":3,"file":"feature-utils.js","sources":["../src/feature-utils.ts"],"sourcesContent":["import type { TableSchema } from \"@vuu-ui/vuu-data-types\";\nimport type { VuuTable } from \"@vuu-ui/vuu-protocol-types\";\nimport type { FeatureProps } from \"@vuu-ui/vuu-shell\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\n\nexport type PathMap = { [key: string]: Pick<FeatureConfig, \"css\" | \"url\"> };\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface FeatureConfig {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n schema?: \"*\" | VuuTable;\n schemas?: VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type Features = {\n [key: string]: FeatureConfig;\n};\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: FeatureConfig) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (schema?: \"*\" | VuuTable): schema is \"*\" =>\n schema === \"*\";\nexport const isTableSchema = (schema?: \"*\" | VuuTable): schema is VuuTable =>\n typeof schema === \"object\" &&\n typeof schema.module === \"string\" &&\n typeof schema.table === \"string\";\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<FeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: FeatureProps\n): props is FeaturePropsWithFilterTableFeature =>\n \"tableSchema\" in (props?.ComponentProps ?? {});\n\n// Sort TableScheas by module\nexport const byModule = (schema1: TableSchema, schema2: TableSchema) => {\n const m1 = schema1.table.module.toLowerCase();\n const m2 = schema2.table.module.toLowerCase();\n if (m1 < m2) {\n return -1;\n } else if (m1 > m2) {\n return 1;\n } else if (schema1.table.table < schema2.table.table) {\n return -1;\n } else if (schema1.table.table > schema2.table.table) {\n return 1;\n } else {\n return 0;\n }\n};\n\nexport type GetFeaturePaths = (params: {\n env: Environment;\n fileName: string;\n withCss?: boolean;\n}) => FeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths\n) =>\n schemas\n .sort(byModule)\n .map<FeatureProps<FilterTableFeatureProps>>((schema) => ({\n ...getFeaturePath({ env, fileName: \"FilterTable\" }),\n ComponentProps: {\n tableSchema: schema,\n },\n ViewProps: {\n allowRename: true,\n },\n title: `${schema.table.module} ${schema.table.table}`,\n }));\n\nexport const assertComponentRegistered = (\n componentName: string,\n component: unknown\n) => {\n if (typeof component !== \"function\") {\n console.warn(\n `${componentName} module not loaded, will be unabale to deserialize from layout JSON`\n );\n }\n};\n\nexport const getCustomAndTableFeatures = (\n features: Features,\n vuuTables: Map<string, TableSchema>\n): [FeatureProps[], FeatureProps<FilterTableFeatureProps>[]] => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n Object.values(features),\n isCustomFeature\n );\n\n const customFeatures: FeatureProps[] = [];\n const tableFeatures: FeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { schema } = featureProps;\n if (isWildcardSchema(schema) && vuuTables) {\n for (const tableSchema of vuuTables.values()) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n title: `${tableSchema.table.module} ${wordify(\n tableSchema.table.table\n )}`,\n ViewProps: {\n ...viewProps,\n allowRename: true,\n },\n });\n }\n } else if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n if (tableSchema) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { schema, schemas } = featureProps;\n if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n customFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n } else if (Array.isArray(schemas) && vuuTables) {\n customFeatures.push({\n ...feature,\n ComponentProps: schemas.reduce<Record<string, TableSchema>>(\n (map, schema) => {\n map[`${schema.table}Schema`] = vuuTables.get(\n schema.table\n ) as TableSchema;\n return map;\n },\n {}\n ),\n ViewProps: viewProps,\n });\n } else {\n customFeatures.push(feature);\n }\n }\n return [customFeatures, tableFeatures];\n};\n"],"names":["partition","wordify","schema"],"mappings":";;;;;AAQa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA,SAAA;AA8CxB,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA,eAAA;AAEjB,MAAA,gBAAA,GAAmB,CAAC,MAAA,KAC/B,MAAW,KAAA,IAAA;AACN,MAAM,aAAgB,GAAA,CAAC,MAC5B,KAAA,OAAO,MAAW,KAAA,QAAA,IAClB,OAAO,MAAA,CAAO,MAAW,KAAA,QAAA,IACzB,OAAO,MAAA,CAAO,KAAU,KAAA,SAAA;AAOnB,MAAM,6BAA6B,CACxC,KAAA,KAEA,aAAkB,KAAA,KAAA,EAAO,kBAAkB,EAAC,EAAA;AAGjC,MAAA,QAAA,GAAW,CAAC,OAAA,EAAsB,OAAyB,KAAA;AACtE,EAAA,MAAM,EAAK,GAAA,OAAA,CAAQ,KAAM,CAAA,MAAA,CAAO,WAAY,EAAA,CAAA;AAC5C,EAAA,MAAM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cssQueryString) => el === null ? null : el.closest(css
|
|
|
37
37
|
const getClosest = (el, dataProperty) => queryClosest(el, `[data-${dataProperty}]`);
|
|
38
38
|
const getClosestIndexItem = (el) => getClosest(el, "index");
|
|
39
39
|
function getElementByDataIndex(container, index, throwIfNotFound = false) {
|
|
40
|
-
if (container
|
|
40
|
+
if (container == null && throwIfNotFound) {
|
|
41
41
|
throw Error("html-utils getElementByDataIndex, container is null");
|
|
42
42
|
}
|
|
43
43
|
const element = container?.querySelector(
|
package/cjs/html-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-utils.js","sources":["../src/html-utils.ts"],"sourcesContent":["export const createEl = (\n elementType: \"div\" | \"p\" | \"span\",\n className?: string,\n textContent?: string\n): HTMLElement => {\n const el = document.createElement(elementType);\n if (className) {\n el.className = className;\n }\n if (textContent) {\n el.textContent = textContent;\n }\n return el;\n};\n\nexport const getFocusableElement = (\n el: HTMLElement | null,\n tabIndex?: number\n) => {\n if (el) {\n if (el.hasAttribute(\"tabindex\")) {\n const rootTabIndex = parseInt(el.getAttribute(\"tabindex\") as string);\n if (\n !isNaN(rootTabIndex) &&\n (tabIndex === undefined || rootTabIndex === tabIndex)\n ) {\n return el;\n }\n }\n const focusableEl =\n typeof tabIndex === \"number\"\n ? (el.querySelector(`[tabindex=\"${tabIndex}\"]`) as HTMLElement)\n : (el.querySelector(\"[tabindex]\") as HTMLElement);\n if (focusableEl) {\n return focusableEl as HTMLElement;\n }\n }\n};\n\nexport const getElementDataIndex = (el: HTMLElement | null) => {\n if (el) {\n const index = parseInt(el.dataset.index || \"\");\n if (!isNaN(index)) {\n return index;\n }\n }\n return -1;\n};\n\nexport const queryClosest = <T extends HTMLElement = HTMLElement>(\n el: HTMLElement | EventTarget | null,\n cssQueryString: string\n) => (el === null ? null : ((el as HTMLElement).closest(cssQueryString) as T));\n\nexport const getClosest = (el: HTMLElement, dataProperty: string) =>\n queryClosest(el, `[data-${dataProperty}]`);\n\nexport const getClosestIndexItem = (el: HTMLElement) => getClosest(el, \"index\");\n\nexport function getElementByDataIndex(\n c: HTMLElement | null,\n i: number | string,\n throwIfNotFound: true\n): HTMLElement;\nexport function getElementByDataIndex(\n c: HTMLElement | null,\n i: number | string,\n throwIfNotFound?: false\n): HTMLElement | undefined;\nexport function getElementByDataIndex(\n container: HTMLElement | null,\n index: number | string,\n throwIfNotFound = false\n) {\n if (container
|
|
1
|
+
{"version":3,"file":"html-utils.js","sources":["../src/html-utils.ts"],"sourcesContent":["export const createEl = (\n elementType: \"div\" | \"p\" | \"span\",\n className?: string,\n textContent?: string\n): HTMLElement => {\n const el = document.createElement(elementType);\n if (className) {\n el.className = className;\n }\n if (textContent) {\n el.textContent = textContent;\n }\n return el;\n};\n\nexport const getFocusableElement = (\n el: HTMLElement | null,\n tabIndex?: number\n) => {\n if (el) {\n if (el.hasAttribute(\"tabindex\")) {\n const rootTabIndex = parseInt(el.getAttribute(\"tabindex\") as string);\n if (\n !isNaN(rootTabIndex) &&\n (tabIndex === undefined || rootTabIndex === tabIndex)\n ) {\n return el;\n }\n }\n const focusableEl =\n typeof tabIndex === \"number\"\n ? (el.querySelector(`[tabindex=\"${tabIndex}\"]`) as HTMLElement)\n : (el.querySelector(\"[tabindex]\") as HTMLElement);\n if (focusableEl) {\n return focusableEl as HTMLElement;\n }\n }\n};\n\nexport const getElementDataIndex = (el: HTMLElement | null) => {\n if (el) {\n const index = parseInt(el.dataset.index || \"\");\n if (!isNaN(index)) {\n return index;\n }\n }\n return -1;\n};\n\nexport const queryClosest = <T extends HTMLElement = HTMLElement>(\n el: HTMLElement | EventTarget | null,\n cssQueryString: string\n) => (el === null ? null : ((el as HTMLElement).closest(cssQueryString) as T));\n\nexport const getClosest = (el: HTMLElement, dataProperty: string) =>\n queryClosest(el, `[data-${dataProperty}]`);\n\nexport const getClosestIndexItem = (el: HTMLElement) => getClosest(el, \"index\");\n\nexport function getElementByDataIndex(\n c: HTMLElement | null | undefined,\n i: number | string,\n throwIfNotFound: true\n): HTMLElement;\nexport function getElementByDataIndex(\n c: HTMLElement | null | undefined,\n i: number | string,\n throwIfNotFound?: false\n): HTMLElement | undefined;\nexport function getElementByDataIndex(\n container: HTMLElement | null | undefined,\n index: number | string,\n throwIfNotFound = false\n) {\n if (container == null && throwIfNotFound) {\n throw Error(\"html-utils getElementByDataIndex, container is null\");\n }\n const element = container?.querySelector(\n `[data-index=\"${index}\"]`\n ) as HTMLElement;\n if (element) {\n return element;\n } else if (throwIfNotFound) {\n throw Error(\n \"html-utils getElementByDataIndex, Item not found with data-index='${index}'\"\n );\n } else {\n return undefined;\n }\n}\n\nexport const focusFirstFocusableElement = (\n el: HTMLElement | null,\n tabIndex?: number\n) => {\n // TODO test el for focusable\n requestAnimationFrame(() => {\n const focusableElement = getFocusableElement(el, tabIndex);\n if (focusableElement) {\n focusableElement.focus();\n }\n });\n};\n\nexport const isSelectableElement = (el?: HTMLElement | null) => {\n const item = el?.closest(\"[data-index]\") as HTMLElement;\n if (\n !item ||\n item.ariaDisabled ||\n item.dataset.selectable === \"false\" ||\n item.querySelector('[data-selectable=\"false\"],[aria-disabled=\"true\"]')\n ) {\n return false;\n } else {\n return true;\n }\n};\n\nexport const hasOpenOptionList = (el: HTMLElement | EventTarget | null) => {\n if (el !== null) {\n return (el as HTMLElement).ariaExpanded === \"true\";\n }\n};\n\nlet size: number;\n\nexport function getScrollbarSize() {\n if (size === undefined) {\n let outer: HTMLElement | null = document.createElement(\"div\");\n outer.className = \"scrollable-content\";\n outer.style.width = \"50px\";\n outer.style.height = \"50px\";\n outer.style.overflowY = \"scroll\";\n outer.style.position = \"absolute\";\n outer.style.top = \"-200px\";\n outer.style.left = \"-200px\";\n const inner = document.createElement(\"div\");\n inner.style.height = \"100px\";\n inner.style.width = \"100%\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n const outerWidth = outer.offsetWidth;\n const innerWidth = inner.offsetWidth;\n document.body.removeChild(outer);\n size = outerWidth - innerWidth;\n outer = null;\n }\n\n return size;\n}\n\nexport type MouseEventTypes = \"dblclick\" | \"click\";\nexport type KeyboardEventTypes = \"keydown\" | \"keypress\" | \"keyup\";\n\nexport const dispatchMouseEvent = (el: HTMLElement, type: MouseEventTypes) => {\n const evt = new MouseEvent(type, {\n view: window,\n bubbles: true,\n cancelable: true,\n });\n el.dispatchEvent(evt);\n};\nexport const dispatchKeyboardEvent = (\n el: HTMLElement,\n type: KeyboardEventTypes,\n key: string\n) => {\n const evt = new KeyboardEvent(type, {\n key,\n view: window,\n bubbles: true,\n cancelable: true,\n });\n el.dispatchEvent(evt);\n};\n\nexport type VuuDomEventType = \"vuu-commit\" | \"vuu-dropped\";\n\nexport const dispatchCustomEvent = (el: HTMLElement, type: VuuDomEventType) => {\n const evt = new Event(type, {\n bubbles: true,\n cancelable: true,\n });\n el.dispatchEvent(evt);\n};\n"],"names":[],"mappings":";;AAAO,MAAM,QAAW,GAAA,CACtB,WACA,EAAA,SAAA,EACA,WACgB,KAAA;AAChB,EAAM,MAAA,EAAA,GAAK,QAAS,CAAA,aAAA,CAAc,WAAW,CAAA,CAAA;AAC7C,EAAA,IAAI,SAAW,EAAA;AACb,IAAA,EAAA,CAAG,SAAY,GAAA,SAAA,CAAA;AAAA,GACjB;AACA,EAAA,IAAI,WAAa,EAAA;AACf,IAAA,EAAA,CAAG,WAAc,GAAA,WAAA,CAAA;AAAA,GACnB;AACA,EAAO,OAAA,EAAA,CAAA;AACT,EAAA;AAEa,MAAA,mBAAA,GAAsB,CACjC,EAAA,EACA,QACG,KAAA;AACH,EAAA,IAAI,EAAI,EAAA;AACN,IAAI,IAAA,EAAA,CAAG,YAAa,CAAA,UAAU,CAAG,EAAA;AAC/B,MAAA,MAAM,YAAe,GAAA,QAAA,CAAS,EAAG,CAAA,YAAA,CAAa,UAAU,CAAW,CAAA,CAAA;AACnE,MAAA,IACE,CAAC,KAAM,CAAA,YAAY,MAClB,QAAa,KAAA,KAAA,CAAA,IAAa,iBAAiB,QAC5C,CAAA,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tB,EAAA;AACO,MAAM,qBAAwB,GAAA,CACnC,EACA,EAAA,IAAA,EACA,GACG,KAAA;AACH,EAAM,MAAA,GAAA,GAAM,IAAI,aAAA,CAAc,IAAM,EAAA;AAAA,IAClC,GAAA;AAAA,IACA,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,IACT,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACD,EAAA,EAAA,CAAG,cAAc,GAAG,CAAA,CAAA;AACtB,EAAA;AAIa,MAAA,mBAAA,GAAsB,CAAC,EAAA,EAAiB,IAA0B,KAAA;AAC7E,EAAM,MAAA,GAAA,GAAM,IAAI,KAAA,CAAM,IAAM,EAAA;AAAA,IAC1B,OAAS,EAAA,IAAA;AAAA,IACT,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACD,EAAA,EAAA,CAAG,cAAc,GAAG,CAAA,CAAA;AACtB;;;;;;;;;;;;;;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -67,6 +67,7 @@ exports.AggregationType = columnUtils.AggregationType;
|
|
|
67
67
|
exports.addColumnToSubscribedColumns = columnUtils.addColumnToSubscribedColumns;
|
|
68
68
|
exports.applyDefaultColumnConfig = columnUtils.applyDefaultColumnConfig;
|
|
69
69
|
exports.applyGroupByToColumns = columnUtils.applyGroupByToColumns;
|
|
70
|
+
exports.applyRuntimeColumnWidthsToConfig = columnUtils.applyRuntimeColumnWidthsToConfig;
|
|
70
71
|
exports.applySortToColumns = columnUtils.applySortToColumns;
|
|
71
72
|
exports.applyWidthToColumns = columnUtils.applyWidthToColumns;
|
|
72
73
|
exports.buildColumnMap = columnUtils.buildColumnMap;
|
|
@@ -87,6 +88,7 @@ exports.getDefaultAlignment = columnUtils.getDefaultAlignment;
|
|
|
87
88
|
exports.getDefaultColumnType = columnUtils.getDefaultColumnType;
|
|
88
89
|
exports.getGroupValueAndOffset = columnUtils.getGroupValueAndOffset;
|
|
89
90
|
exports.getRowRecord = columnUtils.getRowRecord;
|
|
91
|
+
exports.getRuntimeColumnWidth = columnUtils.getRuntimeColumnWidth;
|
|
90
92
|
exports.getTableHeadings = columnUtils.getTableHeadings;
|
|
91
93
|
exports.getTypeFormattingFromColumn = columnUtils.getTypeFormattingFromColumn;
|
|
92
94
|
exports.hasHeadings = columnUtils.hasHeadings;
|
|
@@ -282,6 +284,7 @@ exports.debounce = perfUtils.debounce;
|
|
|
282
284
|
exports.throttle = perfUtils.throttle;
|
|
283
285
|
exports.isOpenDialogAction = protocolMessageUtils.isOpenDialogAction;
|
|
284
286
|
exports.isOpenSessionTableDialogMessage = protocolMessageUtils.isOpenSessionTableDialogMessage;
|
|
287
|
+
exports.isRequestResponse = protocolMessageUtils.isRequestResponse;
|
|
285
288
|
exports.isVuuMenuRpcRequest = protocolMessageUtils.isVuuMenuRpcRequest;
|
|
286
289
|
exports.NULL_RANGE = rangeUtils.NULL_RANGE;
|
|
287
290
|
exports.WindowRange = rangeUtils.WindowRange;
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -13,10 +13,12 @@ const MENU_RPC_TYPES = [
|
|
|
13
13
|
"VP_EDIT_SUBMIT_FORM_RPC"
|
|
14
14
|
];
|
|
15
15
|
const isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
|
|
16
|
+
const isRequestResponse = (message) => "requestId" in message;
|
|
16
17
|
const isOpenSessionTableDialogMessage = (rpcResponse) => rpcResponse.type === "VIEW_PORT_MENU_RESP" && isOpenDialogAction(rpcResponse.action) && "tableSchema" in rpcResponse.action;
|
|
17
18
|
const isOpenDialogAction = (action) => action !== void 0 && action.type === "OPEN_DIALOG_ACTION";
|
|
18
19
|
|
|
19
20
|
exports.isOpenDialogAction = isOpenDialogAction;
|
|
20
21
|
exports.isOpenSessionTableDialogMessage = isOpenSessionTableDialogMessage;
|
|
22
|
+
exports.isRequestResponse = isRequestResponse;
|
|
21
23
|
exports.isVuuMenuRpcRequest = isVuuMenuRpcRequest;
|
|
22
24
|
//# sourceMappingURL=protocol-message-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-message-utils.js","sources":["../src/protocol-message-utils.ts"],"sourcesContent":["import {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n VuuUIMessageOut,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n ClientToServerMenuRPC,\n OpenDialogAction,\n VuuRpcRequest,\n} from \"@vuu-ui/vuu-protocol-types\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isVuuMenuRpcRequest = (\n message: VuuUIMessageOut | VuuRpcRequest | ClientToServerMenuRPC\n): message is ClientToServerMenuRPC => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"protocol-message-utils.js","sources":["../src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n VuuUIMessageOut,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n ClientToServerMenuRPC,\n OpenDialogAction,\n VuuRpcRequest,\n} from \"@vuu-ui/vuu-protocol-types\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isVuuMenuRpcRequest = (\n message: VuuUIMessageOut | VuuRpcRequest | ClientToServerMenuRPC\n): message is ClientToServerMenuRPC => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isRequestResponse = (\n message: object\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n"],"names":[],"mappings":";;AAcA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AACF,CAAA,CAAA;AAEO,MAAM,sBAAsB,CACjC,OAAA,KACqC,eAAe,QAAS,CAAA,OAAA,CAAQ,MAAM,CAAC,EAAA;AAEjE,MAAA,iBAAA,GAAoB,CAC/B,OAAA,KAC6C,WAAe,IAAA,QAAA;AAEjD,MAAA,+BAAA,GAAkC,CAC7C,WAAA,KAEA,WAAY,CAAA,IAAA,KAAS,qBACrB,IAAA,kBAAA,CAAmB,WAAY,CAAA,MAAM,CACrC,IAAA,aAAA,IAAiB,WAAY,CAAA,OAAA;AAExB,MAAM,qBAAqB,CAChC,MAAA,KAEA,MAAW,KAAA,KAAA,CAAA,IAAa,OAAO,IAAS,KAAA;;;;;;;"}
|
package/esm/column-utils.js
CHANGED
|
@@ -27,6 +27,24 @@ function mapSortCriteria(sortCriteria, columnMap, metadataOffset = 0) {
|
|
|
27
27
|
}
|
|
28
28
|
const numericTypes = ["int", "long", "double"];
|
|
29
29
|
const getDefaultAlignment = (serverDataType) => serverDataType === void 0 ? "left" : numericTypes.includes(serverDataType) ? "right" : "left";
|
|
30
|
+
const getRuntimeColumnWidth = (col, runtimeColumns) => {
|
|
31
|
+
const runtimeColumn = runtimeColumns.find(({ name }) => name === col.name);
|
|
32
|
+
if (runtimeColumn) {
|
|
33
|
+
return runtimeColumn.width;
|
|
34
|
+
} else {
|
|
35
|
+
return DEFAULT_COL_WIDTH;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const applyRuntimeColumnWidthsToConfig = (tableConfig, columns) => {
|
|
39
|
+
return {
|
|
40
|
+
...tableConfig,
|
|
41
|
+
columns: columns.map((column) => ({
|
|
42
|
+
...column,
|
|
43
|
+
width: column.width ?? getRuntimeColumnWidth(column, columns)
|
|
44
|
+
})),
|
|
45
|
+
columnLayout: "manual"
|
|
46
|
+
};
|
|
47
|
+
};
|
|
30
48
|
const isValidColumnAlignment = (v) => v === "left" || v === "right";
|
|
31
49
|
const isValidPinLocation = (v) => isValidColumnAlignment(v) || v === "floating" || v === "";
|
|
32
50
|
const VUU_COLUMN_DATA_TYPES = [
|
|
@@ -614,131 +632,145 @@ const getColumnByName = (schema, name) => {
|
|
|
614
632
|
}
|
|
615
633
|
}
|
|
616
634
|
};
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
(aggregated, column) => {
|
|
640
|
-
const { totalMinWidth: totalMinWidth2, totalMaxWidth: totalMaxWidth2, totalWidth: totalWidth2, flexCount: flexCount2 } = aggregated;
|
|
641
|
-
const {
|
|
642
|
-
minWidth = defaultMinWidth,
|
|
643
|
-
maxWidth = defaultMaxWidth,
|
|
644
|
-
width = defaultWidth,
|
|
645
|
-
flex = 0
|
|
646
|
-
} = column;
|
|
647
|
-
return {
|
|
648
|
-
totalMinWidth: totalMinWidth2 + minWidth,
|
|
649
|
-
totalMaxWidth: totalMaxWidth2 + maxWidth,
|
|
650
|
-
totalWidth: totalWidth2 + width,
|
|
651
|
-
flexCount: flexCount2 + flex
|
|
652
|
-
};
|
|
653
|
-
},
|
|
654
|
-
{ totalMinWidth: 0, totalMaxWidth: 0, totalWidth: 0, flexCount: 0 }
|
|
655
|
-
);
|
|
656
|
-
if (totalMinWidth > availableWidth || totalMaxWidth < availableWidth) {
|
|
635
|
+
const measureColumns = (columns, defaultMaxWidth, defaultMinWidth) => columns.reduce(
|
|
636
|
+
(aggregated, column) => {
|
|
637
|
+
aggregated.totalMinWidth += column.minWidth ?? defaultMinWidth;
|
|
638
|
+
aggregated.totalMaxWidth += column.maxWidth ?? defaultMaxWidth;
|
|
639
|
+
aggregated.totalWidth += column.width;
|
|
640
|
+
aggregated.flexCount += column.flex ?? 0;
|
|
641
|
+
return aggregated;
|
|
642
|
+
},
|
|
643
|
+
{ totalMinWidth: 0, totalMaxWidth: 0, totalWidth: 0, flexCount: 0 }
|
|
644
|
+
);
|
|
645
|
+
function applyWidthToColumns(columns, {
|
|
646
|
+
availableWidth = 0,
|
|
647
|
+
columnLayout = "static",
|
|
648
|
+
defaultWidth = DEFAULT_COL_WIDTH,
|
|
649
|
+
defaultMinWidth = DEFAULT_MIN_WIDTH,
|
|
650
|
+
defaultMaxWidth = DEFAULT_MAX_WIDTH
|
|
651
|
+
}) {
|
|
652
|
+
if (columnLayout === "fit") {
|
|
653
|
+
const { totalMinWidth, totalMaxWidth, totalWidth, flexCount } = measureColumns(columns, defaultMaxWidth, defaultMinWidth);
|
|
654
|
+
if (totalMaxWidth < availableWidth) {
|
|
655
|
+
return assignMaxWidthToAll(columns, defaultMaxWidth);
|
|
656
|
+
} else if (totalMinWidth > availableWidth) {
|
|
657
657
|
return columns;
|
|
658
658
|
} else if (totalWidth > availableWidth) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
width = defaultWidth,
|
|
668
|
-
flex = 0
|
|
669
|
-
} = column;
|
|
670
|
-
if (inFlexMode && flex === 0) {
|
|
671
|
-
return column;
|
|
672
|
-
}
|
|
673
|
-
const adjustedWidth = width - excessWidthPerColumn;
|
|
674
|
-
if (adjustedWidth < minWidth) {
|
|
675
|
-
columnsNotYetAtMinWidth -= 1;
|
|
676
|
-
unassignedExcess += minWidth - adjustedWidth;
|
|
677
|
-
return { ...column, width: minWidth };
|
|
678
|
-
} else {
|
|
679
|
-
return { ...column, width: adjustedWidth };
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
if (unassignedExcess === 0) {
|
|
683
|
-
return newColumns;
|
|
684
|
-
} else {
|
|
685
|
-
excessWidthPerColumn = unassignedExcess / columnsNotYetAtMinWidth;
|
|
686
|
-
newColumns = newColumns.map((column) => {
|
|
687
|
-
const adjustedWidth = column.width - excessWidthPerColumn;
|
|
688
|
-
if (column.width !== column.minWidth) {
|
|
689
|
-
return { ...column, width: adjustedWidth };
|
|
690
|
-
} else {
|
|
691
|
-
return column;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
return newColumns;
|
|
695
|
-
}
|
|
659
|
+
return shrinkColumnsToFitAvailableSpace(
|
|
660
|
+
columns,
|
|
661
|
+
availableWidth,
|
|
662
|
+
totalWidth,
|
|
663
|
+
defaultMinWidth,
|
|
664
|
+
defaultWidth,
|
|
665
|
+
flexCount
|
|
666
|
+
);
|
|
696
667
|
} else if (totalWidth < availableWidth) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
flex = 0
|
|
706
|
-
} = column;
|
|
707
|
-
if (inFlexMode && flex === 0) {
|
|
708
|
-
return column;
|
|
709
|
-
}
|
|
710
|
-
const adjustedWidth = width + additionalWidthPerColumn;
|
|
711
|
-
if (adjustedWidth > maxWidth) {
|
|
712
|
-
return { ...column, width: maxWidth };
|
|
713
|
-
} else {
|
|
714
|
-
return { ...column, width: adjustedWidth, canStretch: true };
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
const unassignedAdditionalColumnWidth = additionalWidth - newColumns.reduce((sum, col) => sum + col.width, 0);
|
|
718
|
-
const columnsNotYetAtMaxWidth = newColumns.filter(
|
|
719
|
-
(col) => col.canStretch
|
|
720
|
-
).length;
|
|
721
|
-
if (unassignedAdditionalColumnWidth > columnsNotYetAtMaxWidth) {
|
|
722
|
-
additionalWidthPerColumn = unassignedAdditionalColumnWidth / columnsNotYetAtMaxWidth;
|
|
723
|
-
newColumns = newColumns.map((column) => {
|
|
724
|
-
if (column.canStretch) {
|
|
725
|
-
const adjustedWidth = Math.min(
|
|
726
|
-
column.width + additionalWidthPerColumn
|
|
727
|
-
);
|
|
728
|
-
return { ...column, width: adjustedWidth };
|
|
729
|
-
} else {
|
|
730
|
-
return column;
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
return newColumns.map(({ canStretch, ...column }) => column);
|
|
735
|
-
}
|
|
668
|
+
return stretchColumnsToFillAvailableSpace(
|
|
669
|
+
columns,
|
|
670
|
+
availableWidth,
|
|
671
|
+
totalWidth,
|
|
672
|
+
defaultMaxWidth,
|
|
673
|
+
defaultWidth,
|
|
674
|
+
flexCount
|
|
675
|
+
);
|
|
736
676
|
}
|
|
737
677
|
}
|
|
738
678
|
return columns;
|
|
739
679
|
}
|
|
680
|
+
const assignMaxWidthToAll = (columns, defaultMaxWidth) => {
|
|
681
|
+
return columns.map((column) => {
|
|
682
|
+
const { maxWidth = defaultMaxWidth } = column;
|
|
683
|
+
if (column.width === maxWidth) {
|
|
684
|
+
return column;
|
|
685
|
+
} else {
|
|
686
|
+
return {
|
|
687
|
+
...column,
|
|
688
|
+
width: maxWidth
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
};
|
|
693
|
+
const shrinkColumnsToFitAvailableSpace = (columns, availableWidth, totalWidth, defaultMinWidth, defaultWidth, flexCount) => {
|
|
694
|
+
const excessWidth = totalWidth - availableWidth;
|
|
695
|
+
const inFlexMode = flexCount > 0;
|
|
696
|
+
let excessWidthPerColumn = excessWidth / (flexCount || columns.length);
|
|
697
|
+
let columnsNotYetAtMinWidth = columns.length;
|
|
698
|
+
let unassignedExcess = 0;
|
|
699
|
+
let newColumns = columns.map((column) => {
|
|
700
|
+
const {
|
|
701
|
+
minWidth = defaultMinWidth,
|
|
702
|
+
width = defaultWidth,
|
|
703
|
+
flex = 0
|
|
704
|
+
} = column;
|
|
705
|
+
if (inFlexMode && flex === 0) {
|
|
706
|
+
return column;
|
|
707
|
+
}
|
|
708
|
+
const adjustedWidth = width - excessWidthPerColumn;
|
|
709
|
+
if (adjustedWidth < minWidth) {
|
|
710
|
+
columnsNotYetAtMinWidth -= 1;
|
|
711
|
+
unassignedExcess += minWidth - adjustedWidth;
|
|
712
|
+
return { ...column, width: minWidth };
|
|
713
|
+
} else {
|
|
714
|
+
return { ...column, width: adjustedWidth };
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
if (unassignedExcess === 0) {
|
|
718
|
+
return newColumns;
|
|
719
|
+
} else {
|
|
720
|
+
excessWidthPerColumn = unassignedExcess / columnsNotYetAtMinWidth;
|
|
721
|
+
newColumns = newColumns.map((column) => {
|
|
722
|
+
const adjustedWidth = column.width - excessWidthPerColumn;
|
|
723
|
+
if (column.width !== column.minWidth) {
|
|
724
|
+
return { ...column, width: adjustedWidth };
|
|
725
|
+
} else {
|
|
726
|
+
return column;
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
return newColumns;
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const stretchColumnsToFillAvailableSpace = (columns, availableWidth, totalWidth, defaultMaxWidth, defaultWidth, flexCount) => {
|
|
733
|
+
let freeSpaceToBeFilled = availableWidth - totalWidth;
|
|
734
|
+
const additionalWidthPerColumn = Math.floor(
|
|
735
|
+
freeSpaceToBeFilled / (flexCount || columns.length)
|
|
736
|
+
);
|
|
737
|
+
const newColumns = columns.map((column) => {
|
|
738
|
+
const {
|
|
739
|
+
maxWidth = defaultMaxWidth,
|
|
740
|
+
width = defaultWidth,
|
|
741
|
+
flex = 0
|
|
742
|
+
} = column;
|
|
743
|
+
if (flexCount > 0 && flex === 0) {
|
|
744
|
+
return column;
|
|
745
|
+
}
|
|
746
|
+
const adjustedWidth = width + additionalWidthPerColumn;
|
|
747
|
+
if (adjustedWidth > maxWidth) {
|
|
748
|
+
return { ...column, width: maxWidth };
|
|
749
|
+
} else {
|
|
750
|
+
freeSpaceToBeFilled -= additionalWidthPerColumn;
|
|
751
|
+
return { ...column, width: adjustedWidth, canStretch: true };
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
const columnsNotYetAtMaxWidth = newColumns.filter(
|
|
755
|
+
(col) => col.canStretch
|
|
756
|
+
).length;
|
|
757
|
+
const finalAdjustmentPerColumn = Math.min(
|
|
758
|
+
1,
|
|
759
|
+
Math.ceil(freeSpaceToBeFilled / columnsNotYetAtMaxWidth)
|
|
760
|
+
);
|
|
761
|
+
return newColumns.map(
|
|
762
|
+
({ canStretch, ...column }) => {
|
|
763
|
+
if (canStretch && freeSpaceToBeFilled) {
|
|
764
|
+
freeSpaceToBeFilled -= finalAdjustmentPerColumn;
|
|
765
|
+
return { ...column, width: column.width + finalAdjustmentPerColumn };
|
|
766
|
+
} else {
|
|
767
|
+
return column;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
);
|
|
771
|
+
};
|
|
740
772
|
const dataAndColumnUnchanged = (p, p1) => p.column === p1.column && p.column.valueFormatter(p.row[p.columnMap[p.column.name]]) === p1.column.valueFormatter(p1.row[p1.columnMap[p1.column.name]]);
|
|
741
773
|
const dataColumnAndKeyUnchanged = (p, p1) => p.column === p1.column && p.row[KEY] === p1.row[KEY] && p.column.valueFormatter(p.row[p.columnMap[p.column.name]]) === p1.column.valueFormatter(p1.row[p1.columnMap[p1.column.name]]);
|
|
742
774
|
|
|
743
|
-
export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applySortToColumns, applyWidthToColumns, buildColumnMap, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getCalculatedColumnDetails, getColumnByName, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupValueAndOffset, getRowRecord, getTableHeadings, getTypeFormattingFromColumn, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeColumn, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNotHidden, isNumericColumn, isPinned, isResizing, isTextColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex };
|
|
775
|
+
export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applyRuntimeColumnWidthsToConfig, applySortToColumns, applyWidthToColumns, buildColumnMap, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getCalculatedColumnDetails, getColumnByName, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupValueAndOffset, getRowRecord, getRuntimeColumnWidth, getTableHeadings, getTypeFormattingFromColumn, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeColumn, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNotHidden, isNumericColumn, isPinned, isResizing, isTextColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex };
|
|
744
776
|
//# sourceMappingURL=column-utils.js.map
|