@neo4j-ndl/react 4.15.2 → 4.15.4
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/lib/cjs/_generated/style-rules/color-utils.js +50 -0
- package/lib/cjs/_generated/style-rules/color-utils.js.map +1 -0
- package/lib/cjs/_generated/style-rules/date-utils.js +145 -0
- package/lib/cjs/_generated/style-rules/date-utils.js.map +1 -0
- package/lib/cjs/_generated/style-rules/index.js +38 -0
- package/lib/cjs/_generated/style-rules/index.js.map +1 -0
- package/lib/cjs/_generated/style-rules/literal-schemas.js +64 -0
- package/lib/cjs/_generated/style-rules/literal-schemas.js.map +1 -0
- package/lib/cjs/data-grid/stories/datagrid-rule-based-styling-datetime.story.js +286 -0
- package/lib/cjs/data-grid/stories/datagrid-rule-based-styling-datetime.story.js.map +1 -0
- package/lib/cjs/data-grid/stories/index.js +5 -1
- package/lib/cjs/data-grid/stories/index.js.map +1 -1
- package/lib/cjs/data-grid/style-rules/evaluate.js +13 -17
- package/lib/cjs/data-grid/style-rules/evaluate.js.map +1 -1
- package/lib/cjs/data-grid/style-rules/index.js +3 -1
- package/lib/cjs/data-grid/style-rules/index.js.map +1 -1
- package/lib/cjs/data-grid/style-rules/types.js +26 -2
- package/lib/cjs/data-grid/style-rules/types.js.map +1 -1
- package/lib/cjs/time-picker/TimePicker.js +39 -22
- package/lib/cjs/time-picker/TimePicker.js.map +1 -1
- package/lib/cjs/time-picker/generate-time-options.js +6 -3
- package/lib/cjs/time-picker/generate-time-options.js.map +1 -1
- package/lib/cjs/time-picker/needle-time.js +23 -9
- package/lib/cjs/time-picker/needle-time.js.map +1 -1
- package/lib/cjs/time-picker/stories/index.js +5 -1
- package/lib/cjs/time-picker/stories/index.js.map +1 -1
- package/lib/cjs/time-picker/stories/time-picker-with-seconds.story.js +32 -0
- package/lib/cjs/time-picker/stories/time-picker-with-seconds.story.js.map +1 -0
- package/lib/esm/_generated/style-rules/color-utils.js +46 -0
- package/lib/esm/_generated/style-rules/color-utils.js.map +1 -0
- package/lib/esm/_generated/style-rules/date-utils.js +141 -0
- package/lib/esm/_generated/style-rules/date-utils.js.map +1 -0
- package/lib/esm/_generated/style-rules/index.js +29 -0
- package/lib/esm/_generated/style-rules/index.js.map +1 -0
- package/lib/esm/_generated/style-rules/literal-schemas.js +61 -0
- package/lib/esm/_generated/style-rules/literal-schemas.js.map +1 -0
- package/lib/esm/data-grid/stories/datagrid-rule-based-styling-datetime.story.js +284 -0
- package/lib/esm/data-grid/stories/datagrid-rule-based-styling-datetime.story.js.map +1 -0
- package/lib/esm/data-grid/stories/index.js +3 -0
- package/lib/esm/data-grid/stories/index.js.map +1 -1
- package/lib/esm/data-grid/style-rules/evaluate.js +7 -11
- package/lib/esm/data-grid/style-rules/evaluate.js.map +1 -1
- package/lib/esm/data-grid/style-rules/index.js +1 -1
- package/lib/esm/data-grid/style-rules/index.js.map +1 -1
- package/lib/esm/data-grid/style-rules/types.js +25 -1
- package/lib/esm/data-grid/style-rules/types.js.map +1 -1
- package/lib/esm/time-picker/TimePicker.js +39 -22
- package/lib/esm/time-picker/TimePicker.js.map +1 -1
- package/lib/esm/time-picker/generate-time-options.js +6 -3
- package/lib/esm/time-picker/generate-time-options.js.map +1 -1
- package/lib/esm/time-picker/needle-time.js +23 -9
- package/lib/esm/time-picker/needle-time.js.map +1 -1
- package/lib/esm/time-picker/stories/index.js +3 -0
- package/lib/esm/time-picker/stories/index.js.map +1 -1
- package/lib/esm/time-picker/stories/time-picker-with-seconds.story.js +30 -0
- package/lib/esm/time-picker/stories/time-picker-with-seconds.story.js.map +1 -0
- package/lib/types/_generated/style-rules/color-utils.d.ts +33 -0
- package/lib/types/_generated/style-rules/color-utils.d.ts.map +1 -0
- package/lib/types/_generated/style-rules/date-utils.d.ts +54 -0
- package/lib/types/_generated/style-rules/date-utils.d.ts.map +1 -0
- package/lib/types/_generated/style-rules/index.d.ts +25 -0
- package/lib/types/_generated/style-rules/index.d.ts.map +1 -0
- package/lib/types/_generated/style-rules/literal-schemas.d.ts +53 -0
- package/lib/types/_generated/style-rules/literal-schemas.d.ts.map +1 -0
- package/lib/types/data-grid/stories/datagrid-rule-based-styling-datetime.story.d.ts +24 -0
- package/lib/types/data-grid/stories/datagrid-rule-based-styling-datetime.story.d.ts.map +1 -0
- package/lib/types/data-grid/stories/index.d.ts +2 -0
- package/lib/types/data-grid/stories/index.d.ts.map +1 -1
- package/lib/types/data-grid/style-rules/evaluate.d.ts.map +1 -1
- package/lib/types/data-grid/style-rules/index.d.ts +2 -2
- package/lib/types/data-grid/style-rules/index.d.ts.map +1 -1
- package/lib/types/data-grid/style-rules/types.d.ts +33 -2
- package/lib/types/data-grid/style-rules/types.d.ts.map +1 -1
- package/lib/types/time-picker/TimePicker.d.ts +1 -1
- package/lib/types/time-picker/TimePicker.d.ts.map +1 -1
- package/lib/types/time-picker/generate-time-options.d.ts +1 -1
- package/lib/types/time-picker/generate-time-options.d.ts.map +1 -1
- package/lib/types/time-picker/needle-time.d.ts +4 -2
- package/lib/types/time-picker/needle-time.d.ts.map +1 -1
- package/lib/types/time-picker/stories/index.d.ts +2 -0
- package/lib/types/time-picker/stories/index.d.ts.map +1 -1
- package/lib/types/time-picker/stories/time-picker-with-seconds.story.d.ts +24 -0
- package/lib/types/time-picker/stories/time-picker-with-seconds.story.d.ts.map +1 -0
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-grid/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,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n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as DataGridCompactMode } from './datagrid-compact-mode.story';\nexport { default as DataGridSimple } from './datagrid-simple.story';\nexport { default as DataGridSortable } from './datagrid-sortable.story';\nexport { default as DataGridSelectable } from './datagrid-selectable.story';\nexport {\n Searchable as DataGridSearchable,\n ColumnFiltering as DataGridColumnFiltering,\n} from './datagrid-search-and-filters.stories';\nexport { default as DataGridInDialog } from './datagrid-in-dialog.story';\nexport { default as DataGridKitchenSink } from './datagrid-kitchen-sink.story';\nexport { default as DataGridVirtualization } from './datagrid-virtualization.story';\nexport { default as DataGridSkeletonLoading } from './datagrid-skeleton-loading.story';\nexport { default as DataGridPlaceholderStates } from './datagrid-placeholder-states.story';\nexport { default as DataGridResizableColumn } from './datagrid-resizable-column.story';\nexport { default as DataGridComponentOverriding } from './datagrid-component-overriding.story';\nexport { default as DataGridKeyboardNavigation } from './datagrid-keyboard-navigation.story';\nexport { default as DataGridPercentageWidthColumns } from './datagrid-percentage-width-columns.story';\nexport {\n PinnedBothSides as DataGridPinnedBothSides,\n PinnedLeftSide as DataGridPinnedLeftSide,\n PinnedRightSide as DataGridPinnedRightSide,\n} from './datagrid-pinned-columns.stories';\nexport { default as DataGridNoPaginationTable } from './datagrid-no-pagination-table.story';\nexport { default as DataGridSingleSelectable } from './datagrid-single-selectable.story';\nexport { default as DataGridUsingEditableCells } from './datagrid-using-editable-cells.story';\nexport { default as DataGridRuleBasedStyling } from './datagrid-rule-based-styling.story';\nexport { default as DataGridCustomCellWithStyleRules } from './datagrid-custom-cell-with-style-rules.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport DataGridColumnFilteringSourceRaw from './datagrid-column-filtering.story?raw';\nimport DataGridCompactModeSourceRaw from './datagrid-compact-mode.story?raw';\nimport DataGridComponentOverridingSourceRaw from './datagrid-component-overriding.story?raw';\nimport DataGridCustomCellWithStyleRulesSourceRaw from './datagrid-custom-cell-with-style-rules.story?raw';\nimport DataGridInDialogSourceRaw from './datagrid-in-dialog.story?raw';\nimport DataGridKeyboardNavigationSourceRaw from './datagrid-keyboard-navigation.story?raw';\nimport DataGridKitchenSinkSourceRaw from './datagrid-kitchen-sink.story?raw';\nimport DataGridNoPaginationTableRaw from './datagrid-no-pagination-table.story?raw';\nimport DataGridPercentageWidthColumnsSourceRaw from './datagrid-percentage-width-columns.story?raw';\nimport DataGridPinnedColumnsSourceRaw from './datagrid-pinned-columns.stories?raw';\nimport DataGridPlaceholderStatesSourceRaw from './datagrid-placeholder-states.story?raw';\nimport DataGridResizableColumnSourceRaw from './datagrid-resizable-column.story?raw';\nimport DataGridRuleBasedStylingSourceRaw from './datagrid-rule-based-styling.story?raw';\nimport DataGridSearchableSourceRaw from './datagrid-search-and-filters.stories?raw';\nimport DataGridSelectableSourceRaw from './datagrid-selectable.story?raw';\nimport DataGridSimpleSourceRaw from './datagrid-simple.story?raw';\nimport DataGridSingleSelectableSourceRaw from './datagrid-single-selectable.story?raw';\nimport DataGridSkeletonLoadingSourceRaw from './datagrid-skeleton-loading.story?raw';\nimport DataGridSortableSourceRaw from './datagrid-sortable.story?raw';\nimport DataGridUsingEditableCellsSourceRaw from './datagrid-using-editable-cells.story?raw';\nimport DataGridVirtualizationSourceRaw from './datagrid-virtualization.story?raw';\n\nexport const DataGridCustomCellWithStyleRulesSource = removeLicenseHeader(\n DataGridCustomCellWithStyleRulesSourceRaw,\n);\nexport const DataGridRuleBasedStylingSource = removeLicenseHeader(\n DataGridRuleBasedStylingSourceRaw,\n);\nexport const DataGridSimpleSource = removeLicenseHeader(\n DataGridSimpleSourceRaw,\n);\nexport const DataGridCompactModeSource = removeLicenseHeader(\n DataGridCompactModeSourceRaw,\n);\nexport const DataGridSortableSource = removeLicenseHeader(\n DataGridSortableSourceRaw,\n);\nexport const DataGridSelectableSource = removeLicenseHeader(\n DataGridSelectableSourceRaw,\n);\nexport const DataGridSearchableSource = removeLicenseHeader(\n DataGridSearchableSourceRaw,\n);\nexport const DataGridInDialogSource = removeLicenseHeader(\n DataGridInDialogSourceRaw,\n);\nexport const DataGridKitchenSinkSource = removeLicenseHeader(\n DataGridKitchenSinkSourceRaw,\n);\nexport const DataGridVirtualizationSource = removeLicenseHeader(\n DataGridVirtualizationSourceRaw,\n);\nexport const DataGridSkeletonLoadingSource = removeLicenseHeader(\n DataGridSkeletonLoadingSourceRaw,\n);\nexport const DataGridPlaceholderStatesSource = removeLicenseHeader(\n DataGridPlaceholderStatesSourceRaw,\n);\nexport const DataGridResizableColumnSource = removeLicenseHeader(\n DataGridResizableColumnSourceRaw,\n);\nexport const DataGridColumnFilteringSource = removeLicenseHeader(\n DataGridColumnFilteringSourceRaw,\n);\nexport const DataGridComponentOverridingSource = removeLicenseHeader(\n DataGridComponentOverridingSourceRaw,\n);\nexport const DataGridKeyboardNavigationSource = removeLicenseHeader(\n DataGridKeyboardNavigationSourceRaw,\n);\nexport const DataGridPercentageWidthColumnsSource = removeLicenseHeader(\n DataGridPercentageWidthColumnsSourceRaw,\n);\nexport const DataGridPinnedColumnsSource = removeLicenseHeader(\n DataGridPinnedColumnsSourceRaw,\n);\nexport const DataGridNoPaginationTableSource = removeLicenseHeader(\n DataGridNoPaginationTableRaw,\n);\nexport const DataGridSingleSelectableSource = removeLicenseHeader(\n DataGridSingleSelectableSourceRaw,\n);\nexport const DataGridUsingEditableCellsSource = removeLicenseHeader(\n DataGridUsingEditableCellsSourceRaw,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-grid/stories/index.ts"],"names":[],"mappings":"AAAA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ACF,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAC5D,8BAA8B,CAC/B,CAAC;AACF,MAAM,CAAC,MAAM,+BAA+B,GAAG,mBAAmB,CAChE,4BAA4B,CAC7B,CAAC;AACF,MAAM,CAAC,MAAM,8BAA8B,GAAG,mBAAmB,CAC/D,iCAAiC,CAClC,CAAC;AACF,MAAM,CAAC,MAAM,gCAAgC,GAAG,mBAAmB,CACjE,mCAAmC,CACpC,CAAC;AACF,MAAM,CAAC,MAAM,sCAAsC,GAAG,mBAAmB,CACvE,yCAAyC,CAC1C,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as DataGridCompactMode } from './datagrid-compact-mode.story';\nexport { default as DataGridSimple } from './datagrid-simple.story';\nexport { default as DataGridSortable } from './datagrid-sortable.story';\nexport { default as DataGridSelectable } from './datagrid-selectable.story';\nexport {\n Searchable as DataGridSearchable,\n ColumnFiltering as DataGridColumnFiltering,\n} from './datagrid-search-and-filters.stories';\nexport { default as DataGridInDialog } from './datagrid-in-dialog.story';\nexport { default as DataGridKitchenSink } from './datagrid-kitchen-sink.story';\nexport { default as DataGridVirtualization } from './datagrid-virtualization.story';\nexport { default as DataGridSkeletonLoading } from './datagrid-skeleton-loading.story';\nexport { default as DataGridPlaceholderStates } from './datagrid-placeholder-states.story';\nexport { default as DataGridResizableColumn } from './datagrid-resizable-column.story';\nexport { default as DataGridComponentOverriding } from './datagrid-component-overriding.story';\nexport { default as DataGridKeyboardNavigation } from './datagrid-keyboard-navigation.story';\nexport { default as DataGridPercentageWidthColumns } from './datagrid-percentage-width-columns.story';\nexport {\n PinnedBothSides as DataGridPinnedBothSides,\n PinnedLeftSide as DataGridPinnedLeftSide,\n PinnedRightSide as DataGridPinnedRightSide,\n} from './datagrid-pinned-columns.stories';\nexport { default as DataGridNoPaginationTable } from './datagrid-no-pagination-table.story';\nexport { default as DataGridSingleSelectable } from './datagrid-single-selectable.story';\nexport { default as DataGridUsingEditableCells } from './datagrid-using-editable-cells.story';\nexport { default as DataGridRuleBasedStyling } from './datagrid-rule-based-styling.story';\nexport { default as DataGridCustomCellWithStyleRules } from './datagrid-custom-cell-with-style-rules.story';\nexport { default as DataGridRuleBasedStylingDateTime } from './datagrid-rule-based-styling-datetime.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport DataGridColumnFilteringSourceRaw from './datagrid-column-filtering.story?raw';\nimport DataGridCompactModeSourceRaw from './datagrid-compact-mode.story?raw';\nimport DataGridComponentOverridingSourceRaw from './datagrid-component-overriding.story?raw';\nimport DataGridCustomCellWithStyleRulesSourceRaw from './datagrid-custom-cell-with-style-rules.story?raw';\nimport DataGridInDialogSourceRaw from './datagrid-in-dialog.story?raw';\nimport DataGridKeyboardNavigationSourceRaw from './datagrid-keyboard-navigation.story?raw';\nimport DataGridKitchenSinkSourceRaw from './datagrid-kitchen-sink.story?raw';\nimport DataGridNoPaginationTableRaw from './datagrid-no-pagination-table.story?raw';\nimport DataGridPercentageWidthColumnsSourceRaw from './datagrid-percentage-width-columns.story?raw';\nimport DataGridPinnedColumnsSourceRaw from './datagrid-pinned-columns.stories?raw';\nimport DataGridPlaceholderStatesSourceRaw from './datagrid-placeholder-states.story?raw';\nimport DataGridResizableColumnSourceRaw from './datagrid-resizable-column.story?raw';\nimport DataGridRuleBasedStylingSourceRaw from './datagrid-rule-based-styling.story?raw';\nimport DataGridRuleBasedStylingDateTimeSourceRaw from './datagrid-rule-based-styling-datetime.story?raw';\nimport DataGridSearchableSourceRaw from './datagrid-search-and-filters.stories?raw';\nimport DataGridSelectableSourceRaw from './datagrid-selectable.story?raw';\nimport DataGridSimpleSourceRaw from './datagrid-simple.story?raw';\nimport DataGridSingleSelectableSourceRaw from './datagrid-single-selectable.story?raw';\nimport DataGridSkeletonLoadingSourceRaw from './datagrid-skeleton-loading.story?raw';\nimport DataGridSortableSourceRaw from './datagrid-sortable.story?raw';\nimport DataGridUsingEditableCellsSourceRaw from './datagrid-using-editable-cells.story?raw';\nimport DataGridVirtualizationSourceRaw from './datagrid-virtualization.story?raw';\n\nexport const DataGridCustomCellWithStyleRulesSource = removeLicenseHeader(\n DataGridCustomCellWithStyleRulesSourceRaw,\n);\nexport const DataGridRuleBasedStylingSource = removeLicenseHeader(\n DataGridRuleBasedStylingSourceRaw,\n);\nexport const DataGridSimpleSource = removeLicenseHeader(\n DataGridSimpleSourceRaw,\n);\nexport const DataGridCompactModeSource = removeLicenseHeader(\n DataGridCompactModeSourceRaw,\n);\nexport const DataGridSortableSource = removeLicenseHeader(\n DataGridSortableSourceRaw,\n);\nexport const DataGridSelectableSource = removeLicenseHeader(\n DataGridSelectableSourceRaw,\n);\nexport const DataGridSearchableSource = removeLicenseHeader(\n DataGridSearchableSourceRaw,\n);\nexport const DataGridInDialogSource = removeLicenseHeader(\n DataGridInDialogSourceRaw,\n);\nexport const DataGridKitchenSinkSource = removeLicenseHeader(\n DataGridKitchenSinkSourceRaw,\n);\nexport const DataGridVirtualizationSource = removeLicenseHeader(\n DataGridVirtualizationSourceRaw,\n);\nexport const DataGridSkeletonLoadingSource = removeLicenseHeader(\n DataGridSkeletonLoadingSourceRaw,\n);\nexport const DataGridPlaceholderStatesSource = removeLicenseHeader(\n DataGridPlaceholderStatesSourceRaw,\n);\nexport const DataGridResizableColumnSource = removeLicenseHeader(\n DataGridResizableColumnSourceRaw,\n);\nexport const DataGridColumnFilteringSource = removeLicenseHeader(\n DataGridColumnFilteringSourceRaw,\n);\nexport const DataGridComponentOverridingSource = removeLicenseHeader(\n DataGridComponentOverridingSourceRaw,\n);\nexport const DataGridKeyboardNavigationSource = removeLicenseHeader(\n DataGridKeyboardNavigationSourceRaw,\n);\nexport const DataGridPercentageWidthColumnsSource = removeLicenseHeader(\n DataGridPercentageWidthColumnsSourceRaw,\n);\nexport const DataGridPinnedColumnsSource = removeLicenseHeader(\n DataGridPinnedColumnsSourceRaw,\n);\nexport const DataGridNoPaginationTableSource = removeLicenseHeader(\n DataGridNoPaginationTableRaw,\n);\nexport const DataGridSingleSelectableSource = removeLicenseHeader(\n DataGridSingleSelectableSourceRaw,\n);\nexport const DataGridUsingEditableCellsSource = removeLicenseHeader(\n DataGridUsingEditableCellsSourceRaw,\n);\nexport const DataGridRuleBasedStylingDateTimeSource = removeLicenseHeader(\n DataGridRuleBasedStylingDateTimeSourceRaw,\n);\n"]}
|
|
@@ -19,17 +19,7 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import { color, rgbToHex, validHex } from '@uiw/react-color';
|
|
22
|
-
|
|
23
|
-
function getWeight(startValue, endValue, value) {
|
|
24
|
-
return (value - startValue) / (endValue - startValue);
|
|
25
|
-
}
|
|
26
|
-
function lerpColor(startColor, endColor, weight) {
|
|
27
|
-
return {
|
|
28
|
-
b: Math.round(startColor.b * (1 - weight) + endColor.b * weight),
|
|
29
|
-
g: Math.round(startColor.g * (1 - weight) + endColor.g * weight),
|
|
30
|
-
r: Math.round(startColor.r * (1 - weight) + endColor.r * weight),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
22
|
+
import { getWeight, lerpColor, parseDateString, parseTimeString, } from '../../_generated/style-rules';
|
|
33
23
|
function getInterpolatedColor(colorRange, rowData, converters) {
|
|
34
24
|
const { onColumn, minValue, minColor, maxValue, maxColor, midValue, midColor, } = colorRange;
|
|
35
25
|
if (!validHex(minColor) || !validHex(maxColor)) {
|
|
@@ -115,6 +105,12 @@ function resolveValue(value, rowData, converters) {
|
|
|
115
105
|
}
|
|
116
106
|
return null;
|
|
117
107
|
}
|
|
108
|
+
if (typeof value === 'object' && value !== null && 'datetime' in value) {
|
|
109
|
+
return parseDateString(value.datetime);
|
|
110
|
+
}
|
|
111
|
+
if (typeof value === 'object' && value !== null && 'time' in value) {
|
|
112
|
+
return parseTimeString(value.time);
|
|
113
|
+
}
|
|
118
114
|
return value;
|
|
119
115
|
}
|
|
120
116
|
function safeCompare(left, right, rowData, compareFn, converters) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/evaluate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,EAAiB,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAY5E,4FAA4F;AAE5F,SAAS,SAAS,CAChB,UAAkB,EAClB,QAAgB,EAChB,KAAa;IAEb,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,SAAS,CAChB,UAAoB,EACpB,QAAkB,EAClB,MAAc;IAEd,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC;QAChE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC;QAChE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC;KACjE,CAAC;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,CAAC;QACtC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,KAAgC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;YACtD,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAChD,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAA0B,EAC1B,OAAgC,EAChC,QAAgB,EAChB,UAA6C;IAE7C,MAAM,EAAE,UAAU,EAAE,GAAG,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { color, type RgbColor, rgbToHex, validHex } from '@uiw/react-color';\n\nimport {\n type DataGridCellStyle,\n type DataGridColorRange,\n type DataGridStyleRule,\n type DataGridStyleRuleLiteral,\n type DataGridStyleRuleOperand,\n type DataGridStyleRuleValueConverters,\n type DataGridStyleRuleWhere,\n} from './types';\n\n// --- Color interpolation (duplicated from react-graph to avoid cross-package coupling) ---\n\nfunction getWeight(\n startValue: number,\n endValue: number,\n value: number,\n): number {\n return (value - startValue) / (endValue - startValue);\n}\n\nfunction lerpColor(\n startColor: RgbColor,\n endColor: RgbColor,\n weight: number,\n): RgbColor {\n return {\n b: Math.round(startColor.b * (1 - weight) + endColor.b * weight),\n g: Math.round(startColor.g * (1 - weight) + endColor.g * weight),\n r: Math.round(startColor.r * (1 - weight) + endColor.r * weight),\n };\n}\n\nfunction getInterpolatedColor(\n colorRange: DataGridColorRange,\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): string | null {\n const {\n onColumn,\n minValue,\n minColor,\n maxValue,\n maxColor,\n midValue,\n midColor,\n } = colorRange;\n\n if (!validHex(minColor) || !validHex(maxColor)) {\n return null;\n }\n\n const minRgb = color(minColor).rgb;\n const maxRgb = color(maxColor).rgb;\n const actualMinValue = Math.min(minValue, maxValue);\n const actualMaxValue = Math.max(minValue, maxValue);\n\n let midRgb: RgbColor | undefined = undefined;\n if (midValue !== undefined && midColor !== undefined) {\n const isMidInRange =\n actualMinValue <= midValue && midValue <= actualMaxValue;\n if (!isMidInRange || !validHex(midColor)) {\n return null;\n }\n midRgb = color(midColor).rgb;\n }\n\n const rawValue = rowData[onColumn];\n let numericValue: number | null = null;\n if (typeof rawValue === 'number') {\n numericValue = Number.isFinite(rawValue) ? rawValue : null;\n } else if (typeof rawValue === 'bigint') {\n const n = Number(rawValue);\n numericValue = Number.isFinite(n) ? n : null;\n } else if (rawValue instanceof Date) {\n const ts = rawValue.getTime();\n numericValue = Number.isFinite(ts) ? ts : null;\n } else {\n const converter = converters?.[onColumn];\n if (converter !== undefined) {\n const converted = converter(rawValue);\n if (typeof converted === 'number') {\n numericValue = Number.isFinite(converted) ? converted : null;\n }\n }\n }\n if (numericValue === null) {\n return null;\n }\n\n const clampedValue = Math.max(\n actualMinValue,\n Math.min(actualMaxValue, numericValue),\n );\n\n let rgb: RgbColor;\n\n if (midRgb !== undefined && midValue !== undefined) {\n const t = getWeight(minValue, midValue, clampedValue);\n const isBetweenMinAndMid = t <= 1;\n if (isBetweenMinAndMid) {\n rgb = lerpColor(minRgb, midRgb, t);\n } else {\n const t2 = getWeight(midValue, maxValue, clampedValue);\n rgb = lerpColor(midRgb, maxRgb, t2);\n }\n } else {\n const t = getWeight(minValue, maxValue, clampedValue);\n rgb = lerpColor(minRgb, maxRgb, t);\n }\n\n return rgbToHex(rgb);\n}\n\n// --- Where clause evaluation ---\n\ntype Ternary = boolean | null;\n\nfunction resolveValue(\n value: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): DataGridStyleRuleLiteral {\n if (typeof value === 'object' && value !== null && 'column' in value) {\n const cellVal = rowData[value.column];\n if (cellVal === undefined) {\n return null;\n }\n if (\n typeof cellVal === 'string' ||\n typeof cellVal === 'number' ||\n typeof cellVal === 'boolean'\n ) {\n return cellVal;\n }\n if (typeof cellVal === 'bigint') {\n return Number(cellVal);\n }\n if (cellVal instanceof Date) {\n const ts = cellVal.getTime();\n return isNaN(ts) ? null : ts;\n }\n const converter = converters?.[value.column];\n if (converter !== undefined) {\n return converter(cellVal);\n }\n return null;\n }\n return value;\n}\n\nfunction safeCompare(\n left: DataGridStyleRuleOperand,\n right: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n compareFn: (\n a: NonNullable<DataGridStyleRuleLiteral>,\n b: NonNullable<DataGridStyleRuleLiteral>,\n ) => boolean,\n converters?: DataGridStyleRuleValueConverters,\n): Ternary {\n const leftVal = resolveValue(left, rowData, converters);\n const rightVal = resolveValue(right, rowData, converters);\n if (leftVal === null || rightVal === null) {\n return null;\n }\n return compareFn(leftVal, rightVal);\n}\n\nfunction safeStringCompare(\n left: DataGridStyleRuleOperand,\n right: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n compareFn: (a: string, b: string) => boolean,\n converters?: DataGridStyleRuleValueConverters,\n): Ternary {\n const leftVal = resolveValue(left, rowData, converters);\n const rightVal = resolveValue(right, rowData, converters);\n if (\n leftVal === null ||\n rightVal === null ||\n typeof leftVal !== 'string' ||\n typeof rightVal !== 'string'\n ) {\n return null;\n }\n return compareFn(leftVal, rightVal);\n}\n\nfunction evaluateWhere(\n rowData: Record<string, unknown>,\n where?: DataGridStyleRuleWhere,\n converters?: DataGridStyleRuleValueConverters,\n): Ternary {\n if (!where) {\n return true;\n }\n\n if ('equal' in where) {\n const [left, right] = where.equal;\n const leftVal = resolveValue(left, rowData, converters);\n const rightVal = resolveValue(right, rowData, converters);\n if (leftVal === null || rightVal === null) {\n return null;\n }\n return leftVal === rightVal;\n }\n\n if ('not' in where) {\n const isMatch = evaluateWhere(rowData, where.not, converters);\n return isMatch === null ? null : !isMatch;\n }\n\n if ('lessThan' in where) {\n return safeCompare(\n where.lessThan[0],\n where.lessThan[1],\n rowData,\n (a, b) => a < b,\n converters,\n );\n }\n\n if ('lessThanOrEqual' in where) {\n return safeCompare(\n where.lessThanOrEqual[0],\n where.lessThanOrEqual[1],\n rowData,\n (a, b) => a <= b,\n converters,\n );\n }\n\n if ('greaterThan' in where) {\n return safeCompare(\n where.greaterThan[0],\n where.greaterThan[1],\n rowData,\n (a, b) => a > b,\n converters,\n );\n }\n\n if ('greaterThanOrEqual' in where) {\n return safeCompare(\n where.greaterThanOrEqual[0],\n where.greaterThanOrEqual[1],\n rowData,\n (a, b) => a >= b,\n converters,\n );\n }\n\n if ('contains' in where) {\n return safeStringCompare(\n where.contains[0],\n where.contains[1],\n rowData,\n (a, b) => a.includes(b),\n converters,\n );\n }\n\n if ('startsWith' in where) {\n return safeStringCompare(\n where.startsWith[0],\n where.startsWith[1],\n rowData,\n (a, b) => a.startsWith(b),\n converters,\n );\n }\n\n if ('endsWith' in where) {\n return safeStringCompare(\n where.endsWith[0],\n where.endsWith[1],\n rowData,\n (a, b) => a.endsWith(b),\n converters,\n );\n }\n\n if ('isNull' in where) {\n const value = resolveValue(where.isNull, rowData, converters);\n return value === null;\n }\n\n if ('and' in where) {\n let hasNull = false;\n for (const clause of where.and) {\n const isMatch = evaluateWhere(rowData, clause, converters);\n if (isMatch === false) {\n return false;\n }\n if (isMatch === null) {\n hasNull = true;\n }\n }\n return hasNull ? null : true;\n }\n\n if ('or' in where) {\n let hasNull = false;\n for (const clause of where.or) {\n const isMatch = evaluateWhere(rowData, clause, converters);\n if (isMatch === true) {\n return true;\n }\n if (isMatch === null) {\n hasNull = true;\n }\n }\n return hasNull ? null : false;\n }\n\n return false;\n}\n\n// --- Style resolution ---\n\nfunction resolveAppliedStyle(\n apply: DataGridCellStyle,\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): React.CSSProperties | undefined {\n const result: React.CSSProperties = {};\n let hasStyle = false;\n\n if (apply.color && !apply.color.isDisabled) {\n result.backgroundColor = apply.color.value;\n hasStyle = true;\n }\n\n if (apply.textColor && !apply.textColor.isDisabled) {\n result.color = apply.textColor.value;\n hasStyle = true;\n }\n\n if (apply.colorRange && !apply.colorRange.isDisabled) {\n const interpolated = getInterpolatedColor(\n apply.colorRange,\n rowData,\n converters,\n );\n if (interpolated !== null) {\n result.backgroundColor = interpolated;\n hasStyle = true;\n }\n }\n\n if (apply.textColorRange && !apply.textColorRange.isDisabled) {\n const interpolated = getInterpolatedColor(\n apply.textColorRange,\n rowData,\n converters,\n );\n if (interpolated !== null) {\n result.color = interpolated;\n hasStyle = true;\n }\n }\n\n return hasStyle ? result : undefined;\n}\n\nexport type ComputedDataGridStyles = {\n cellStyles: Record<string, React.CSSProperties | undefined>;\n};\n\ntype PriorityEntry = { value: string; priority: number };\ntype PropPriorityMap = Record<string, PriorityEntry>;\n\n/**\n * Computes styles for all cells in a row based on the given style rules.\n * When a rule's `column` is `null`, its style is applied to every cell.\n *\n * Used internally by hooks, but exported for context-free usage.\n */\nexport function computeDataGridRowStyles(\n rules: DataGridStyleRule[],\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): ComputedDataGridStyles {\n const enabledRules = rules.filter((r) => !r.isDisabled);\n const totalRules = enabledRules.length;\n\n const sortedRules = enabledRules\n .map((rule, index) => {\n if (rule.priority !== undefined && rule.priority < 0) {\n throw new Error(\n `DataGridStyleRule priority must be >= 0, got ${rule.priority}. Negative values are reserved for internal use.`,\n );\n }\n\n return {\n ...rule,\n _order: index,\n _priority: rule.priority ?? index - totalRules,\n };\n })\n .sort((a, b) => {\n if (a._priority !== b._priority) {\n return a._priority - b._priority;\n }\n return a._order - b._order;\n });\n\n const cellPriorityMap: Record<string, PropPriorityMap> = {};\n\n for (const rule of sortedRules) {\n const isMatching = evaluateWhere(rowData, rule.where, converters) === true;\n if (!isMatching) {\n continue;\n }\n\n const style = resolveAppliedStyle(rule.apply, rowData, converters);\n if (!style) {\n continue;\n }\n\n const effectivePriority = rule._priority;\n const affectedColumns =\n rule.column === null ? Object.keys(rowData) : [rule.column];\n\n for (const col of affectedColumns) {\n if (!cellPriorityMap[col]) {\n cellPriorityMap[col] = {};\n }\n for (const [prop, value] of Object.entries(style)) {\n const existing = cellPriorityMap[col][prop];\n if (!existing || effectivePriority >= existing.priority) {\n cellPriorityMap[col][prop] = {\n priority: effectivePriority,\n value: value as string,\n };\n }\n }\n }\n }\n\n const cellStyles: Record<string, React.CSSProperties | undefined> = {};\n for (const [col, propMap] of Object.entries(cellPriorityMap)) {\n const style: React.CSSProperties = {};\n let hasProp = false;\n for (const [prop, entry] of Object.entries(propMap)) {\n (style as Record<string, string>)[prop] = entry.value;\n hasProp = true;\n }\n cellStyles[col] = hasProp ? style : undefined;\n }\n\n return { cellStyles };\n}\n\n/**\n * Evaluate style rules for a single cell.\n * Pure function -- no React context needed.\n *\n * @param rules - Array of style rules to evaluate\n * @param rowData - The row's data as a record (column id -> value)\n * @param columnId - Returns the computed style for this specific cell.\n * @param converters - Optional per-column value converters for complex cell types.\n */\nexport function evaluateDataGridStyleRules(\n rules: DataGridStyleRule[],\n rowData: Record<string, unknown>,\n columnId: string,\n converters?: DataGridStyleRuleValueConverters,\n): React.CSSProperties | undefined {\n const { cellStyles } = computeDataGridRowStyles(rules, rowData, converters);\n return cellStyles[columnId];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/evaluate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,EAAiB,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EACL,SAAS,EACT,SAAS,EACT,eAAe,EACf,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAatC,SAAS,oBAAoB,CAC3B,UAA8B,EAC9B,OAAgC,EAChC,UAA6C;IAE7C,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,GAAG,UAAU,CAAC;IAEf,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC;IACnC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEpD,IAAI,MAAM,GAAyB,SAAS,CAAC;IAC7C,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACrD,MAAM,YAAY,GAChB,cAAc,IAAI,QAAQ,IAAI,QAAQ,IAAI,cAAc,CAAC;QAC3D,IAAI,CAAC,YAAY,IAAI,CAA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7C,MAAM,EAAE,UAAU,EAAE,GAAG,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { color, type RgbColor, rgbToHex, validHex } from '@uiw/react-color';\n\nimport {\n getWeight,\n lerpColor,\n parseDateString,\n parseTimeString,\n} from '../../_generated/style-rules';\nimport {\n type DataGridCellStyle,\n type DataGridColorRange,\n type DataGridDatetimeLiteral,\n type DataGridStyleRule,\n type DataGridStyleRuleLiteral,\n type DataGridStyleRuleOperand,\n type DataGridStyleRuleValueConverters,\n type DataGridStyleRuleWhere,\n type DataGridTimeLiteral,\n} from './types';\n\nfunction getInterpolatedColor(\n colorRange: DataGridColorRange,\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): string | null {\n const {\n onColumn,\n minValue,\n minColor,\n maxValue,\n maxColor,\n midValue,\n midColor,\n } = colorRange;\n\n if (!validHex(minColor) || !validHex(maxColor)) {\n return null;\n }\n\n const minRgb = color(minColor).rgb;\n const maxRgb = color(maxColor).rgb;\n const actualMinValue = Math.min(minValue, maxValue);\n const actualMaxValue = Math.max(minValue, maxValue);\n\n let midRgb: RgbColor | undefined = undefined;\n if (midValue !== undefined && midColor !== undefined) {\n const isMidInRange =\n actualMinValue <= midValue && midValue <= actualMaxValue;\n if (!isMidInRange || !validHex(midColor)) {\n return null;\n }\n midRgb = color(midColor).rgb;\n }\n\n const rawValue = rowData[onColumn];\n let numericValue: number | null = null;\n if (typeof rawValue === 'number') {\n numericValue = Number.isFinite(rawValue) ? rawValue : null;\n } else if (typeof rawValue === 'bigint') {\n const n = Number(rawValue);\n numericValue = Number.isFinite(n) ? n : null;\n } else if (rawValue instanceof Date) {\n const ts = rawValue.getTime();\n numericValue = Number.isFinite(ts) ? ts : null;\n } else {\n const converter = converters?.[onColumn];\n if (converter !== undefined) {\n const converted = converter(rawValue);\n if (typeof converted === 'number') {\n numericValue = Number.isFinite(converted) ? converted : null;\n }\n }\n }\n if (numericValue === null) {\n return null;\n }\n\n const clampedValue = Math.max(\n actualMinValue,\n Math.min(actualMaxValue, numericValue),\n );\n\n let rgb: RgbColor;\n\n if (midRgb !== undefined && midValue !== undefined) {\n const t = getWeight(minValue, midValue, clampedValue);\n const isBetweenMinAndMid = t <= 1;\n if (isBetweenMinAndMid) {\n rgb = lerpColor(minRgb, midRgb, t);\n } else {\n const t2 = getWeight(midValue, maxValue, clampedValue);\n rgb = lerpColor(midRgb, maxRgb, t2);\n }\n } else {\n const t = getWeight(minValue, maxValue, clampedValue);\n rgb = lerpColor(minRgb, maxRgb, t);\n }\n\n return rgbToHex(rgb);\n}\n\n// --- Where clause evaluation ---\n\ntype Ternary = boolean | null;\n\nfunction resolveValue(\n value: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): DataGridStyleRuleLiteral {\n if (typeof value === 'object' && value !== null && 'column' in value) {\n const cellVal = rowData[value.column];\n if (cellVal === undefined) {\n return null;\n }\n if (\n typeof cellVal === 'string' ||\n typeof cellVal === 'number' ||\n typeof cellVal === 'boolean'\n ) {\n return cellVal;\n }\n if (typeof cellVal === 'bigint') {\n return Number(cellVal);\n }\n if (cellVal instanceof Date) {\n const ts = cellVal.getTime();\n return isNaN(ts) ? null : ts;\n }\n const converter = converters?.[value.column];\n if (converter !== undefined) {\n return converter(cellVal);\n }\n return null;\n }\n if (typeof value === 'object' && value !== null && 'datetime' in value) {\n return parseDateString((value as DataGridDatetimeLiteral).datetime);\n }\n if (typeof value === 'object' && value !== null && 'time' in value) {\n return parseTimeString((value as DataGridTimeLiteral).time);\n }\n return value as DataGridStyleRuleLiteral;\n}\n\nfunction safeCompare(\n left: DataGridStyleRuleOperand,\n right: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n compareFn: (\n a: NonNullable<DataGridStyleRuleLiteral>,\n b: NonNullable<DataGridStyleRuleLiteral>,\n ) => boolean,\n converters?: DataGridStyleRuleValueConverters,\n): Ternary {\n const leftVal = resolveValue(left, rowData, converters);\n const rightVal = resolveValue(right, rowData, converters);\n if (leftVal === null || rightVal === null) {\n return null;\n }\n return compareFn(leftVal, rightVal);\n}\n\nfunction safeStringCompare(\n left: DataGridStyleRuleOperand,\n right: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n compareFn: (a: string, b: string) => boolean,\n converters?: DataGridStyleRuleValueConverters,\n): Ternary {\n const leftVal = resolveValue(left, rowData, converters);\n const rightVal = resolveValue(right, rowData, converters);\n if (\n leftVal === null ||\n rightVal === null ||\n typeof leftVal !== 'string' ||\n typeof rightVal !== 'string'\n ) {\n return null;\n }\n return compareFn(leftVal, rightVal);\n}\n\nfunction evaluateWhere(\n rowData: Record<string, unknown>,\n where?: DataGridStyleRuleWhere,\n converters?: DataGridStyleRuleValueConverters,\n): Ternary {\n if (!where) {\n return true;\n }\n\n if ('equal' in where) {\n const [left, right] = where.equal;\n const leftVal = resolveValue(left, rowData, converters);\n const rightVal = resolveValue(right, rowData, converters);\n if (leftVal === null || rightVal === null) {\n return null;\n }\n return leftVal === rightVal;\n }\n\n if ('not' in where) {\n const isMatch = evaluateWhere(rowData, where.not, converters);\n return isMatch === null ? null : !isMatch;\n }\n\n if ('lessThan' in where) {\n return safeCompare(\n where.lessThan[0],\n where.lessThan[1],\n rowData,\n (a, b) => a < b,\n converters,\n );\n }\n\n if ('lessThanOrEqual' in where) {\n return safeCompare(\n where.lessThanOrEqual[0],\n where.lessThanOrEqual[1],\n rowData,\n (a, b) => a <= b,\n converters,\n );\n }\n\n if ('greaterThan' in where) {\n return safeCompare(\n where.greaterThan[0],\n where.greaterThan[1],\n rowData,\n (a, b) => a > b,\n converters,\n );\n }\n\n if ('greaterThanOrEqual' in where) {\n return safeCompare(\n where.greaterThanOrEqual[0],\n where.greaterThanOrEqual[1],\n rowData,\n (a, b) => a >= b,\n converters,\n );\n }\n\n if ('contains' in where) {\n return safeStringCompare(\n where.contains[0],\n where.contains[1],\n rowData,\n (a, b) => a.includes(b),\n converters,\n );\n }\n\n if ('startsWith' in where) {\n return safeStringCompare(\n where.startsWith[0],\n where.startsWith[1],\n rowData,\n (a, b) => a.startsWith(b),\n converters,\n );\n }\n\n if ('endsWith' in where) {\n return safeStringCompare(\n where.endsWith[0],\n where.endsWith[1],\n rowData,\n (a, b) => a.endsWith(b),\n converters,\n );\n }\n\n if ('isNull' in where) {\n const value = resolveValue(where.isNull, rowData, converters);\n return value === null;\n }\n\n if ('and' in where) {\n let hasNull = false;\n for (const clause of where.and) {\n const isMatch = evaluateWhere(rowData, clause, converters);\n if (isMatch === false) {\n return false;\n }\n if (isMatch === null) {\n hasNull = true;\n }\n }\n return hasNull ? null : true;\n }\n\n if ('or' in where) {\n let hasNull = false;\n for (const clause of where.or) {\n const isMatch = evaluateWhere(rowData, clause, converters);\n if (isMatch === true) {\n return true;\n }\n if (isMatch === null) {\n hasNull = true;\n }\n }\n return hasNull ? null : false;\n }\n\n return false;\n}\n\n// --- Style resolution ---\n\nfunction resolveAppliedStyle(\n apply: DataGridCellStyle,\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): React.CSSProperties | undefined {\n const result: React.CSSProperties = {};\n let hasStyle = false;\n\n if (apply.color && !apply.color.isDisabled) {\n result.backgroundColor = apply.color.value;\n hasStyle = true;\n }\n\n if (apply.textColor && !apply.textColor.isDisabled) {\n result.color = apply.textColor.value;\n hasStyle = true;\n }\n\n if (apply.colorRange && !apply.colorRange.isDisabled) {\n const interpolated = getInterpolatedColor(\n apply.colorRange,\n rowData,\n converters,\n );\n if (interpolated !== null) {\n result.backgroundColor = interpolated;\n hasStyle = true;\n }\n }\n\n if (apply.textColorRange && !apply.textColorRange.isDisabled) {\n const interpolated = getInterpolatedColor(\n apply.textColorRange,\n rowData,\n converters,\n );\n if (interpolated !== null) {\n result.color = interpolated;\n hasStyle = true;\n }\n }\n\n return hasStyle ? result : undefined;\n}\n\nexport type ComputedDataGridStyles = {\n cellStyles: Record<string, React.CSSProperties | undefined>;\n};\n\ntype PriorityEntry = { value: string; priority: number };\ntype PropPriorityMap = Record<string, PriorityEntry>;\n\n/**\n * Computes styles for all cells in a row based on the given style rules.\n * When a rule's `column` is `null`, its style is applied to every cell.\n *\n * Used internally by hooks, but exported for context-free usage.\n */\nexport function computeDataGridRowStyles(\n rules: DataGridStyleRule[],\n rowData: Record<string, unknown>,\n converters?: DataGridStyleRuleValueConverters,\n): ComputedDataGridStyles {\n const enabledRules = rules.filter((r) => !r.isDisabled);\n const totalRules = enabledRules.length;\n\n const sortedRules = enabledRules\n .map((rule, index) => {\n if (rule.priority !== undefined && rule.priority < 0) {\n throw new Error(\n `DataGridStyleRule priority must be >= 0, got ${rule.priority}. Negative values are reserved for internal use.`,\n );\n }\n\n return {\n ...rule,\n _order: index,\n _priority: rule.priority ?? index - totalRules,\n };\n })\n .sort((a, b) => {\n if (a._priority !== b._priority) {\n return a._priority - b._priority;\n }\n return a._order - b._order;\n });\n\n const cellPriorityMap: Record<string, PropPriorityMap> = {};\n\n for (const rule of sortedRules) {\n const isMatching = evaluateWhere(rowData, rule.where, converters) === true;\n if (!isMatching) {\n continue;\n }\n\n const style = resolveAppliedStyle(rule.apply, rowData, converters);\n if (!style) {\n continue;\n }\n\n const effectivePriority = rule._priority;\n const affectedColumns =\n rule.column === null ? Object.keys(rowData) : [rule.column];\n\n for (const col of affectedColumns) {\n if (!cellPriorityMap[col]) {\n cellPriorityMap[col] = {};\n }\n for (const [prop, value] of Object.entries(style)) {\n const existing = cellPriorityMap[col][prop];\n if (!existing || effectivePriority >= existing.priority) {\n cellPriorityMap[col][prop] = {\n priority: effectivePriority,\n value: value as string,\n };\n }\n }\n }\n }\n\n const cellStyles: Record<string, React.CSSProperties | undefined> = {};\n for (const [col, propMap] of Object.entries(cellPriorityMap)) {\n const style: React.CSSProperties = {};\n let hasProp = false;\n for (const [prop, entry] of Object.entries(propMap)) {\n (style as Record<string, string>)[prop] = entry.value;\n hasProp = true;\n }\n cellStyles[col] = hasProp ? style : undefined;\n }\n\n return { cellStyles };\n}\n\n/**\n * Evaluate style rules for a single cell.\n * Pure function -- no React context needed.\n *\n * @param rules - Array of style rules to evaluate\n * @param rowData - The row's data as a record (column id -> value)\n * @param columnId - Returns the computed style for this specific cell.\n * @param converters - Optional per-column value converters for complex cell types.\n */\nexport function evaluateDataGridStyleRules(\n rules: DataGridStyleRule[],\n rowData: Record<string, unknown>,\n columnId: string,\n converters?: DataGridStyleRuleValueConverters,\n): React.CSSProperties | undefined {\n const { cellStyles } = computeDataGridRowStyles(rules, rowData, converters);\n return cellStyles[columnId];\n}\n"]}
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
export { evaluateDataGridStyleRules } from './evaluate';
|
|
22
22
|
export { useDataGridCellStyle } from './hooks';
|
|
23
23
|
// TODO v5: remove schema exports
|
|
24
|
-
export { DataGridCellStyleSchema, DataGridColorRangeSchema, DataGridColumnRefSchema, DataGridDisableableColorSchema, DataGridStyleRuleLiteralSchema, DataGridStyleRuleOperandSchema, DataGridStyleRuleSchema, DataGridStyleRuleWhereSchema, } from './types';
|
|
24
|
+
export { DataGridCellStyleSchema, DataGridColorRangeSchema, DataGridColumnRefSchema, DataGridDatetimeLiteralSchema, DataGridDisableableColorSchema, DataGridStyleRuleLiteralSchema, DataGridStyleRuleOperandSchema, DataGridStyleRuleSchema, DataGridStyleRuleWhereSchema, DataGridTimeLiteralSchema, } from './types';
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,iCAAiC;AACjC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,iCAAiC;AACjC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { evaluateDataGridStyleRules } from './evaluate';\nexport { useDataGridCellStyle } from './hooks';\n// TODO v5: remove schema exports\nexport {\n DataGridCellStyleSchema,\n DataGridColorRangeSchema,\n DataGridColumnRefSchema,\n DataGridDatetimeLiteralSchema,\n DataGridDisableableColorSchema,\n DataGridStyleRuleLiteralSchema,\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleSchema,\n DataGridStyleRuleWhereSchema,\n DataGridTimeLiteralSchema,\n} from './types';\nexport type {\n DataGridCellStyle,\n DataGridColorRange,\n DataGridColumnRef,\n DataGridDatetimeLiteral,\n DataGridDisableableColor,\n DataGridStyleRuleLiteral,\n DataGridStyleRuleOperand,\n DataGridStyleRule,\n DataGridStyleRuleWhere,\n DataGridStyleRuleValueConverter,\n DataGridStyleRuleValueConverters,\n DataGridTimeLiteral,\n} from './types';\n"]}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import { z } from 'zod';
|
|
22
|
+
import { DatetimeLiteralSchema, TimeLiteralSchema, } from '../../_generated/style-rules';
|
|
22
23
|
/*
|
|
23
24
|
* Style types defined in Zod, so that we can use the schemas to generate JSON Schema.
|
|
24
25
|
* This is useful for generating documentation, importing and for future integration into editors.
|
|
@@ -32,9 +33,32 @@ export const DataGridStyleRuleLiteralSchema = z.union([
|
|
|
32
33
|
]);
|
|
33
34
|
/** A reference to a column whose cell value is resolved at evaluation time. */
|
|
34
35
|
export const DataGridColumnRefSchema = z.object({ column: z.string() });
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* An ISO 8601 or RFC 9557 datetime literal that resolves to a Unix millisecond
|
|
38
|
+
* timestamp at evaluation time. Wraps the shared `DatetimeLiteralSchema` with a
|
|
39
|
+
* DataGrid-specific name. Supported formats:
|
|
40
|
+
* - RFC 9557 with IANA timezone: `"2024-06-15T14:00:00[Europe/Stockholm]"` (offset
|
|
41
|
+
* inferred) or `"2024-06-15T14:00:00+02:00[Europe/Stockholm]"` (offset explicit)
|
|
42
|
+
* - UTC or offset datetime: `"2024-01-01T00:00:00Z"`, `"2024-01-01T00:00:00+02:00"`
|
|
43
|
+
* - Plain datetime (treated as UTC): `"2024-01-01T14:30:00"`
|
|
44
|
+
* - Date-only (treated as UTC midnight): `"2024-01-01"`
|
|
45
|
+
*
|
|
46
|
+
* Unzoned datetimes without `Z` or an offset are treated as UTC wall-clock time.
|
|
47
|
+
*/
|
|
48
|
+
export const DataGridDatetimeLiteralSchema = DatetimeLiteralSchema;
|
|
49
|
+
/**
|
|
50
|
+
* An ISO 8601 time literal that resolves to milliseconds since UTC midnight at
|
|
51
|
+
* evaluation time. Wraps the shared `TimeLiteralSchema` with a DataGrid-specific
|
|
52
|
+
* name. Supported formats:
|
|
53
|
+
* - Local time (treated as UTC): `"14:30:00"`, `"14:30:00.500"`
|
|
54
|
+
* - Offset time (UTC-normalised): `"14:30:00+02:00"`
|
|
55
|
+
*/
|
|
56
|
+
export const DataGridTimeLiteralSchema = TimeLiteralSchema;
|
|
57
|
+
/** An operand in a style-rule where clause -- either a literal value, a datetime literal, a time literal, or a column reference. */
|
|
36
58
|
export const DataGridStyleRuleOperandSchema = z.union([
|
|
37
59
|
DataGridColumnRefSchema,
|
|
60
|
+
DataGridDatetimeLiteralSchema,
|
|
61
|
+
DataGridTimeLiteralSchema,
|
|
38
62
|
DataGridStyleRuleLiteralSchema,
|
|
39
63
|
]);
|
|
40
64
|
export const DataGridStyleRuleWhereSchema = z.lazy(() => z.union([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AAEH,mFA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ACnF,KAAK,EAAE,4BAA4B,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { z } from 'zod';\n\n/*\n * Style types defined in Zod, so that we can use the schemas to generate JSON Schema.\n * This is useful for generating documentation, importing and for future integration into editors.\n */\n\n/** A scalar literal that can appear as an operand in a style-rule where clause. */\nexport const DataGridStyleRuleLiteralSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n]);\nexport type DataGridStyleRuleLiteral = z.infer<\n typeof DataGridStyleRuleLiteralSchema\n>;\n\n/** A reference to a column whose cell value is resolved at evaluation time. */\nexport const DataGridColumnRefSchema = z.object({ column: z.string() });\nexport type DataGridColumnRef = z.infer<typeof DataGridColumnRefSchema>;\n\n/** An operand in a style-rule where clause -- either a literal value or a column reference. */\nexport const DataGridStyleRuleOperandSchema = z.union([\n DataGridColumnRefSchema,\n DataGridStyleRuleLiteralSchema,\n]);\nexport type DataGridStyleRuleOperand = z.infer<\n typeof DataGridStyleRuleOperandSchema\n>;\n\n/**\n * Recursive WHERE clause for conditional expressions.\n * Inspired by the graph visualization style rule system but adapted for tabular data.\n *\n * The type is manually defined for the export, since zod doesn't support\n * exporting inferred recursive types.\n */\nexport type DataGridStyleRuleWhere =\n | { not: DataGridStyleRuleWhere }\n | { and: DataGridStyleRuleWhere[] }\n | { or: DataGridStyleRuleWhere[] }\n | { equal: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { lessThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { lessThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { greaterThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { greaterThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { contains: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { startsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { endsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { isNull: DataGridStyleRuleOperand };\n\nexport const DataGridStyleRuleWhereSchema: z.ZodType<DataGridStyleRuleWhere> =\n z.lazy(() =>\n z.union([\n z.object({ not: DataGridStyleRuleWhereSchema }),\n z.object({ and: z.array(DataGridStyleRuleWhereSchema) }),\n z.object({ or: z.array(DataGridStyleRuleWhereSchema) }),\n z.object({\n equal: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n lessThan: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n lessThanOrEqual: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n greaterThan: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n greaterThanOrEqual: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n contains: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n startsWith: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n endsWith: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({ isNull: DataGridStyleRuleOperandSchema }),\n ]),\n );\n\n/**\n * Gradient coloring based on a continuous numeric column value.\n * Colors should be hex strings (#rrggbb).\n * If the column value is missing or non-numeric, the colorRange is ignored.\n */\nexport const DataGridColorRangeSchema = z.object({\n /** Disable this color range without removing it. */\n isDisabled: z.boolean().optional(),\n /** Hex color (#rrggbb) at the maximum value. */\n maxColor: z.string(),\n /** The high end of the numeric range. Values above this clamp to maxColor. */\n maxValue: z.number(),\n /** Hex color (#rrggbb) at the optional mid-point for a 3-stop gradient. */\n midColor: z.string().optional(),\n /** Optional inflection point between minValue and maxValue for a 3-stop gradient. */\n midValue: z.number().optional(),\n /** Hex color (#rrggbb) at the minimum value. */\n minColor: z.string(),\n /** The low end of the numeric range. Values below this clamp to minColor. */\n minValue: z.number(),\n /** The column whose numeric value drives the interpolation. */\n onColumn: z.string(),\n});\nexport type DataGridColorRange = z.infer<typeof DataGridColorRangeSchema>;\n\n/** A disable-able static color value. */\nexport const DataGridDisableableColorSchema = z.object({\n /** Disable this style without removing it. */\n isDisabled: z.boolean().optional(),\n /** The CSS color value (e.g. '#fee2e2'). */\n value: z.string(),\n});\nexport type DataGridDisableableColor = z.infer<\n typeof DataGridDisableableColorSchema\n>;\n\n/** Visual properties that a style rule can apply to a cell or row. */\nexport const DataGridCellStyleSchema = z.object({\n /** CSS background color / cell fill (e.g. '#fee2e2'). Matches the graph `Style.color`. */\n color: DataGridDisableableColorSchema.optional(),\n /** Gradient color interpolation applied to the cell fill. Matches the graph `Style.colorRange`. */\n colorRange: DataGridColorRangeSchema.optional(),\n /** CSS text color (e.g. '#991b1b'). Grid-only; no graph equivalent. */\n textColor: DataGridDisableableColorSchema.optional(),\n /** Gradient color interpolation applied to the text color. Grid-only; no graph equivalent. */\n textColorRange: DataGridColorRangeSchema.optional(),\n});\nexport type DataGridCellStyle = z.infer<typeof DataGridCellStyleSchema>;\n\n/**\n * metaData is an free-form object that can be used to store additional information about a style rule.\n * The data is not taken into account when evaluating the rule.\n */\nconst metaDataSchema = z.record(z.string(), z.unknown());\n\n/**\n * A function that converts a complex or non-scalar cell value into a\n * `DataGridStyleRuleLiteral` so it can participate in where-clause evaluation\n * and color-range interpolation.\n *\n * The function receives the raw cell value (`unknown`) and must return a scalar\n * (`string | number | boolean | null`). Return `null` to signal that the value\n * is missing or cannot be represented.\n *\n * Note: converter functions are TypeScript-only — they cannot be serialized as\n * JSON, so no Zod schema is provided.\n */\nexport type DataGridStyleRuleValueConverter = (\n value: unknown,\n) => DataGridStyleRuleLiteral;\n\n/**\n * A map of column id → converter function.\n * Pass this as the `styleRuleValueConverters` prop on `DataGrid` to teach the\n * style-rule engine how to interpret complex cell values for specific columns.\n *\n * @example\n * ```ts\n * const converters: DataGridStyleRuleValueConverters = {\n * priority: (v) => {\n * const s = v as { min: number; max: number };\n * return s.max - s.min;\n * },\n * };\n * ```\n */\nexport type DataGridStyleRuleValueConverters = Record<\n string,\n DataGridStyleRuleValueConverter\n>;\n\n/** A single declarative rule that conditionally applies styles to DataGrid cells. */\nexport const DataGridStyleRuleSchema = z.object({\n /** Style properties to apply when the rule matches. */\n apply: DataGridCellStyleSchema,\n /** Which column this rule targets. Set to null to apply styles to all columns (row-level effect). */\n column: z.string().nullable(),\n /** Disable this rule without removing it. */\n isDisabled: z.boolean().optional(),\n /** Additional metadata about the rule. */\n metaData: metaDataSchema.optional(),\n /** Higher priority rules are applied later (override lower). Must be >= 0; negative values are reserved for internal use. Rules without explicit priority preserve their array order but are always applied before rules with explicit priority. */\n priority: z.number().nonnegative().optional(),\n /** Condition to evaluate. If omitted, rule always applies to matched column(s). */\n where: DataGridStyleRuleWhereSchema.optional(),\n});\nexport type DataGridStyleRule = z.infer<typeof DataGridStyleRuleSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE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CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,6CAA6C;IAC7C,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC,0CAA0C;IAC1C,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;IACnC,oPAAoP;IACpP,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IAC7C,mFAAmF;IACnF,KAAK,EAAE,4BAA4B,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { z } from 'zod';\n\nimport {\n DatetimeLiteralSchema,\n TimeLiteralSchema,\n} from '../../_generated/style-rules';\n\n/*\n * Style types defined in Zod, so that we can use the schemas to generate JSON Schema.\n * This is useful for generating documentation, importing and for future integration into editors.\n */\n\n/** A scalar literal that can appear as an operand in a style-rule where clause. */\nexport const DataGridStyleRuleLiteralSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n]);\nexport type DataGridStyleRuleLiteral = z.infer<\n typeof DataGridStyleRuleLiteralSchema\n>;\n\n/** A reference to a column whose cell value is resolved at evaluation time. */\nexport const DataGridColumnRefSchema = z.object({ column: z.string() });\nexport type DataGridColumnRef = z.infer<typeof DataGridColumnRefSchema>;\n\n/**\n * An ISO 8601 or RFC 9557 datetime literal that resolves to a Unix millisecond\n * timestamp at evaluation time. Wraps the shared `DatetimeLiteralSchema` with a\n * DataGrid-specific name. Supported formats:\n * - RFC 9557 with IANA timezone: `\"2024-06-15T14:00:00[Europe/Stockholm]\"` (offset\n * inferred) or `\"2024-06-15T14:00:00+02:00[Europe/Stockholm]\"` (offset explicit)\n * - UTC or offset datetime: `\"2024-01-01T00:00:00Z\"`, `\"2024-01-01T00:00:00+02:00\"`\n * - Plain datetime (treated as UTC): `\"2024-01-01T14:30:00\"`\n * - Date-only (treated as UTC midnight): `\"2024-01-01\"`\n *\n * Unzoned datetimes without `Z` or an offset are treated as UTC wall-clock time.\n */\nexport const DataGridDatetimeLiteralSchema = DatetimeLiteralSchema;\nexport type DataGridDatetimeLiteral = z.infer<\n typeof DataGridDatetimeLiteralSchema\n>;\n\n/**\n * An ISO 8601 time literal that resolves to milliseconds since UTC midnight at\n * evaluation time. Wraps the shared `TimeLiteralSchema` with a DataGrid-specific\n * name. Supported formats:\n * - Local time (treated as UTC): `\"14:30:00\"`, `\"14:30:00.500\"`\n * - Offset time (UTC-normalised): `\"14:30:00+02:00\"`\n */\nexport const DataGridTimeLiteralSchema = TimeLiteralSchema;\nexport type DataGridTimeLiteral = z.infer<typeof DataGridTimeLiteralSchema>;\n\n/** An operand in a style-rule where clause -- either a literal value, a datetime literal, a time literal, or a column reference. */\nexport const DataGridStyleRuleOperandSchema = z.union([\n DataGridColumnRefSchema,\n DataGridDatetimeLiteralSchema,\n DataGridTimeLiteralSchema,\n DataGridStyleRuleLiteralSchema,\n]);\nexport type DataGridStyleRuleOperand =\n | DataGridColumnRef\n | DataGridDatetimeLiteral\n | DataGridTimeLiteral\n | DataGridStyleRuleLiteral;\n\n/**\n * Recursive WHERE clause for conditional expressions.\n * Inspired by the graph visualization style rule system but adapted for tabular data.\n *\n * The type is manually defined for the export, since zod doesn't support\n * exporting inferred recursive types.\n */\nexport type DataGridStyleRuleWhere =\n | { not: DataGridStyleRuleWhere }\n | { and: DataGridStyleRuleWhere[] }\n | { or: DataGridStyleRuleWhere[] }\n | { equal: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { lessThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { lessThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { greaterThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { greaterThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { contains: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { startsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { endsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { isNull: DataGridStyleRuleOperand };\n\nexport const DataGridStyleRuleWhereSchema: z.ZodType<DataGridStyleRuleWhere> =\n z.lazy(() =>\n z.union([\n z.object({ not: DataGridStyleRuleWhereSchema }),\n z.object({ and: z.array(DataGridStyleRuleWhereSchema) }),\n z.object({ or: z.array(DataGridStyleRuleWhereSchema) }),\n z.object({\n equal: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n lessThan: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n lessThanOrEqual: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n greaterThan: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n greaterThanOrEqual: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n contains: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n startsWith: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n endsWith: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({ isNull: DataGridStyleRuleOperandSchema }),\n ]),\n );\n\n/**\n * Gradient coloring based on a continuous numeric column value.\n * Colors should be hex strings (#rrggbb).\n * If the column value is missing or non-numeric, the colorRange is ignored.\n */\nexport const DataGridColorRangeSchema = z.object({\n /** Disable this color range without removing it. */\n isDisabled: z.boolean().optional(),\n /** Hex color (#rrggbb) at the maximum value. */\n maxColor: z.string(),\n /** The high end of the numeric range. Values above this clamp to maxColor. */\n maxValue: z.number(),\n /** Hex color (#rrggbb) at the optional mid-point for a 3-stop gradient. */\n midColor: z.string().optional(),\n /** Optional inflection point between minValue and maxValue for a 3-stop gradient. */\n midValue: z.number().optional(),\n /** Hex color (#rrggbb) at the minimum value. */\n minColor: z.string(),\n /** The low end of the numeric range. Values below this clamp to minColor. */\n minValue: z.number(),\n /** The column whose numeric value drives the interpolation. */\n onColumn: z.string(),\n});\nexport type DataGridColorRange = z.infer<typeof DataGridColorRangeSchema>;\n\n/** A disable-able static color value. */\nexport const DataGridDisableableColorSchema = z.object({\n /** Disable this style without removing it. */\n isDisabled: z.boolean().optional(),\n /** The CSS color value (e.g. '#fee2e2'). */\n value: z.string(),\n});\nexport type DataGridDisableableColor = z.infer<\n typeof DataGridDisableableColorSchema\n>;\n\n/** Visual properties that a style rule can apply to a cell or row. */\nexport const DataGridCellStyleSchema = z.object({\n /** CSS background color / cell fill (e.g. '#fee2e2'). Matches the graph `Style.color`. */\n color: DataGridDisableableColorSchema.optional(),\n /** Gradient color interpolation applied to the cell fill. Matches the graph `Style.colorRange`. */\n colorRange: DataGridColorRangeSchema.optional(),\n /** CSS text color (e.g. '#991b1b'). Grid-only; no graph equivalent. */\n textColor: DataGridDisableableColorSchema.optional(),\n /** Gradient color interpolation applied to the text color. Grid-only; no graph equivalent. */\n textColorRange: DataGridColorRangeSchema.optional(),\n});\nexport type DataGridCellStyle = z.infer<typeof DataGridCellStyleSchema>;\n\n/**\n * metaData is an free-form object that can be used to store additional information about a style rule.\n * The data is not taken into account when evaluating the rule.\n */\nconst metaDataSchema = z.record(z.string(), z.unknown());\n\n/**\n * A function that converts a complex or non-scalar cell value into a\n * `DataGridStyleRuleLiteral` so it can participate in where-clause evaluation\n * and color-range interpolation.\n *\n * The function receives the raw cell value (`unknown`) and must return a scalar\n * (`string | number | boolean | null`). Return `null` to signal that the value\n * is missing or cannot be represented.\n *\n * Note: converter functions are TypeScript-only — they cannot be serialized as\n * JSON, so no Zod schema is provided.\n */\nexport type DataGridStyleRuleValueConverter = (\n value: unknown,\n) => DataGridStyleRuleLiteral;\n\n/**\n * A map of column id → converter function.\n * Pass this as the `styleRuleValueConverters` prop on `DataGrid` to teach the\n * style-rule engine how to interpret complex cell values for specific columns.\n *\n * @example\n * ```ts\n * const converters: DataGridStyleRuleValueConverters = {\n * priority: (v) => {\n * const s = v as { min: number; max: number };\n * return s.max - s.min;\n * },\n * };\n * ```\n */\nexport type DataGridStyleRuleValueConverters = Record<\n string,\n DataGridStyleRuleValueConverter\n>;\n\n/** A single declarative rule that conditionally applies styles to DataGrid cells. */\nexport const DataGridStyleRuleSchema = z.object({\n /** Style properties to apply when the rule matches. */\n apply: DataGridCellStyleSchema,\n /** Which column this rule targets. Set to null to apply styles to all columns (row-level effect). */\n column: z.string().nullable(),\n /** Disable this rule without removing it. */\n isDisabled: z.boolean().optional(),\n /** Additional metadata about the rule. */\n metaData: metaDataSchema.optional(),\n /** Higher priority rules are applied later (override lower). Must be >= 0; negative values are reserved for internal use. Rules without explicit priority preserve their array order but are always applied before rules with explicit priority. */\n priority: z.number().nonnegative().optional(),\n /** Condition to evaluate. If omitted, rule always applies to matched column(s). */\n where: DataGridStyleRuleWhereSchema.optional(),\n});\nexport type DataGridStyleRule = z.infer<typeof DataGridStyleRuleSchema>;\n"]}
|
|
@@ -42,12 +42,20 @@ import { Typography } from '../typography';
|
|
|
42
42
|
import { generateTimeOptions } from './generate-time-options';
|
|
43
43
|
import { NeedleTime } from './needle-time';
|
|
44
44
|
import { useKeyboardNavigation, useTimePickerPopover, } from './time-picker-hooks';
|
|
45
|
+
/** Fixed input width per format (only used when the picker is not fluid). */
|
|
46
|
+
const INPUT_WIDTH_BY_FORMAT = {
|
|
47
|
+
'hh:mm': '6rem',
|
|
48
|
+
'hh:mm aa': '9rem',
|
|
49
|
+
'hh:mm:ss': '7.5rem',
|
|
50
|
+
'hh:mm:ss aa': '11rem',
|
|
51
|
+
};
|
|
45
52
|
export const TimePicker = (_a) => {
|
|
46
53
|
var _b, _c, _d;
|
|
47
54
|
var { format = 'hh:mm', isDisabled, isFluid, isReadOnly, isRequired, value, timeInterval = 15, label, onChange, className, onError, style, size = 'medium', errorText, htmlAttributes, floatingStrategy, isPortaled: isPortaledProp, ref } = _a, restProps = __rest(_a, ["format", "isDisabled", "isFluid", "isReadOnly", "isRequired", "value", "timeInterval", "label", "onChange", "className", "onError", "style", "size", "errorText", "htmlAttributes", "floatingStrategy", "isPortaled", "ref"]);
|
|
48
55
|
const [editedInput, setEditedInput] = useState(value);
|
|
49
|
-
const is24Hour = format
|
|
50
|
-
const
|
|
56
|
+
const is24Hour = !format.includes('aa');
|
|
57
|
+
const hasSeconds = format.includes('ss');
|
|
58
|
+
const [inputValue, setInputValue] = useState((_b = value === null || value === void 0 ? void 0 : value.toString(is24Hour, hasSeconds)) !== null && _b !== void 0 ? _b : '');
|
|
51
59
|
const listRef = useRef(null);
|
|
52
60
|
const inputRef = useRef(null);
|
|
53
61
|
useImperativeHandle(ref, () => inputRef.current, []);
|
|
@@ -55,7 +63,7 @@ export const TimePicker = (_a) => {
|
|
|
55
63
|
const [error, setError] = useState(undefined);
|
|
56
64
|
const errorTextId = useId();
|
|
57
65
|
const listboxId = useId();
|
|
58
|
-
const timeOptions = useMemo(() => generateTimeOptions(is24Hour, timeInterval), [is24Hour, timeInterval]);
|
|
66
|
+
const timeOptions = useMemo(() => generateTimeOptions(is24Hour, timeInterval, hasSeconds), [is24Hour, timeInterval, hasSeconds]);
|
|
59
67
|
const { themeClassName } = useNeedleTheme();
|
|
60
68
|
const { isPopoverOpen, setIsPopoverOpen } = useTimePickerPopover(false);
|
|
61
69
|
const { focusedIndex, setFocusedIndex, handleArrowNavigation } = useKeyboardNavigation(listRef, timeOptions.length);
|
|
@@ -69,14 +77,17 @@ export const TimePicker = (_a) => {
|
|
|
69
77
|
'ndl-read-only': isReadOnly,
|
|
70
78
|
'ndl-small': size === 'small',
|
|
71
79
|
};
|
|
72
|
-
const inputWidth = isFluid === true ? '100%' :
|
|
73
|
-
const isValidTime = useCallback((hours, minutes) => {
|
|
80
|
+
const inputWidth = isFluid === true ? '100%' : INPUT_WIDTH_BY_FORMAT[format];
|
|
81
|
+
const isValidTime = useCallback((hours, minutes, seconds) => {
|
|
74
82
|
if (hours > 23 || hours < 0) {
|
|
75
83
|
return false;
|
|
76
84
|
}
|
|
77
85
|
if (minutes > 59 || minutes < 0) {
|
|
78
86
|
return false;
|
|
79
87
|
}
|
|
88
|
+
if (seconds > 59 || seconds < 0) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
80
91
|
return true;
|
|
81
92
|
}, []);
|
|
82
93
|
useEffect(() => {
|
|
@@ -87,8 +98,8 @@ export const TimePicker = (_a) => {
|
|
|
87
98
|
useEffect(() => {
|
|
88
99
|
var _a;
|
|
89
100
|
setEditedInput(value);
|
|
90
|
-
setInputValue((_a = value === null || value === void 0 ? void 0 : value.toString(is24Hour)) !== null && _a !== void 0 ? _a : '');
|
|
91
|
-
}, [is24Hour, value]);
|
|
101
|
+
setInputValue((_a = value === null || value === void 0 ? void 0 : value.toString(is24Hour, hasSeconds)) !== null && _a !== void 0 ? _a : '');
|
|
102
|
+
}, [is24Hour, hasSeconds, value]);
|
|
92
103
|
useEffect(() => {
|
|
93
104
|
if (isPopoverOpen) {
|
|
94
105
|
setTimeout(() => {
|
|
@@ -101,15 +112,15 @@ export const TimePicker = (_a) => {
|
|
|
101
112
|
}
|
|
102
113
|
else {
|
|
103
114
|
setTimeout(() => {
|
|
104
|
-
var _a, _b
|
|
105
|
-
(
|
|
106
|
-
const selectedIndex = (_c = timeOptions.indexOf((_b = value === null || value === void 0 ? void 0 : value.toString(is24Hour)) !== null && _b !== void 0 ? _b : '')) !== null && _c !== void 0 ? _c : 0;
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const selectedIndex = (_b = timeOptions.indexOf((_a = value === null || value === void 0 ? void 0 : value.toString(is24Hour, hasSeconds)) !== null && _a !== void 0 ? _a : '')) !== null && _b !== void 0 ? _b : 0;
|
|
107
117
|
setFocusedIndex(selectedIndex);
|
|
108
118
|
}, 0);
|
|
109
119
|
}
|
|
110
120
|
}, [
|
|
111
121
|
focusedIndex,
|
|
112
122
|
is24Hour,
|
|
123
|
+
hasSeconds,
|
|
113
124
|
isPopoverOpen,
|
|
114
125
|
value,
|
|
115
126
|
setFocusedIndex,
|
|
@@ -129,7 +140,7 @@ export const TimePicker = (_a) => {
|
|
|
129
140
|
setInputValue(e.target.value);
|
|
130
141
|
setLastAction('type');
|
|
131
142
|
const time = NeedleTime.fromString(e.target.value);
|
|
132
|
-
if (!isValidTime(time.hour, time.minute)) {
|
|
143
|
+
if (!isValidTime(time.hour, time.minute, time.second)) {
|
|
133
144
|
setError('Invalid time');
|
|
134
145
|
}
|
|
135
146
|
else {
|
|
@@ -146,14 +157,15 @@ export const TimePicker = (_a) => {
|
|
|
146
157
|
}
|
|
147
158
|
setIsPopoverOpen(true);
|
|
148
159
|
if (e.key === 'Enter') {
|
|
149
|
-
|
|
160
|
+
const minTypedLength = (is24Hour ? 5 : 6) + (hasSeconds ? 3 : 0);
|
|
161
|
+
if (lastAction === 'type' && inputValue.length >= minTypedLength) {
|
|
150
162
|
const time = NeedleTime.fromString(inputValue);
|
|
151
|
-
handleOnClick(time.toString(is24Hour));
|
|
163
|
+
handleOnClick(time.toString(is24Hour, hasSeconds));
|
|
152
164
|
}
|
|
153
165
|
else if (lastAction === 'type' && !inputValue.includes(':')) {
|
|
154
166
|
const time = NeedleTime.fromString(inputValue);
|
|
155
|
-
if (isValidTime(time.hour, time.minute)) {
|
|
156
|
-
handleOnClick(time.toString(is24Hour));
|
|
167
|
+
if (isValidTime(time.hour, time.minute, time.second)) {
|
|
168
|
+
handleOnClick(time.toString(is24Hour, hasSeconds));
|
|
157
169
|
}
|
|
158
170
|
setIsPopoverOpen(false);
|
|
159
171
|
}
|
|
@@ -177,9 +189,10 @@ export const TimePicker = (_a) => {
|
|
|
177
189
|
if (timeDigits.length === 1) {
|
|
178
190
|
// Single digit - assume it's an hour
|
|
179
191
|
const hour = `0${timeDigits}`;
|
|
192
|
+
const minutes = hasSeconds ? '00:00' : '00';
|
|
180
193
|
const searchTime = is24Hour
|
|
181
|
-
? `${hour}
|
|
182
|
-
: `${hour}
|
|
194
|
+
? `${hour}:${minutes}`
|
|
195
|
+
: `${hour}:${minutes} ${isPM ? 'PM' : 'AM'}`;
|
|
183
196
|
index = timeOptions.indexOf(searchTime);
|
|
184
197
|
}
|
|
185
198
|
else {
|
|
@@ -262,17 +275,21 @@ export const TimePicker = (_a) => {
|
|
|
262
275
|
setError('Invalid time');
|
|
263
276
|
return;
|
|
264
277
|
}
|
|
265
|
-
if (!isValidTime(time.hour, time.minute)) {
|
|
278
|
+
if (!isValidTime(time.hour, time.minute, time.second)) {
|
|
266
279
|
setError('Invalid time');
|
|
267
280
|
}
|
|
268
281
|
else {
|
|
269
282
|
setError(undefined);
|
|
270
|
-
setInputValue(time.toString(is24Hour));
|
|
283
|
+
setInputValue(time.toString(is24Hour, hasSeconds));
|
|
284
|
+
setEditedInput(time);
|
|
285
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(time);
|
|
271
286
|
}
|
|
272
|
-
}, placeholder: format,
|
|
287
|
+
}, placeholder: format,
|
|
288
|
+
// The typed value can never be longer than the format pattern.
|
|
289
|
+
maxLength: format.length }, restProps, htmlAttributes)), _jsx(ClockIconOutline, { className: "ndl-icon-svg ndl-time-picker-icon" })] })] }), errorToShow !== undefined && (_jsxs("div", { className: "ndl-time-picker-error-wrapper", role: "status", children: [_jsx(ExclamationCircleIconSolid, { className: "ndl-time-picker-error-icon" }), _jsx(Typography, { variant: size === 'large' ? 'body-medium' : 'body-small', className: "ndl-time-picker-error-text", htmlAttributes: { id: errorTextId }, children: errorToShow })] }))] })), context.open && (_jsx(ConditionalWrap, { shouldWrap: isPortaled, wrap: (wrapChildren) => (_jsx(FloatingPortal, { children: wrapChildren })), children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: -1, children: _jsx("div", Object.assign({ ref: refs.setFloating, className: classNames(themeClassName, 'ndl-time-picker-popover', Object.assign({}, classes)), style: Object.assign(Object.assign(Object.assign({}, transitionStyles), floatingStyles), { width: isFluid === true
|
|
273
290
|
? (_d = containerRef.current) === null || _d === void 0 ? void 0 : _d.clientWidth
|
|
274
|
-
: undefined }) }, getFloatingProps(), { children: _jsx("ul", { ref: listRef, role: "listbox", id: listboxId, tabIndex: -1, children: timeOptions.map((time, i) => (_jsx("li", { id: `${listboxId}-option-${i}`, role: "option", "aria-selected": (value === null || value === void 0 ? void 0 : value.toString(is24Hour)) === time ||
|
|
275
|
-
(editedInput === null || editedInput === void 0 ? void 0 : editedInput.toString(is24Hour)) === time, value: time, onClick: (e) => {
|
|
291
|
+
: undefined }) }, getFloatingProps(), { children: _jsx("ul", { ref: listRef, role: "listbox", id: listboxId, tabIndex: -1, children: timeOptions.map((time, i) => (_jsx("li", { id: `${listboxId}-option-${i}`, role: "option", "aria-selected": (value === null || value === void 0 ? void 0 : value.toString(is24Hour, hasSeconds)) === time ||
|
|
292
|
+
(editedInput === null || editedInput === void 0 ? void 0 : editedInput.toString(is24Hour, hasSeconds)) === time, value: time, onClick: (e) => {
|
|
276
293
|
e.stopPropagation();
|
|
277
294
|
e.preventDefault();
|
|
278
295
|
handleOnClick(time);
|