@vuu-ui/vuu-utils 0.9.3 → 0.10.1
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/box-utils.js +43 -0
- package/cjs/box-utils.js.map +1 -1
- package/cjs/column-utils.js +17 -0
- package/cjs/column-utils.js.map +1 -1
- package/cjs/data-utils.js +14 -0
- package/cjs/data-utils.js.map +1 -1
- package/cjs/event-emitter.js +1 -0
- package/cjs/event-emitter.js.map +1 -1
- package/cjs/feature-utils.js +43 -55
- package/cjs/feature-utils.js.map +1 -1
- package/cjs/form-utils.js +2 -0
- package/cjs/form-utils.js.map +1 -1
- package/cjs/formatting-utils.js +2 -0
- package/cjs/formatting-utils.js.map +1 -1
- package/cjs/index.js +13 -2
- package/cjs/index.js.map +1 -1
- package/cjs/module-utils.js +0 -6
- package/cjs/module-utils.js.map +1 -1
- package/cjs/react-utils.js +15 -0
- package/cjs/react-utils.js.map +1 -1
- package/cjs/tree-utils.js +2 -1
- package/cjs/tree-utils.js.map +1 -1
- package/cjs/ts-utils.js +2 -0
- package/cjs/ts-utils.js.map +1 -1
- package/esm/box-utils.js +40 -1
- package/esm/box-utils.js.map +1 -1
- package/esm/column-utils.js +17 -1
- package/esm/column-utils.js.map +1 -1
- package/esm/data-utils.js +14 -1
- package/esm/data-utils.js.map +1 -1
- package/esm/event-emitter.js +1 -0
- package/esm/event-emitter.js.map +1 -1
- package/esm/feature-utils.js +42 -55
- package/esm/feature-utils.js.map +1 -1
- package/esm/form-utils.js +2 -1
- package/esm/form-utils.js.map +1 -1
- package/esm/formatting-utils.js +2 -1
- package/esm/formatting-utils.js.map +1 -1
- package/esm/index.js +9 -9
- package/esm/module-utils.js +1 -6
- package/esm/module-utils.js.map +1 -1
- package/esm/react-utils.js +15 -2
- package/esm/react-utils.js.map +1 -1
- package/esm/tree-utils.js +2 -1
- package/esm/tree-utils.js.map +1 -1
- package/esm/ts-utils.js +2 -1
- package/esm/ts-utils.js.map +1 -1
- package/package.json +8 -8
- package/types/box-utils.d.ts +15 -0
- package/types/column-utils.d.ts +6 -2
- package/types/data-utils.d.ts +1 -0
- package/types/feature-utils.d.ts +18 -5
- package/types/form-utils.d.ts +2 -1
- package/types/formatting-utils.d.ts +7 -0
- package/types/module-utils.d.ts +0 -1
- package/types/react-utils.d.ts +3 -1
- package/types/ts-utils.d.ts +17 -0
package/cjs/feature-utils.js
CHANGED
|
@@ -18,9 +18,12 @@ function featureFromJson({ type }) {
|
|
|
18
18
|
return React.createElement(componentType);
|
|
19
19
|
}
|
|
20
20
|
const isCustomFeature = (feature) => feature.leftNavLocation === "vuu-features";
|
|
21
|
-
const isWildcardSchema = (
|
|
22
|
-
const
|
|
21
|
+
const isWildcardSchema = (vuuTables) => vuuTables === "*";
|
|
22
|
+
const isVuuTables = (vuuTables) => Array.isArray(vuuTables);
|
|
23
23
|
const hasFilterTableFeatureProps = (props) => typeof props.ComponentProps === "object" && props.ComponentProps !== null && "tableSchema" in props.ComponentProps;
|
|
24
|
+
const isSameTable = (t1, t2) => {
|
|
25
|
+
t1.module === t2.module && t1.table == t2.table;
|
|
26
|
+
};
|
|
24
27
|
const byModule = (schema1, schema2) => {
|
|
25
28
|
const m1 = schema1.table.module.toLowerCase();
|
|
26
29
|
const m2 = schema2.table.module.toLowerCase();
|
|
@@ -58,7 +61,7 @@ const assertComponentsRegistered = (componentList) => {
|
|
|
58
61
|
assertComponentRegistered(componentName, component);
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
|
-
const getCustomAndTableFeatures = (dynamicFeatures,
|
|
64
|
+
const getCustomAndTableFeatures = (dynamicFeatures, tableSchemas) => {
|
|
62
65
|
const [customFeatureConfig, tableFeaturesConfig] = arrayUtils.partition(
|
|
63
66
|
dynamicFeatures,
|
|
64
67
|
isCustomFeature
|
|
@@ -70,33 +73,24 @@ const getCustomAndTableFeatures = (dynamicFeatures, vuuTables) => {
|
|
|
70
73
|
viewProps,
|
|
71
74
|
...feature
|
|
72
75
|
} of tableFeaturesConfig) {
|
|
73
|
-
const {
|
|
74
|
-
if (isWildcardSchema(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
tableSchema.table.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const tableSchema = vuuTables.get(schema.table);
|
|
92
|
-
if (tableSchema) {
|
|
93
|
-
tableFeatures.push({
|
|
94
|
-
...feature,
|
|
95
|
-
ComponentProps: {
|
|
96
|
-
tableSchema
|
|
97
|
-
},
|
|
98
|
-
ViewProps: viewProps
|
|
99
|
-
});
|
|
76
|
+
const { vuuTables } = featureProps;
|
|
77
|
+
if (isWildcardSchema(vuuTables)) {
|
|
78
|
+
if (tableSchemas) {
|
|
79
|
+
for (const tableSchema of tableSchemas) {
|
|
80
|
+
tableFeatures.push({
|
|
81
|
+
...feature,
|
|
82
|
+
ComponentProps: {
|
|
83
|
+
tableSchema
|
|
84
|
+
},
|
|
85
|
+
title: `${tableSchema.table.module} ${textUtils.wordify(
|
|
86
|
+
tableSchema.table.table
|
|
87
|
+
)}`,
|
|
88
|
+
ViewProps: {
|
|
89
|
+
...viewProps,
|
|
90
|
+
allowRename: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
100
94
|
}
|
|
101
95
|
}
|
|
102
96
|
}
|
|
@@ -105,30 +99,23 @@ const getCustomAndTableFeatures = (dynamicFeatures, vuuTables) => {
|
|
|
105
99
|
viewProps,
|
|
106
100
|
...feature
|
|
107
101
|
} of customFeatureConfig) {
|
|
108
|
-
const {
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
return map;
|
|
127
|
-
},
|
|
128
|
-
{}
|
|
129
|
-
),
|
|
130
|
-
ViewProps: viewProps
|
|
131
|
-
});
|
|
102
|
+
const { vuuTables } = featureProps;
|
|
103
|
+
if (isVuuTables(vuuTables)) {
|
|
104
|
+
if (tableSchemas) {
|
|
105
|
+
customFeatures.push({
|
|
106
|
+
...feature,
|
|
107
|
+
ComponentProps: vuuTables.reduce(
|
|
108
|
+
(map, vuuTable) => {
|
|
109
|
+
map[`${vuuTable.table}Schema`] = tableSchemas.find(
|
|
110
|
+
(tableSchema) => isSameTable(vuuTable, tableSchema.table)
|
|
111
|
+
);
|
|
112
|
+
return map;
|
|
113
|
+
},
|
|
114
|
+
{}
|
|
115
|
+
),
|
|
116
|
+
ViewProps: viewProps
|
|
117
|
+
});
|
|
118
|
+
}
|
|
132
119
|
} else {
|
|
133
120
|
customFeatures.push(feature);
|
|
134
121
|
}
|
|
@@ -145,7 +132,8 @@ exports.getCustomAndTableFeatures = getCustomAndTableFeatures;
|
|
|
145
132
|
exports.getFilterTableFeatures = getFilterTableFeatures;
|
|
146
133
|
exports.hasFilterTableFeatureProps = hasFilterTableFeatureProps;
|
|
147
134
|
exports.isCustomFeature = isCustomFeature;
|
|
135
|
+
exports.isSameTable = isSameTable;
|
|
148
136
|
exports.isStaticFeatures = isStaticFeatures;
|
|
149
|
-
exports.
|
|
137
|
+
exports.isVuuTables = isVuuTables;
|
|
150
138
|
exports.isWildcardSchema = isWildcardSchema;
|
|
151
139
|
//# sourceMappingURL=feature-utils.js.map
|
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 { ListOption } from \"@vuu-ui/vuu-table-types\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\nimport React, { ReactElement } from \"react\";\nimport { getLayoutComponent } from \"./component-registry\";\n\nexport type PathMap = {\n [key: string]: Pick<DynamicFeatureDescriptor, \"css\" | \"url\">;\n};\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport type LookupTableProvider = (table: VuuTable) => ListOption[];\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\nexport interface DynamicFeatureProps<P extends object | undefined = object> {\n /**\n props that will be passed to the lazily loaded component.\n */\n ComponentProps?: P;\n ViewProps?: ViewConfig;\n css?: string;\n height?: number;\n title?: string;\n /** \n The url of javascript bundle to lazily load. Bundle must provide a default export\n and that export must be a React component.\n */\n url: string;\n width?: number;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface DynamicFeatureDescriptor {\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 StaticFeatureDescriptor {\n group?: string;\n label: string;\n type: string;\n}\n\nconst isStaticFeature = (\n feature: unknown,\n): feature is StaticFeatureDescriptor =>\n feature !== null && typeof feature === \"object\" && \"type\" in feature;\n\nexport const isStaticFeatures = (\n features: unknown,\n): features is StaticFeatureDescriptor[] =>\n Array.isArray(features) && features.every(isStaticFeature);\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type DynamicFeatures = {\n [key: string]: DynamicFeatureDescriptor;\n};\n\nexport function featureFromJson({ type }: { type: string }): ReactElement {\n const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);\n if (componentType === undefined) {\n throw Error(\n `layoutUtils unable to create feature component from JSON, unknown type ${type}`,\n );\n }\n return React.createElement(componentType);\n}\n\nexport interface VuuConfig {\n features: DynamicFeatures;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: DynamicFeatureDescriptor) =>\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<DynamicFeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: DynamicFeatureProps,\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\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}) => DynamicFeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths,\n) =>\n schemas\n .sort(byModule)\n .map<DynamicFeatureProps<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 type Component = {\n componentName: string;\n component: unknown;\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 assertComponentsRegistered = (componentList: Component[]) => {\n for (const { componentName, component } of componentList) {\n assertComponentRegistered(componentName, component);\n }\n};\n\nexport const getCustomAndTableFeatures = (\n dynamicFeatures: DynamicFeatureDescriptor[],\n vuuTables: Map<string, TableSchema>,\n): {\n dynamicFeatures: DynamicFeatureProps[];\n tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[];\n} => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n dynamicFeatures,\n isCustomFeature,\n );\n\n const customFeatures: DynamicFeatureProps[] = [];\n const tableFeatures: DynamicFeatureProps<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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,CAAA;AAAA;AACH;AACF;AAGF,EAAW,KAAA,MAAA;AAAA,IACT,eAAe,EAAC;AAAA,IAChB,SAAA;AAAA,IACA,GAAG;AAAA,OACA,mBAAqB,EAAA;AACxB,IAAM,MAAA,EAAE,MAAQ,EAAA,OAAA,EAAY,GAAA,YAAA;AAC5B,IAAI,IAAA,aAAA,CAAc,MAAM,CAAA,IAAK,SAAW,EAAA;AACtC,MAAA,MAAM,WAAc,GAAA,SAAA,CAAU,GAAI,CAAA,MAAA,CAAO,KAAK,CAAA;AAC9C,MAAA,cAAA,CAAe,IAAK,CAAA;AAAA,QAClB,GAAG,OAAA;AAAA,QACH,cAAgB,EAAA;AAAA,UACd;AAAA,SACF;AAAA,QACA,SAAW,EAAA;AAAA,OACZ,CAAA;AAAA,KACQ,MAAA,IAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,KAAK,SAAW,EAAA;AAC9C,MAAA,cAAA,CAAe,IAAK,CAAA;AAAA,QAClB,GAAG,OAAA;AAAA,QACH,gBAAgB,OAAQ,CAAA,MAAA;AAAA,UACtB,CAAC,KAAKC,OAAW,KAAA;AACf,YAAA,GAAA,CAAI,CAAGA,EAAAA,OAAAA,CAAO,KAAK,CAAA,MAAA,CAAQ,IAAI,SAAU,CAAA,GAAA;AAAA,cACvCA,OAAO,CAAA;AAAA,aACT;AACA,YAAO,OAAA,GAAA;AAAA,WACT;AAAA,UACA;AAAC,SACH;AAAA,QACA,SAAW,EAAA;AAAA,OACZ,CAAA;AAAA,KACI,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA;AAAA;AAC7B;AAEF,EAAO,OAAA,EAAE,eAAiB,EAAA,cAAA,EAAgB,aAA6B,EAAA;AACzE;;;;;;;;;;;;;;;"}
|
|
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 { ListOption } from \"@vuu-ui/vuu-table-types\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\nimport React, { ReactElement } from \"react\";\nimport { getLayoutComponent } from \"./component-registry\";\n\nexport type PathMap = {\n [key: string]: Pick<DynamicFeatureDescriptor, \"css\" | \"url\">;\n};\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport type LookupTableProvider = (table: VuuTable) => ListOption[];\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\nexport interface DynamicFeatureProps<P extends object | undefined = object> {\n /**\n props that will be passed to the lazily loaded component.\n */\n ComponentProps?: P;\n ViewProps?: ViewConfig;\n css?: string;\n height?: number;\n title?: string;\n /** \n The url of javascript bundle to lazily load. Bundle must provide a default export\n and that export must be a React component.\n */\n url: string;\n width?: number;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface DynamicFeatureDescriptor {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n vuuTables?: \"*\" | VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface StaticFeatureDescriptor {\n group?: string;\n label: string;\n type: string;\n}\n\nconst isStaticFeature = (\n feature: unknown,\n): feature is StaticFeatureDescriptor =>\n feature !== null && typeof feature === \"object\" && \"type\" in feature;\n\nexport const isStaticFeatures = (\n features: unknown,\n): features is StaticFeatureDescriptor[] =>\n Array.isArray(features) && features.every(isStaticFeature);\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type DynamicFeatures = {\n [key: string]: DynamicFeatureDescriptor;\n};\n\nexport function featureFromJson({ type }: { type: string }): ReactElement {\n const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);\n if (componentType === undefined) {\n throw Error(\n `layoutUtils unable to create feature component from JSON, unknown type ${type}`,\n );\n }\n return React.createElement(componentType);\n}\n\nexport interface VuuConfig {\n features: DynamicFeatures;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\n/**\n * We currently categorize 'features' simply by the leftNavLocation\n * @param feature\n * @returns\n */\nexport const isCustomFeature = (feature: DynamicFeatureDescriptor) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (\n vuuTables?: \"*\" | VuuTable[],\n): vuuTables is \"*\" => vuuTables === \"*\";\nexport const isVuuTables = (\n vuuTables?: \"*\" | VuuTable[],\n): vuuTables is VuuTable[] => Array.isArray(vuuTables);\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<DynamicFeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: DynamicFeatureProps,\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\nexport const isSameTable = (t1: VuuTable, t2: VuuTable) => {\n t1.module === t2.module && t1.table == t2.table;\n};\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}) => DynamicFeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths,\n) =>\n schemas\n .sort(byModule)\n .map<DynamicFeatureProps<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 type Component = {\n componentName: string;\n component: unknown;\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 assertComponentsRegistered = (componentList: Component[]) => {\n for (const { componentName, component } of componentList) {\n assertComponentRegistered(componentName, component);\n }\n};\n/**\n * Process the DynamicFeature descriptors. Identify\n * the vuu tables required and inject the appropriate TableSchemas\n *\n * @param dynamicFeatures\n * @param tableSchemas\n * @returns\n */\nexport const getCustomAndTableFeatures = (\n dynamicFeatures: DynamicFeatureDescriptor[],\n tableSchemas: TableSchema[],\n): {\n dynamicFeatures: DynamicFeatureProps[];\n tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[];\n} => {\n // Split features into simple tables and 'custom' features\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n dynamicFeatures,\n isCustomFeature,\n );\n\n const customFeatures: DynamicFeatureProps[] = [];\n const tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { vuuTables } = featureProps;\n // Currently FilterTable is the only 'tableFeature' and it uses the wildcard\n if (isWildcardSchema(vuuTables)) {\n if (tableSchemas) {\n for (const tableSchema of tableSchemas) {\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 }\n } /*else if (isVuuTables(vuuTables) && tableSchemas) {\n const tableSchema = tableSchemas.find((tableSchema) =>\n isSameTable(vuuTable, tableSchema.table),\n );\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 { vuuTables } = featureProps;\n if (isVuuTables(vuuTables)) {\n if (tableSchemas) {\n customFeatures.push({\n ...feature,\n ComponentProps: vuuTables.reduce<Record<string, TableSchema>>(\n (map, vuuTable) => {\n map[`${vuuTable.table}Schema`] = tableSchemas.find(\n (tableSchema) => isSameTable(vuuTable, tableSchema.table),\n ) as TableSchema;\n return map;\n },\n {},\n ),\n ViewProps: viewProps,\n });\n }\n } else {\n customFeatures.push(feature);\n }\n }\n return { dynamicFeatures: customFeatures, tableFeatures: tableFeatures };\n};\n"],"names":["getLayoutComponent","partition","wordify"],"mappings":";;;;;;;AAYa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA;AAiD/B,MAAM,eAAA,GAAkB,CACtB,OAEA,KAAA,OAAA,KAAY,QAAQ,OAAO,OAAA,KAAY,YAAY,MAAU,IAAA,OAAA;AAElD,MAAA,gBAAA,GAAmB,CAC9B,QAEA,KAAA,KAAA,CAAM,QAAQ,QAAQ,CAAA,IAAK,QAAS,CAAA,KAAA,CAAM,eAAe;AAU3C,SAAA,eAAA,CAAgB,EAAE,IAAA,EAAwC,EAAA;AACxE,EAAA,MAAM,gBAAgB,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,IAAA,GAAOA,qCAAmB,IAAI,CAAA;AAC3E,EAAA,IAAI,kBAAkB,KAAW,CAAA,EAAA;AAC/B,IAAM,MAAA,KAAA;AAAA,MACJ,0EAA0E,IAAI,CAAA;AAAA,KAChF;AAAA;AAEF,EAAO,OAAA,KAAA,CAAM,cAAc,aAAa,CAAA;AAC1C;AAcO,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA;AAEjB,MAAA,gBAAA,GAAmB,CAC9B,SAAA,KACqB,SAAc,KAAA;AAC9B,MAAM,WAAc,GAAA,CACzB,SAC4B,KAAA,KAAA,CAAM,QAAQ,SAAS;AAOxC,MAAA,0BAAA,GAA6B,CACxC,KAAA,KAEA,OAAO,KAAA,CAAM,cAAmB,KAA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Aa,EAAA;AAAA;AACf,WACD,CAAA;AAAA;AACH;AACF;AACF;AAgBF,EAAW,KAAA,MAAA;AAAA,IACT,eAAe,EAAC;AAAA,IAChB,SAAA;AAAA,IACA,GAAG;AAAA,OACA,mBAAqB,EAAA;AACxB,IAAM,MAAA,EAAE,WAAc,GAAA,YAAA;AACtB,IAAI,IAAA,WAAA,CAAY,SAAS,CAAG,EAAA;AAC1B,MAAA,IAAI,YAAc,EAAA;AAChB,QAAA,cAAA,CAAe,IAAK,CAAA;AAAA,UAClB,GAAG,OAAA;AAAA,UACH,gBAAgB,SAAU,CAAA,MAAA;AAAA,YACxB,CAAC,KAAK,QAAa,KAAA;AACjB,cAAA,GAAA,CAAI,CAAG,EAAA,QAAA,CAAS,KAAK,CAAA,MAAA,CAAQ,IAAI,YAAa,CAAA,IAAA;AAAA,gBAC5C,CAAC,WAAA,KAAgB,WAAY,CAAA,QAAA,EAAU,YAAY,KAAK;AAAA,eAC1D;AACA,cAAO,OAAA,GAAA;AAAA,aACT;AAAA,YACA;AAAC,WACH;AAAA,UACA,SAAW,EAAA;AAAA,SACZ,CAAA;AAAA;AACH,KACK,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA;AAAA;AAC7B;AAEF,EAAO,OAAA,EAAE,eAAiB,EAAA,cAAA,EAAgB,aAA6B,EAAA;AACzE;;;;;;;;;;;;;;;;"}
|
package/cjs/form-utils.js
CHANGED
|
@@ -12,6 +12,7 @@ const getFieldName = (target) => {
|
|
|
12
12
|
throw Error("named form field not found");
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
const isNumber = (type, value) => type === "number";
|
|
15
16
|
function getTypedValue(value, type, throwIfInvalid = false) {
|
|
16
17
|
switch (type) {
|
|
17
18
|
case "int":
|
|
@@ -43,4 +44,5 @@ function getTypedValue(value, type, throwIfInvalid = false) {
|
|
|
43
44
|
|
|
44
45
|
exports.getFieldName = getFieldName;
|
|
45
46
|
exports.getTypedValue = getTypedValue;
|
|
47
|
+
exports.isNumber = isNumber;
|
|
46
48
|
//# sourceMappingURL=form-utils.js.map
|
package/cjs/form-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-utils.js","sources":["../src/form-utils.ts"],"sourcesContent":["import {\n VuuColumnDataType,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { KeyboardEvent, SyntheticEvent } from \"react\";\nimport { queryClosest } from \"./html-utils\";\nimport { stringIsValidDecimal, stringIsValidInt } from \"./data-utils\";\n\n/**\n * Use with the following convention:\n *\n * <FormField data-field=\"my-field-name\">\n */\nexport const getFieldName = (target: EventTarget | HTMLElement): string => {\n const saltFormField = queryClosest(target, \"[data-field]\") as HTMLElement;\n const fieldName = saltFormField?.dataset.field;\n if (fieldName) {\n return fieldName;\n } else {\n throw Error(\"named form field not found\");\n }\n};\n\nexport type InputSource = \"typeahead-suggestion\" | \"text-input\";\n\nexport type CommitHandler<\n E extends HTMLElement = HTMLInputElement,\n T extends VuuRowDataItemType
|
|
1
|
+
{"version":3,"file":"form-utils.js","sources":["../src/form-utils.ts"],"sourcesContent":["import {\n VuuColumnDataType,\n VuuRowDataItemType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { KeyboardEvent, SyntheticEvent } from \"react\";\nimport { queryClosest } from \"./html-utils\";\nimport { stringIsValidDecimal, stringIsValidInt } from \"./data-utils\";\n\n/**\n * Use with the following convention:\n *\n * <FormField data-field=\"my-field-name\">\n */\nexport const getFieldName = (target: EventTarget | HTMLElement): string => {\n const saltFormField = queryClosest(target, \"[data-field]\") as HTMLElement;\n const fieldName = saltFormField?.dataset.field;\n if (fieldName) {\n return fieldName;\n } else {\n throw Error(\"named form field not found\");\n }\n};\n\nexport type InputSource = \"typeahead-suggestion\" | \"text-input\";\n\nexport const isNumber = (\n type: string,\n value: VuuRowDataItemType,\n): value is number => type === \"number\";\n\nexport type CommitHandler<\n E extends HTMLElement = HTMLInputElement,\n T extends VuuRowDataItemType = VuuRowDataItemType,\n> = (\n evt: SyntheticEvent<E> | KeyboardEvent<E>,\n value: T,\n source?: InputSource,\n) => void;\n\n/**\n * Convert a string value to the type appropriate for the associated\n * column or form field. Can be used when processing a string value\n * from an input used for user editing.\n *\n * @param value\n * @param type\n * @param throwIfInvalid\n */\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | \"number\",\n throwIfInvalid?: false,\n): VuuRowDataItemType | undefined;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | \"number\",\n throwIfInvalid: true,\n): VuuRowDataItemType;\nexport function getTypedValue(\n value: string,\n type: VuuColumnDataType | \"number\",\n throwIfInvalid = false,\n): VuuRowDataItemType | undefined {\n switch (type) {\n case \"int\":\n case \"long\": {\n if (stringIsValidInt(value)) {\n return parseInt(value, 10);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"double\":\n case \"number\": {\n if (stringIsValidDecimal(value)) {\n return parseFloat(value);\n } else if (throwIfInvalid) {\n throw Error(`value ${value} is not a valid ${type}`);\n } else {\n return undefined;\n }\n }\n\n case \"boolean\":\n return value === \"true\" ? true : false;\n default:\n return value;\n }\n}\n"],"names":["queryClosest","stringIsValidInt","stringIsValidDecimal"],"mappings":";;;;;AAaa,MAAA,YAAA,GAAe,CAAC,MAA8C,KAAA;AACzE,EAAM,MAAA,aAAA,GAAgBA,sBAAa,CAAA,MAAA,EAAQ,cAAc,CAAA;AACzD,EAAM,MAAA,SAAA,GAAY,eAAe,OAAQ,CAAA,KAAA;AACzC,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,OAAA,SAAA;AAAA,GACF,MAAA;AACL,IAAA,MAAM,MAAM,4BAA4B,CAAA;AAAA;AAE5C;AAIO,MAAM,QAAW,GAAA,CACtB,IACA,EAAA,KAAA,KACoB,IAAS,KAAA;AA8BxB,SAAS,aACd,CAAA,KAAA,EACA,IACA,EAAA,cAAA,GAAiB,KACe,EAAA;AAChC,EAAA,QAAQ,IAAM;AAAA,IACZ,KAAK,KAAA;AAAA,IACL,KAAK,MAAQ,EAAA;AACX,MAAI,IAAAC,0BAAA,CAAiB,KAAK,CAAG,EAAA;AAC3B,QAAO,OAAA,QAAA,CAAS,OAAO,EAAE,CAAA;AAAA,iBAChB,cAAgB,EAAA;AACzB,QAAA,MAAM,KAAM,CAAA,CAAA,MAAA,EAAS,KAAK,CAAA,gBAAA,EAAmB,IAAI,CAAE,CAAA,CAAA;AAAA,OAC9C,MAAA;AACL,QAAO,OAAA,KAAA,CAAA;AAAA;AACT;AACF,IAEA,KAAK,QAAA;AAAA,IACL,KAAK,QAAU,EAAA;AACb,MAAI,IAAAC,8BAAA,CAAqB,KAAK,CAAG,EAAA;AAC/B,QAAA,OAAO,WAAW,KAAK,CAAA;AAAA,iBACd,cAAgB,EAAA;AACzB,QAAA,MAAM,KAAM,CAAA,CAAA,MAAA,EAAS,KAAK,CAAA,gBAAA,EAAmB,IAAI,CAAE,CAAA,CAAA;AAAA,OAC9C,MAAA;AACL,QAAO,OAAA,KAAA,CAAA;AAAA;AACT;AACF,IAEA,KAAK,SAAA;AACH,MAAO,OAAA,KAAA,KAAU,SAAS,IAAO,GAAA,KAAA;AAAA,IACnC;AACE,MAAO,OAAA,KAAA;AAAA;AAEb;;;;;;"}
|
package/cjs/formatting-utils.js
CHANGED
|
@@ -59,8 +59,10 @@ const getValueFormatter = (column, serverDataType = column.serverDataType) => {
|
|
|
59
59
|
}
|
|
60
60
|
return defaultValueFormatter;
|
|
61
61
|
};
|
|
62
|
+
const lowerCase = (str) => str.toLowerCase();
|
|
62
63
|
|
|
63
64
|
exports.defaultValueFormatter = defaultValueFormatter;
|
|
64
65
|
exports.getValueFormatter = getValueFormatter;
|
|
66
|
+
exports.lowerCase = lowerCase;
|
|
65
67
|
exports.numericFormatter = numericFormatter;
|
|
66
68
|
//# sourceMappingURL=formatting-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting-utils.js","sources":["../src/formatting-utils.ts"],"sourcesContent":["import { DateTimeDataValueDescriptor } from \"@vuu-ui/vuu-data-types\";\nimport {\n ColumnDescriptor,\n ColumnTypeFormatting,\n ColumnTypeValueMap,\n ValueFormatter,\n} from \"@vuu-ui/vuu-table-types\";\nimport {\n isDateTimeDataValue,\n isMappedValueTypeRenderer,\n isTypeDescriptor,\n} from \"./column-utils\";\nimport { dateTimePattern, formatDate } from \"./date\";\nimport { roundDecimal } from \"./round-decimal\";\n\nexport type ValueFormatters = {\n [key: string]: ValueFormatter;\n};\n\nconst DEFAULT_NUMERIC_FORMAT: ColumnTypeFormatting = {};\n\nexport const defaultValueFormatter = (value: unknown) =>\n value == null ? \"\" : typeof value === \"string\" ? value : value.toString();\n\nconst dateFormatter = (column: DateTimeDataValueDescriptor) => {\n const pattern = dateTimePattern(column.type);\n const formatter = formatDate(pattern);\n\n return (value: unknown) => {\n if (typeof value === \"number\" && value !== 0) {\n return formatter(new Date(value));\n } else {\n return \"\";\n }\n };\n};\n\nexport const numericFormatter = ({\n align = \"right\",\n type,\n}: Partial<ColumnDescriptor>) => {\n if (type === undefined || typeof type === \"string\") {\n return defaultValueFormatter;\n } else {\n const {\n alignOnDecimals = false,\n decimals,\n zeroPad = false,\n } = type.formatting ?? DEFAULT_NUMERIC_FORMAT;\n return (value: unknown) => {\n if (\n typeof value === \"string\" &&\n (value.startsWith(\"Σ\") || value.startsWith(\"[\"))\n ) {\n return value;\n }\n const number =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\"\n ? parseFloat(value)\n : undefined;\n return roundDecimal(number, align, decimals, zeroPad, alignOnDecimals);\n };\n }\n};\n\nconst mapFormatter = (map: ColumnTypeValueMap) => {\n return (value: unknown) => {\n return map[value as string] ?? \"\";\n };\n};\n\nexport const getValueFormatter = (\n column: ColumnDescriptor,\n serverDataType = column.serverDataType,\n): ValueFormatter => {\n if (isDateTimeDataValue(column)) {\n return dateFormatter(column);\n }\n\n const { type } = column;\n if (isTypeDescriptor(type) && isMappedValueTypeRenderer(type?.renderer)) {\n return mapFormatter(type.renderer.map);\n } else if (serverDataType === \"string\" || serverDataType === \"char\") {\n return (value: unknown) => value as string;\n } else if (serverDataType === \"double\") {\n return numericFormatter(column);\n }\n return defaultValueFormatter;\n};\n"],"names":["dateTimePattern","formatter","formatDate","roundDecimal","isDateTimeDataValue","isTypeDescriptor","isMappedValueTypeRenderer"],"mappings":";;;;;;;;AAmBA,MAAM,yBAA+C,EAAC;AAEzC,MAAA,qBAAA,GAAwB,CAAC,KAAA,KACpC,KAAS,IAAA,IAAA,GAAO,EAAK,GAAA,OAAO,KAAU,KAAA,QAAA,GAAW,KAAQ,GAAA,KAAA,CAAM,QAAS;AAE1E,MAAM,aAAA,GAAgB,CAAC,MAAwC,KAAA;AAC7D,EAAM,MAAA,OAAA,GAAUA,+BAAgB,CAAA,MAAA,CAAO,IAAI,CAAA;AAC3C,EAAM,MAAAC,WAAA,GAAYC,qBAAW,OAAO,CAAA;AAEpC,EAAA,OAAO,CAAC,KAAmB,KAAA;AACzB,IAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,KAAA,KAAU,CAAG,EAAA;AAC5C,MAAA,OAAOD,WAAU,CAAA,IAAI,IAAK,CAAA,KAAK,CAAC,CAAA;AAAA,KAC3B,MAAA;AACL,MAAO,OAAA,EAAA;AAAA;AACT,GACF;AACF,CAAA;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,KAAQ,GAAA,OAAA;AAAA,EACR;AACF,CAAiC,KAAA;AAC/B,EAAA,IAAI,IAAS,KAAA,KAAA,CAAA,IAAa,OAAO,IAAA,KAAS,QAAU,EAAA;AAClD,IAAO,OAAA,qBAAA;AAAA,GACF,MAAA;AACL,IAAM,MAAA;AAAA,MACJ,eAAkB,GAAA,KAAA;AAAA,MAClB,QAAA;AAAA,MACA,OAAU,GAAA;AAAA,KACZ,GAAI,KAAK,UAAc,IAAA,sBAAA;AACvB,IAAA,OAAO,CAAC,KA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.js","sources":["../src/formatting-utils.ts"],"sourcesContent":["import { DateTimeDataValueDescriptor } from \"@vuu-ui/vuu-data-types\";\nimport {\n ColumnDescriptor,\n ColumnTypeFormatting,\n ColumnTypeValueMap,\n ValueFormatter,\n} from \"@vuu-ui/vuu-table-types\";\nimport {\n isDateTimeDataValue,\n isMappedValueTypeRenderer,\n isTypeDescriptor,\n} from \"./column-utils\";\nimport { dateTimePattern, formatDate } from \"./date\";\nimport { roundDecimal } from \"./round-decimal\";\n\nexport type ValueFormatters = {\n [key: string]: ValueFormatter;\n};\n\nconst DEFAULT_NUMERIC_FORMAT: ColumnTypeFormatting = {};\n\nexport const defaultValueFormatter = (value: unknown) =>\n value == null ? \"\" : typeof value === \"string\" ? value : value.toString();\n\nconst dateFormatter = (column: DateTimeDataValueDescriptor) => {\n const pattern = dateTimePattern(column.type);\n const formatter = formatDate(pattern);\n\n return (value: unknown) => {\n if (typeof value === \"number\" && value !== 0) {\n return formatter(new Date(value));\n } else {\n return \"\";\n }\n };\n};\n\nexport const numericFormatter = ({\n align = \"right\",\n type,\n}: Partial<ColumnDescriptor>) => {\n if (type === undefined || typeof type === \"string\") {\n return defaultValueFormatter;\n } else {\n const {\n alignOnDecimals = false,\n decimals,\n zeroPad = false,\n } = type.formatting ?? DEFAULT_NUMERIC_FORMAT;\n return (value: unknown) => {\n if (\n typeof value === \"string\" &&\n (value.startsWith(\"Σ\") || value.startsWith(\"[\"))\n ) {\n return value;\n }\n const number =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\"\n ? parseFloat(value)\n : undefined;\n return roundDecimal(number, align, decimals, zeroPad, alignOnDecimals);\n };\n }\n};\n\nconst mapFormatter = (map: ColumnTypeValueMap) => {\n return (value: unknown) => {\n return map[value as string] ?? \"\";\n };\n};\n\nexport const getValueFormatter = (\n column: ColumnDescriptor,\n serverDataType = column.serverDataType,\n): ValueFormatter => {\n if (isDateTimeDataValue(column)) {\n return dateFormatter(column);\n }\n\n const { type } = column;\n if (isTypeDescriptor(type) && isMappedValueTypeRenderer(type?.renderer)) {\n return mapFormatter(type.renderer.map);\n } else if (serverDataType === \"string\" || serverDataType === \"char\") {\n return (value: unknown) => value as string;\n } else if (serverDataType === \"double\") {\n return numericFormatter(column);\n }\n return defaultValueFormatter;\n};\n\n/**\n * Lowercases a string and returns as Lowercase typescript type\n *\n * @param str the input string\n * @returns str converted to Lowercase\n */\nexport const lowerCase = (str: string) =>\n str.toLowerCase() as Lowercase<string>;\n"],"names":["dateTimePattern","formatter","formatDate","roundDecimal","isDateTimeDataValue","isTypeDescriptor","isMappedValueTypeRenderer"],"mappings":";;;;;;;;AAmBA,MAAM,yBAA+C,EAAC;AAEzC,MAAA,qBAAA,GAAwB,CAAC,KAAA,KACpC,KAAS,IAAA,IAAA,GAAO,EAAK,GAAA,OAAO,KAAU,KAAA,QAAA,GAAW,KAAQ,GAAA,KAAA,CAAM,QAAS;AAE1E,MAAM,aAAA,GAAgB,CAAC,MAAwC,KAAA;AAC7D,EAAM,MAAA,OAAA,GAAUA,+BAAgB,CAAA,MAAA,CAAO,IAAI,CAAA;AAC3C,EAAM,MAAAC,WAAA,GAAYC,qBAAW,OAAO,CAAA;AAEpC,EAAA,OAAO,CAAC,KAAmB,KAAA;AACzB,IAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,KAAA,KAAU,CAAG,EAAA;AAC5C,MAAA,OAAOD,WAAU,CAAA,IAAI,IAAK,CAAA,KAAK,CAAC,CAAA;AAAA,KAC3B,MAAA;AACL,MAAO,OAAA,EAAA;AAAA;AACT,GACF;AACF,CAAA;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,KAAQ,GAAA,OAAA;AAAA,EACR;AACF,CAAiC,KAAA;AAC/B,EAAA,IAAI,IAAS,KAAA,KAAA,CAAA,IAAa,OAAO,IAAA,KAAS,QAAU,EAAA;AAClD,IAAO,OAAA,qBAAA;AAAA,GACF,MAAA;AACL,IAAM,MAAA;AAAA,MACJ,eAAkB,GAAA,KAAA;A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A;AACtC,IAAA,OAAO,iBAAiB,MAAM,CAAA;AAAA;AAEhC,EAAO,OAAA,qBAAA;AACT;AAQO,MAAM,SAAY,GAAA,CAAC,GACxB,KAAA,GAAA,CAAI,WAAY;;;;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -74,6 +74,10 @@ exports.moveItem = arrayUtils.moveItem;
|
|
|
74
74
|
exports.moveItemDeprecated = arrayUtils.moveItemDeprecated;
|
|
75
75
|
exports.partition = arrayUtils.partition;
|
|
76
76
|
exports.boxContainsPoint = boxUtils.boxContainsPoint;
|
|
77
|
+
exports.getCenteredBox = boxUtils.getCenteredBox;
|
|
78
|
+
exports.getPositionWithinBox = boxUtils.getPositionWithinBox;
|
|
79
|
+
exports.isGridLayoutSplitDirection = boxUtils.isGridLayoutSplitDirection;
|
|
80
|
+
exports.pointPositionWithinRect = boxUtils.pointPositionWithinRect;
|
|
77
81
|
exports.AggregationType = columnUtils.AggregationType;
|
|
78
82
|
exports.addColumnToSubscribedColumns = columnUtils.addColumnToSubscribedColumns;
|
|
79
83
|
exports.applyDefaultColumnConfig = columnUtils.applyDefaultColumnConfig;
|
|
@@ -82,6 +86,7 @@ exports.applyRuntimeColumnWidthsToConfig = columnUtils.applyRuntimeColumnWidthsT
|
|
|
82
86
|
exports.applySortToColumns = columnUtils.applySortToColumns;
|
|
83
87
|
exports.applyWidthToColumns = columnUtils.applyWidthToColumns;
|
|
84
88
|
exports.buildColumnMap = columnUtils.buildColumnMap;
|
|
89
|
+
exports.buildReverseColumnMap = columnUtils.buildReverseColumnMap;
|
|
85
90
|
exports.checkConfirmationPending = columnUtils.checkConfirmationPending;
|
|
86
91
|
exports.dataAndColumnUnchanged = columnUtils.dataAndColumnUnchanged;
|
|
87
92
|
exports.dataColumnAndKeyUnchanged = columnUtils.dataColumnAndKeyUnchanged;
|
|
@@ -171,6 +176,7 @@ exports.DOWN1 = dataUtils.DOWN1;
|
|
|
171
176
|
exports.DOWN2 = dataUtils.DOWN2;
|
|
172
177
|
exports.UP1 = dataUtils.UP1;
|
|
173
178
|
exports.UP2 = dataUtils.UP2;
|
|
179
|
+
exports.asInteger = dataUtils.asInteger;
|
|
174
180
|
exports.getMovingValueDirection = dataUtils.getMovingValueDirection;
|
|
175
181
|
exports.isValidNumber = dataUtils.isValidNumber;
|
|
176
182
|
exports.numericTypeOfStringValue = dataUtils.numericTypeOfStringValue;
|
|
@@ -263,13 +269,16 @@ exports.getCustomAndTableFeatures = featureUtils.getCustomAndTableFeatures;
|
|
|
263
269
|
exports.getFilterTableFeatures = featureUtils.getFilterTableFeatures;
|
|
264
270
|
exports.hasFilterTableFeatureProps = featureUtils.hasFilterTableFeatureProps;
|
|
265
271
|
exports.isCustomFeature = featureUtils.isCustomFeature;
|
|
272
|
+
exports.isSameTable = featureUtils.isSameTable;
|
|
266
273
|
exports.isStaticFeatures = featureUtils.isStaticFeatures;
|
|
267
|
-
exports.
|
|
274
|
+
exports.isVuuTables = featureUtils.isVuuTables;
|
|
268
275
|
exports.isWildcardSchema = featureUtils.isWildcardSchema;
|
|
269
276
|
exports.getFieldName = formUtils.getFieldName;
|
|
270
277
|
exports.getTypedValue = formUtils.getTypedValue;
|
|
278
|
+
exports.isNumber = formUtils.isNumber;
|
|
271
279
|
exports.defaultValueFormatter = formattingUtils.defaultValueFormatter;
|
|
272
280
|
exports.getValueFormatter = formattingUtils.getValueFormatter;
|
|
281
|
+
exports.lowerCase = formattingUtils.lowerCase;
|
|
273
282
|
exports.numericFormatter = formattingUtils.numericFormatter;
|
|
274
283
|
exports.getUniqueId = getUniqueId.getUniqueId;
|
|
275
284
|
exports.addGroupColumn = groupUtils.addGroupColumn;
|
|
@@ -308,10 +317,11 @@ exports.isRoot = menuUtils.isRoot;
|
|
|
308
317
|
exports.isRowMenu = menuUtils.isRowMenu;
|
|
309
318
|
exports.isSelectionMenu = menuUtils.isSelectionMenu;
|
|
310
319
|
exports.isTableLocation = menuUtils.isTableLocation;
|
|
311
|
-
exports.assertModuleExportsAtLeastOneComponent = moduleUtils.assertModuleExportsAtLeastOneComponent;
|
|
312
320
|
exports.isModule = moduleUtils.isModule;
|
|
313
321
|
exports.uuid = index.uuid;
|
|
314
322
|
exports.asReactElements = reactUtils.asReactElements;
|
|
323
|
+
exports.isSimpleStateValue = reactUtils.isSimpleStateValue;
|
|
324
|
+
exports.useIsMounted = reactUtils.useIsMounted;
|
|
315
325
|
exports.roundDecimal = roundDecimal.roundDecimal;
|
|
316
326
|
exports.debounce = perfUtils.debounce;
|
|
317
327
|
exports.throttle = perfUtils.throttle;
|
|
@@ -368,6 +378,7 @@ exports.DEFAULT_THEME_MODE = ThemeProvider.DEFAULT_THEME_MODE;
|
|
|
368
378
|
exports.ThemeContext = ThemeProvider.ThemeContext;
|
|
369
379
|
exports.ThemeProvider = ThemeProvider.ThemeProvider;
|
|
370
380
|
exports.useThemeAttributes = ThemeProvider.useThemeAttributes;
|
|
381
|
+
exports.elementImplementsJSONSerialization = tsUtils.elementImplementsJSONSerialization;
|
|
371
382
|
exports.isNotNullOrUndefined = tsUtils.isNotNullOrUndefined;
|
|
372
383
|
exports.isObject = tsUtils.isObject;
|
|
373
384
|
exports.getUrlParameter = urlUtils.getUrlParameter;
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/cjs/module-utils.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const isModule = (entity) => entity !== void 0 && typeof entity !== "function";
|
|
4
|
-
const assertModuleExportsAtLeastOneComponent = (module) => {
|
|
5
|
-
if (module && Object.values(module).every((item) => isModule(item))) {
|
|
6
|
-
throw Error("module file, no components");
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
4
|
|
|
10
|
-
exports.assertModuleExportsAtLeastOneComponent = assertModuleExportsAtLeastOneComponent;
|
|
11
5
|
exports.isModule = isModule;
|
|
12
6
|
//# sourceMappingURL=module-utils.js.map
|
package/cjs/module-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-utils.js","sources":["../src/module-utils.ts"],"sourcesContent":["export type ReactComponent = {\n (props?: any): JSX.Element;\n};\n\nexport const isModule = (entity: Module | ReactComponent): entity is Module =>\n entity !== undefined && typeof entity !== \"function\";\n\nexport interface Module<T = ReactComponent> {\n [key: string]: Module<T> | T;\n}\n
|
|
1
|
+
{"version":3,"file":"module-utils.js","sources":["../src/module-utils.ts"],"sourcesContent":["export type ReactComponent = {\n (props?: any): JSX.Element;\n};\n\nexport const isModule = (entity: Module | ReactComponent): entity is Module =>\n entity !== undefined && typeof entity !== \"function\";\n\nexport interface Module<T = ReactComponent> {\n [key: string]: Module<T> | T;\n}\n"],"names":[],"mappings":";;AAIO,MAAM,WAAW,CAAC,MAAA,KACvB,MAAW,KAAA,KAAA,CAAA,IAAa,OAAO,MAAW,KAAA;;;;"}
|
package/cjs/react-utils.js
CHANGED
|
@@ -16,6 +16,21 @@ const asReactElements = (children) => {
|
|
|
16
16
|
return EMPTY_ARRAY;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
+
const useIsMounted = (id = "") => {
|
|
20
|
+
const isMountedRef = React.useRef(false);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
console.log(`is MOUNTED ${id}`);
|
|
23
|
+
isMountedRef.current = true;
|
|
24
|
+
return () => {
|
|
25
|
+
console.log(`is UNMOUNTED ${id}`);
|
|
26
|
+
isMountedRef.current = false;
|
|
27
|
+
};
|
|
28
|
+
}, [id]);
|
|
29
|
+
return isMountedRef;
|
|
30
|
+
};
|
|
31
|
+
const isSimpleStateValue = (arg) => typeof arg !== "function";
|
|
19
32
|
|
|
20
33
|
exports.asReactElements = asReactElements;
|
|
34
|
+
exports.isSimpleStateValue = isSimpleStateValue;
|
|
35
|
+
exports.useIsMounted = useIsMounted;
|
|
21
36
|
//# sourceMappingURL=react-utils.js.map
|
package/cjs/react-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-utils.js","sources":["../src/react-utils.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"react-utils.js","sources":["../src/react-utils.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n SetStateAction,\n useEffect,\n useRef,\n} from \"react\";\n\nconst EMPTY_ARRAY: ReactElement[] = [];\n\nexport const asReactElements = (children: ReactNode): ReactElement[] => {\n const isArray = Array.isArray(children);\n const count = isArray ? children.length : Children.count(children);\n if (isArray && children.every(isValidElement)) {\n return children;\n } else if (count === 1 && !isArray && isValidElement(children)) {\n return [children];\n } else if (count > 1) {\n return children as ReactElement[];\n } else {\n return EMPTY_ARRAY;\n }\n};\n\nexport const useIsMounted = (id = \"\") => {\n const isMountedRef = useRef(false);\n useEffect(() => {\n console.log(`is MOUNTED ${id}`);\n isMountedRef.current = true;\n return () => {\n console.log(`is UNMOUNTED ${id}`);\n isMountedRef.current = false;\n };\n }, [id]);\n\n return isMountedRef;\n};\n\nexport const isSimpleStateValue = <T>(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.js
CHANGED
|
@@ -7,6 +7,7 @@ const treeToDataSourceRows = (treeSourceNodes, iconProvider) => {
|
|
|
7
7
|
const columns = [];
|
|
8
8
|
columns.push(
|
|
9
9
|
{
|
|
10
|
+
hidden: true,
|
|
10
11
|
name: "nodeData",
|
|
11
12
|
type: "json"
|
|
12
13
|
},
|
|
@@ -31,7 +32,7 @@ const addChildValues = (rows, treeSourceNodes, cols, iconProvider, index = { val
|
|
|
31
32
|
if (depth === cols.length - 1) {
|
|
32
33
|
cols.push({
|
|
33
34
|
getIcon: iconProvider?.getIcon,
|
|
34
|
-
name: `Level ${cols.length
|
|
35
|
+
name: `Level ${cols.length}`,
|
|
35
36
|
type: "string"
|
|
36
37
|
});
|
|
37
38
|
}
|
package/cjs/tree-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-utils.js","sources":["../src/tree-utils.ts"],"sourcesContent":["import { TreeSourceNode } from \"./tree-types\";\nimport { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport { DataSourceRow } from \"@vuu-ui/vuu-data-types\";\nimport { metadataKeys } from \"./column-utils\";\nimport { IconProvider } from \"@vuu-ui/vuu-data-local/src/tree-data-source/IconProvider\";\n\nconst { COUNT, DEPTH, IDX, KEY } = metadataKeys;\n\ntype Index = { value: number };\n\nexport const treeToDataSourceRows = (\n treeSourceNodes: TreeSourceNode[],\n iconProvider?: IconProvider,\n): [ColumnDescriptor[], DataSourceRow[]] => {\n const columns: ColumnDescriptor[] = [];\n\n columns.push(\n {\n name: \"nodeData\",\n type: \"json\",\n },\n {\n getIcon: iconProvider?.getIcon,\n name: \"Level 1\",\n type: \"string\",\n },\n {\n getIcon: iconProvider?.getIcon,\n name: \"Level 2\",\n type: \"string\",\n },\n );\n\n const rows: DataSourceRow[] = [];\n\n addChildValues(rows, treeSourceNodes, columns, iconProvider);\n return [columns, rows];\n};\n\nconst addChildValues = (\n rows: DataSourceRow[],\n treeSourceNodes: TreeSourceNode[],\n cols: ColumnDescriptor[],\n iconProvider: IconProvider | undefined,\n index: Index = { value: 0 },\n keyBase = \"$root\",\n depth = 1,\n): [number, number] => {\n let leafCount = 0;\n let rowCount = 0;\n if (depth === cols.length - 1) {\n cols.push({\n getIcon: iconProvider?.getIcon,\n name: `Level ${cols.length
|
|
1
|
+
{"version":3,"file":"tree-utils.js","sources":["../src/tree-utils.ts"],"sourcesContent":["import { TreeSourceNode } from \"./tree-types\";\nimport { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport { DataSourceRow } from \"@vuu-ui/vuu-data-types\";\nimport { metadataKeys } from \"./column-utils\";\nimport { IconProvider } from \"@vuu-ui/vuu-data-local/src/tree-data-source/IconProvider\";\n\nconst { COUNT, DEPTH, IDX, KEY } = metadataKeys;\n\ntype Index = { value: number };\n\nexport const treeToDataSourceRows = (\n treeSourceNodes: TreeSourceNode[],\n iconProvider?: IconProvider,\n): [ColumnDescriptor[], DataSourceRow[]] => {\n const columns: ColumnDescriptor[] = [];\n\n columns.push(\n {\n hidden: true,\n name: \"nodeData\",\n type: \"json\",\n },\n {\n getIcon: iconProvider?.getIcon,\n name: \"Level 1\",\n type: \"string\",\n },\n {\n getIcon: iconProvider?.getIcon,\n name: \"Level 2\",\n type: \"string\",\n },\n );\n\n const rows: DataSourceRow[] = [];\n\n addChildValues(rows, treeSourceNodes, columns, iconProvider);\n return [columns, rows];\n};\n\nconst addChildValues = (\n rows: DataSourceRow[],\n treeSourceNodes: TreeSourceNode[],\n cols: ColumnDescriptor[],\n iconProvider: IconProvider | undefined,\n index: Index = { value: 0 },\n keyBase = \"$root\",\n depth = 1,\n): [number, number] => {\n let leafCount = 0;\n let rowCount = 0;\n if (depth === cols.length - 1) {\n cols.push({\n getIcon: iconProvider?.getIcon,\n name: `Level ${cols.length}`,\n type: \"string\",\n });\n }\n for (let i = 0; i < treeSourceNodes.length; i++, index.value += 1) {\n const { childNodes, icon, label, nodeData } = treeSourceNodes[i];\n const blanks = Array(depth - 1).fill(\"\");\n const fullKey = `${keyBase}|${label}`;\n // prettier-ignore\n const row = [index.value, index.value, false,false,depth,0,fullKey,0, nodeData, ...blanks, label ] as DataSourceRow;\n if (icon) {\n iconProvider?.setIcon(fullKey, icon);\n }\n rows.push(row);\n rowCount += 1;\n\n if (childNodes && childNodes.length > 0) {\n const [nestedLeafCount, nestedRowCount] = addChildValues(\n rows,\n childNodes,\n cols,\n iconProvider,\n { value: index.value + 1 },\n fullKey,\n depth + 1,\n );\n row[COUNT] = nestedLeafCount;\n leafCount += nestedLeafCount;\n rowCount += nestedRowCount;\n index.value += nestedRowCount;\n } else {\n leafCount += 1;\n }\n }\n\n return [leafCount, rowCount];\n};\n\nexport const lastPathSegment = (path: string, separator = \"/\") => {\n const root = path.endsWith(separator) ? path.slice(0, -1) : path;\n return root.slice(root.lastIndexOf(separator) + 1);\n};\n\nexport const dropLastPathSegment = (path: string, separator = \"/\") => {\n return path.slice(0, path.lastIndexOf(separator));\n};\n\nexport const getParentRow = (rows: DataSourceRow[], row: DataSourceRow) => {\n const { [IDX]: idx, [DEPTH]: depth } = row;\n for (let i = idx - 1; i >= 0; i--) {\n const nextRow = rows[i];\n if (nextRow[DEPTH] === depth - 1) {\n return nextRow;\n }\n }\n};\n\nconst rowsAreSiblings = (key1: string, key2: string) =>\n dropLastPathSegment(key1, \"|\") === dropLastPathSegment(key2, \"|\");\n\nexport const missingAncestor = (\n row: DataSourceRow,\n previousRow?: DataSourceRow,\n) => {\n if (previousRow) {\n const prevKey = previousRow[KEY];\n const key = row[KEY];\n\n if (key.startsWith(prevKey)) {\n return false;\n } else if (!rowsAreSiblings(prevKey, key)) {\n return true;\n }\n } else if (row[DEPTH] > 1) {\n return true;\n }\n\n return false;\n};\n"],"names":["metadataKeys"],"mappings":";;;;AAMA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,GAAA,EAAK,KAAQ,GAAAA,wBAAA;AAItB,MAAA,oBAAA,GAAuB,CAClC,eAAA,EACA,YAC0C,KAA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AA;AAAA;AACT,GACS,MAAA,IAAA,GAAA,CAAI,KAAK,CAAA,GAAI,CAAG,EAAA;AACzB,IAAO,OAAA,IAAA;AAAA;AAGT,EAAO,OAAA,KAAA;AACT;;;;;;;;"}
|
package/cjs/ts-utils.js
CHANGED
|
@@ -4,7 +4,9 @@ function isNotNullOrUndefined(value) {
|
|
|
4
4
|
return value !== void 0 && value !== null;
|
|
5
5
|
}
|
|
6
6
|
const isObject = (o) => typeof o === "object" && o !== null;
|
|
7
|
+
const elementImplementsJSONSerialization = (element) => typeof element.type.toJSON === "function";
|
|
7
8
|
|
|
9
|
+
exports.elementImplementsJSONSerialization = elementImplementsJSONSerialization;
|
|
8
10
|
exports.isNotNullOrUndefined = isNotNullOrUndefined;
|
|
9
11
|
exports.isObject = isObject;
|
|
10
12
|
//# sourceMappingURL=ts-utils.js.map
|
package/cjs/ts-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-utils.js","sources":["../src/ts-utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ts-utils.js","sources":["../src/ts-utils.ts"],"sourcesContent":["import { JSXElementConstructor, ReactElement } from \"react\";\nimport { LayoutJSON } from \"./json-types\";\n\nexport function isNotNullOrUndefined<T>(\n value: T | undefined | null,\n): value is NonNullable<T> {\n return value !== undefined && value !== null;\n}\n\nexport const isObject = (o: unknown): o is object =>\n typeof o === \"object\" && o !== null;\n\nexport type OptionalProperty<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>;\n\n/**\n * test whether a given react element implements a custom toJSON\n * serialisation (static) method.\n */\ntype JsonEnabledJSXElementConstructor<P> = JSXElementConstructor<P> & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON: (el: ReactElement) => LayoutJSON<any>;\n};\n\ninterface ReactElementWithJSON<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n P = any,\n T extends // eslint-disable-next-line @typescript-eslint/no-explicit-any\n JsonEnabledJSXElementConstructor<any> = JsonEnabledJSXElementConstructor<any>,\n> {\n type: T;\n props: P;\n key: string | null;\n}\nexport const elementImplementsJSONSerialization = (\n element: ReactElement,\n): element is ReactElementWithJSON =>\n typeof (element.type as JsonEnabledJSXElementConstructor<unknown>).toJSON ===\n \"function\";\n"],"names":[],"mappings":";;AAGO,SAAS,qBACd,KACyB,EAAA;AACzB,EAAO,OAAA,KAAA,KAAU,UAAa,KAAU,KAAA,IAAA;AAC1C;AAEO,MAAM,WAAW,CAAC,CAAA,KACvB,OAAO,CAAA,KAAM,YAAY,CAAM,KAAA;AAwB1B,MAAM,qCAAqC,CAChD,OAAA,KAEA,OAAQ,OAAA,CAAQ,KAAmD,MACnE,KAAA;;;;;;"}
|
package/esm/box-utils.js
CHANGED
|
@@ -3,6 +3,45 @@ function boxContainsPoint(rect, x, y) {
|
|
|
3
3
|
return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom;
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
+
function getCenteredBox({ right, left, top, bottom }, pctSize) {
|
|
7
|
+
const pctOffset = (1 - pctSize) / 2;
|
|
8
|
+
const w = (right - left) * pctOffset;
|
|
9
|
+
const h = (bottom - top) * pctOffset;
|
|
10
|
+
return { left: left + w, top: top + h, right: right - w, bottom: bottom - h };
|
|
11
|
+
}
|
|
12
|
+
function pointPositionWithinRect(x, y, rect, borderZone = 30) {
|
|
13
|
+
const width = rect.right - rect.left;
|
|
14
|
+
const height = rect.bottom - rect.top;
|
|
15
|
+
const posX = x - rect.left;
|
|
16
|
+
const posY = y - rect.top;
|
|
17
|
+
let closeToTheEdge = 0;
|
|
18
|
+
if (posX < borderZone) closeToTheEdge += 8;
|
|
19
|
+
if (posX > width - borderZone) closeToTheEdge += 2;
|
|
20
|
+
if (posY < borderZone) closeToTheEdge += 1;
|
|
21
|
+
if (posY > height - borderZone) closeToTheEdge += 4;
|
|
22
|
+
return { pctX: posX / width, pctY: posY / height, closeToTheEdge };
|
|
23
|
+
}
|
|
24
|
+
const isGridLayoutSplitDirection = (position) => position !== "centre" && position !== "header";
|
|
25
|
+
function getPositionWithinBox(x, y, rect, pctX, pctY) {
|
|
26
|
+
const centerBox = getCenteredBox(rect, 0.2);
|
|
27
|
+
if (boxContainsPoint(centerBox, x, y)) {
|
|
28
|
+
return "centre";
|
|
29
|
+
} else {
|
|
30
|
+
const quadrant = `${pctY < 0.5 ? "north" : "south"}${pctX < 0.5 ? "west" : "east"}`;
|
|
31
|
+
switch (quadrant) {
|
|
32
|
+
case "northwest":
|
|
33
|
+
return pctX > pctY ? "north" : "west";
|
|
34
|
+
case "northeast":
|
|
35
|
+
return 1 - pctX > pctY ? "north" : "east";
|
|
36
|
+
case "southeast":
|
|
37
|
+
return pctX > pctY ? "east" : "south";
|
|
38
|
+
case "southwest":
|
|
39
|
+
return 1 - pctX > pctY ? "west" : "south";
|
|
40
|
+
default:
|
|
41
|
+
throw Error("getPositionWithinBox failed top compute position");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
6
45
|
|
|
7
|
-
export { boxContainsPoint };
|
|
46
|
+
export { boxContainsPoint, getCenteredBox, getPositionWithinBox, isGridLayoutSplitDirection, pointPositionWithinRect };
|
|
8
47
|
//# sourceMappingURL=box-utils.js.map
|
package/esm/box-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box-utils.js","sources":["../src/box-utils.ts"],"sourcesContent":["export interface rect {\n bottom: number;\n left: number;\n right: number;\n top: number;\n}\nexport type rectTuple = [number, number, number, number];\n\nexport type dimension = \"width\" | \"height\";\n\nexport function boxContainsPoint(rect: rect, x: number, y: number) {\n if (rect) {\n return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom;\n }\n}\n"],"names":[],"mappings":"AAUgB,SAAA,gBAAA,CAAiB,IAAY,EAAA,CAAA,EAAW,CAAW,EAAA;AACjE,EAAA,IAAI,IAAM,EAAA;AACR,IAAO,OAAA,CAAA,IAAK,IAAK,CAAA,IAAA,IAAQ,CAAI,GAAA,IAAA,CAAK,SAAS,CAAK,IAAA,IAAA,CAAK,GAAO,IAAA,CAAA,GAAI,IAAK,CAAA,MAAA;AAAA;AAEzE;;;;"}
|
|
1
|
+
{"version":3,"file":"box-utils.js","sources":["../src/box-utils.ts"],"sourcesContent":["export interface rect {\n bottom: number;\n left: number;\n right: number;\n top: number;\n}\nexport type rectTuple = [number, number, number, number];\n\nexport type dimension = \"width\" | \"height\";\n\nexport function boxContainsPoint(rect: rect, x: number, y: number) {\n if (rect) {\n return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom;\n }\n}\n\nexport type GridLayoutSplitDirection = \"north\" | \"south\" | \"east\" | \"west\";\n\nexport type GridLayoutDropPosition =\n | GridLayoutSplitDirection\n | \"header\"\n | \"centre\";\n\nexport function getCenteredBox(\n { right, left, top, bottom }: rect,\n pctSize: number,\n) {\n const pctOffset = (1 - pctSize) / 2;\n const w = (right - left) * pctOffset;\n const h = (bottom - top) * pctOffset;\n return { left: left + w, top: top + h, right: right - w, bottom: bottom - h };\n}\n\nexport function pointPositionWithinRect(\n x: number,\n y: number,\n rect: rect,\n borderZone = 30,\n) {\n const width = rect.right - rect.left;\n const height = rect.bottom - rect.top;\n const posX = x - rect.left;\n const posY = y - rect.top;\n let closeToTheEdge = 0;\n\n if (posX < borderZone) closeToTheEdge += 8;\n if (posX > width - borderZone) closeToTheEdge += 2;\n if (posY < borderZone) closeToTheEdge += 1;\n if (posY > height - borderZone) closeToTheEdge += 4;\n\n return { pctX: posX / width, pctY: posY / height, closeToTheEdge };\n}\n\nexport const isGridLayoutSplitDirection = (\n position: GridLayoutDropPosition,\n): position is GridLayoutSplitDirection =>\n position !== \"centre\" && position !== \"header\";\n\nexport function getPositionWithinBox(\n x: number,\n y: number,\n rect: rect,\n pctX: number,\n pctY: number,\n): GridLayoutDropPosition {\n const centerBox = getCenteredBox(rect, 0.2);\n if (boxContainsPoint(centerBox, x, y)) {\n return \"centre\";\n } else {\n const quadrant = `${pctY < 0.5 ? \"north\" : \"south\"}${\n pctX < 0.5 ? \"west\" : \"east\"\n }`;\n\n switch (quadrant) {\n case \"northwest\":\n return pctX > pctY ? \"north\" : \"west\";\n case \"northeast\":\n return 1 - pctX > pctY ? \"north\" : \"east\";\n case \"southeast\":\n return pctX > pctY ? \"east\" : \"south\";\n case \"southwest\":\n return 1 - pctX > pctY ? \"west\" : \"south\";\n default:\n throw Error(\"getPositionWithinBox failed top compute position\");\n }\n }\n}\n"],"names":[],"mappings":"AAUgB,SAAA,gBAAA,CAAiB,IAAY,EAAA,CAAA,EAAW,CAAW,EAAA;AACjE,EAAA,IAAI,IAAM,EAAA;AACR,IAAO,OAAA,CAAA,IAAK,IAAK,CAAA,IAAA,IAAQ,CAAI,GAAA,IAAA,CAAK,SAAS,CAAK,IAAA,IAAA,CAAK,GAAO,IAAA,CAAA,GAAI,IAAK,CAAA,MAAA;AAAA;AAEzE;AASO,SAAS,eACd,EAAE,KAAA,EAAO,MAAM,GAAK,EAAA,MAAA,IACpB,OACA,EAAA;AACA,EAAM,MAAA,SAAA,GAAA,CAAa,IAAI,OAAW,IAAA,CAAA;AAClC,EAAM,MAAA,CAAA,GAAA,CAAK,QAAQ,IAAQ,IAAA,SAAA;AAC3B,EAAM,MAAA,CAAA,GAAA,CAAK,SAAS,GAAO,IAAA,SAAA;AAC3B,EAAA,OAAO,EAAE,IAAA,EAAM,IAAO,GAAA,CAAA,EAAG,GAAK,EAAA,GAAA,GAAM,CAAG,EAAA,KAAA,EAAO,KAAQ,GAAA,CAAA,EAAG,MAAQ,EAAA,MAAA,GAAS,CAAE,EAAA;AAC9E;AAEO,SAAS,uBACd,CAAA,CAAA,EACA,CACA,EAAA,IAAA,EACA,aAAa,EACb,EAAA;AACA,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,KAAA,GAAQ,IAAK,CAAA,IAAA;AAChC,EAAM,MAAA,MAAA,GAAS,IAAK,CAAA,MAAA,GAAS,IAAK,CAAA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A,IAAA,GAAO,OAAO,MAAS,GAAA,OAAA;AAAA,MAChC,KAAK,WAAA;AACH,QAAO,OAAA,CAAA,GAAI,IAAO,GAAA,IAAA,GAAO,MAAS,GAAA,OAAA;AAAA,MACpC;AACE,QAAA,MAAM,MAAM,kDAAkD,CAAA;AAAA;AAClE;AAEJ;;;;"}
|
package/esm/column-utils.js
CHANGED
|
@@ -111,6 +111,21 @@ function buildColumnMap(columns) {
|
|
|
111
111
|
return EMPTY_COLUMN_MAP;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
function buildReverseColumnMap(columns) {
|
|
115
|
+
const start = metadataKeys.count;
|
|
116
|
+
if (columns) {
|
|
117
|
+
return columns.reduce((map, column, i) => {
|
|
118
|
+
if (typeof column === "string") {
|
|
119
|
+
map[start + i] = column;
|
|
120
|
+
} else {
|
|
121
|
+
map[start + i] = column.name;
|
|
122
|
+
}
|
|
123
|
+
return map;
|
|
124
|
+
}, {});
|
|
125
|
+
} else {
|
|
126
|
+
return EMPTY_COLUMN_MAP;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
114
129
|
function projectUpdates(updates) {
|
|
115
130
|
const results = [];
|
|
116
131
|
const metadataOffset = metadataKeys.count - 2;
|
|
@@ -261,6 +276,7 @@ const sortPinnedColumns = (columns) => {
|
|
|
261
276
|
pinnedWidthLeft += column.width;
|
|
262
277
|
}
|
|
263
278
|
break;
|
|
279
|
+
// store right pinned columns initially in reverse order
|
|
264
280
|
case "right":
|
|
265
281
|
rightPinnedColumns.unshift(column);
|
|
266
282
|
break;
|
|
@@ -800,5 +816,5 @@ const dataColumnAndKeyUnchanged = (p, p1) => p.column === p1.column && p.row[KEY
|
|
|
800
816
|
const toColumnName = (column) => column.name;
|
|
801
817
|
const isStringColumn = (column) => column.serverDataType === "string";
|
|
802
818
|
|
|
803
|
-
export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applyRuntimeColumnWidthsToConfig, applySortToColumns, applyWidthToColumns, buildColumnMap, checkConfirmationPending, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getCalculatedColumnDetails, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupIcon, getGroupValue, getRowRecord, getRuntimeColumnWidth, getTableHeadings, getTypeFormattingFromColumn, hasCustomRenderer, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeDataValue, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNotHidden, isNumericColumn, isPinned, isResizing, isStringColumn, isTextColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toColumnName, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex };
|
|
819
|
+
export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applyRuntimeColumnWidthsToConfig, applySortToColumns, applyWidthToColumns, buildColumnMap, buildReverseColumnMap, checkConfirmationPending, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getCalculatedColumnDetails, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupIcon, getGroupValue, getRowRecord, getRuntimeColumnWidth, getTableHeadings, getTypeFormattingFromColumn, hasCustomRenderer, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeDataValue, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNotHidden, isNumericColumn, isPinned, isResizing, isStringColumn, isTextColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toColumnName, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex };
|
|
804
820
|
//# sourceMappingURL=column-utils.js.map
|