@deephaven/iris-grid 1.23.1-legacy-table-plugin.bbf55c8.0 → 1.25.0
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/dist/CellDropdownField.css +117 -0
- package/dist/CellDropdownField.css.map +1 -0
- package/dist/CellDropdownField.d.ts +15 -0
- package/dist/CellDropdownField.d.ts.map +1 -0
- package/dist/CellDropdownField.js +147 -0
- package/dist/CellDropdownField.js.map +1 -0
- package/dist/FilterInputField.css.map +1 -1
- package/dist/IrisGrid.css.map +1 -1
- package/dist/IrisGrid.d.ts +5 -4
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +5 -3
- package/dist/IrisGrid.js.map +1 -1
- package/dist/IrisGridContextProvider.d.ts +32 -0
- package/dist/IrisGridContextProvider.d.ts.map +1 -0
- package/dist/IrisGridContextProvider.js +68 -0
- package/dist/IrisGridContextProvider.js.map +1 -0
- package/dist/IrisGridModel.d.ts +10 -1
- package/dist/IrisGridModel.d.ts.map +1 -1
- package/dist/IrisGridModel.js +11 -0
- package/dist/IrisGridModel.js.map +1 -1
- package/dist/IrisGridTableModel.d.ts.map +1 -1
- package/dist/IrisGridTableModel.js +8 -8
- package/dist/IrisGridTableModel.js.map +1 -1
- package/dist/IrisGridTheme.module.css.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.js +3 -3
- package/dist/mousehandlers/IrisGridContextMenuHandler.js.map +1 -1
- package/dist/sidebar/visibility-ordering-builder/SearchWithModal.css.map +1 -1
- package/package.json +16 -16
- package/dist/IrisGridThemeProvider.d.ts +0 -18
- package/dist/IrisGridThemeProvider.d.ts.map +0 -1
- package/dist/IrisGridThemeProvider.js +0 -34
- package/dist/IrisGridThemeProvider.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* stylelint-disable */
|
|
2
|
+
/* stylelint-disable scss/at-import-no-partial-leading-underscore */
|
|
3
|
+
/* stylelint-disable-next-line number-max-precision */
|
|
4
|
+
:export {
|
|
5
|
+
grid-bg: var(--dh-color-grid-bg);
|
|
6
|
+
font: 12px Fira Sans, sans-serif;
|
|
7
|
+
white: var(--dh-color-white);
|
|
8
|
+
black: var(--dh-color-black);
|
|
9
|
+
header-bg: var(--dh-color-grid-header-bg);
|
|
10
|
+
header-color: var(--dh-color-grid-header-text);
|
|
11
|
+
header-height: 30px;
|
|
12
|
+
header-separator-color: var(--dh-color-grid-header-separator);
|
|
13
|
+
header-separator-hover-color: var(--dh-color-grid-header-separator-hover);
|
|
14
|
+
header-hidden-separator-hover-color: var(--dh-color-grid-header-separator-hidden-hover);
|
|
15
|
+
header-sort-bar-color: var(--dh-color-grid-header-sort-bar);
|
|
16
|
+
header-reverse-bar-color: var(--dh-color-grid-header-reverse-bar);
|
|
17
|
+
header-bar-casing-color: var(--dh-color-grid-header-bar-casing);
|
|
18
|
+
header-font: 600 12px Fira Sans, sans-serif;
|
|
19
|
+
row-height: 19px;
|
|
20
|
+
row-background-colors: var(--dh-color-grid-row-0-bg) var(--dh-color-grid-row-1-bg);
|
|
21
|
+
active-cell-selection-border-width: 2px;
|
|
22
|
+
selection-color: var(--dh-color-grid-selection);
|
|
23
|
+
selection-outline-color: var(--dh-color-grid-selection-outline);
|
|
24
|
+
selection-outline-casing-color: var(--dh-color-grid-selection-outline-casing);
|
|
25
|
+
row-hover-bg: var(--dh-color-grid-row-hover-bg);
|
|
26
|
+
row-shadow-alpha: var(--dh-color-grid-row-shadow-alpha);
|
|
27
|
+
selected-row-hover-bg: var(--dh-color-grid-row-hover-bg-selected);
|
|
28
|
+
scroll-bar-active-selection-tick-color: var(--dh-color-grid-scroll-bar-active-selection-tick);
|
|
29
|
+
scroll-bar-bg: var(--dh-color-grid-scroll-bar-bg);
|
|
30
|
+
scroll-bar-hover-bg: var(--dh-color-grid-scroll-bar-hover-bg);
|
|
31
|
+
scroll-bar-casing-color: var(--dh-color-grid-scroll-bar-casing);
|
|
32
|
+
scroll-bar-corner-color: var(--dh-color-grid-scroll-bar-corner);
|
|
33
|
+
scroll-bar-color: var(--dh-color-grid-scroll-bar);
|
|
34
|
+
scroll-bar-hover-color: var(--dh-color-grid-scroll-bar-hover);
|
|
35
|
+
scroll-bar-active-color: var(--dh-color-grid-scroll-bar-active);
|
|
36
|
+
text-color: var(--dh-color-grid-text);
|
|
37
|
+
hyperlink-color: var(--dh-color-grid-text-hyperlink);
|
|
38
|
+
positive-number-color: var(--dh-color-grid-number-positive);
|
|
39
|
+
negative-number-color: var(--dh-color-grid-number-negative);
|
|
40
|
+
zero-number-color: var(--dh-color-grid-number-zero);
|
|
41
|
+
date-color: var(--dh-color-grid-date);
|
|
42
|
+
pending-text-color: var(--dh-color-grid-text-pending);
|
|
43
|
+
error-text-color: var(--dh-color-grid-text-error);
|
|
44
|
+
null-string-color: var(--dh-color-grid-string-null);
|
|
45
|
+
filter-bar-active-bg: var(--dh-color-grid-filter-bar-active-bg);
|
|
46
|
+
filter-bar-active-color: var(--dh-color-grid-filter-bar-active);
|
|
47
|
+
filter-bar-expanded-bg: var(--dh-color-grid-filter-bar-expanded-bg);
|
|
48
|
+
filter-bar-expanded-active-bg: var(--dh-color-grid-filter-bar-expanded-active-bg);
|
|
49
|
+
filter-bar-expanded-active-cell-bg: var(--dh-color-grid-filter-bar-expanded-active-cell-bg);
|
|
50
|
+
filter-bar-separator-color: var(--dh-color-grid-filter-bar-separator);
|
|
51
|
+
filter-bar-error-color: var(--dh-color-grid-filter-bar-error);
|
|
52
|
+
filter-icon-color: var(--dh-color-grid-filter-icon);
|
|
53
|
+
scrim-color: var(--dh-color-grid-scrim);
|
|
54
|
+
context-menu-sort-icon-color: var(--dh-color-grid-context-menu-sort-icon);
|
|
55
|
+
context-menu-reverse-icon-color: var(--dh-color-grid-context-menu-reverse-icon);
|
|
56
|
+
linker-column-hover-bg: var(--dh-color-grid-column-linker-hover-bg);
|
|
57
|
+
tree-line-color: var(--dh-color-grid-tree-line);
|
|
58
|
+
tree-marker-color: var(--dh-color-grid-tree-marker);
|
|
59
|
+
tree-marker-hover-color: var(--dh-color-grid-tree-marker-hover);
|
|
60
|
+
grouped-column-divider-color: var(--dh-color-grid-column-grouped-divider);
|
|
61
|
+
floating-grid-row-color: var(--dh-color-grid-floating-row);
|
|
62
|
+
floating-row-background-colors: var(--dh-color-grid-floating-row-bg);
|
|
63
|
+
floating-divider-inner-color: var(--dh-color-grid-floating-divider-inner);
|
|
64
|
+
floating-divider-outer-color: var(--dh-color-grid-floating-divider-outer);
|
|
65
|
+
overflow-button-color: var(--dh-color-grid-overflow-button);
|
|
66
|
+
overflow-button-hover-color: var(--dh-color-grid-overflow-button-hover);
|
|
67
|
+
zero-line-color: var(--dh-color-grid-data-bar-zero-line);
|
|
68
|
+
positive-bar-color: var(--dh-color-grid-data-bar-positive);
|
|
69
|
+
negative-bar-color: var(--dh-color-grid-data-bar-negative);
|
|
70
|
+
marker-bar-color: var(--dh-color-grid-data-bar-marker);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.cell-dropdown-field {
|
|
74
|
+
position: absolute;
|
|
75
|
+
left: 0;
|
|
76
|
+
right: 0;
|
|
77
|
+
padding-right: var(--grid-cell-horizontal-padding, 5px);
|
|
78
|
+
padding-left: var(--grid-cell-horizontal-padding, 5px);
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
--spectrum-dropdown-height: var(--grid-row-height, 20px);
|
|
83
|
+
--spectrum-dropdown-quiet-min-width: 0;
|
|
84
|
+
--spectrum-dropdown-min-width: 0;
|
|
85
|
+
--spectrum-dropdown-text-size: var(--grid-font-size, 12px);
|
|
86
|
+
box-shadow: 0 0 0 2px var(--dh-color-grid-selection-outline), 0 0 0 5px color-mix(in srgb, var(--dh-color-accent) 25%, transparent);
|
|
87
|
+
}
|
|
88
|
+
.cell-dropdown-field::after {
|
|
89
|
+
content: "";
|
|
90
|
+
display: block;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
width: 8px;
|
|
93
|
+
height: 8px;
|
|
94
|
+
border-right: 2px solid currentcolor;
|
|
95
|
+
border-bottom: 2px solid currentcolor;
|
|
96
|
+
transform: rotate(45deg);
|
|
97
|
+
margin-left: 4px;
|
|
98
|
+
margin-bottom: 4px;
|
|
99
|
+
opacity: 0.7;
|
|
100
|
+
}
|
|
101
|
+
.cell-dropdown-field .cell-dropdown-field-picker {
|
|
102
|
+
flex: 1;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
transform: translateY(mod(var(--grid-row-height, 19px) - var(--grid-font-size, 12px), 2px));
|
|
105
|
+
}
|
|
106
|
+
.cell-dropdown-field .cell-dropdown-field-picker svg[class*=spectrum-Dropdown-chevron] {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
.cell-dropdown-field .cell-dropdown-field-picker button {
|
|
110
|
+
font-family: "fira sans", sans-serif;
|
|
111
|
+
color: inherit;
|
|
112
|
+
}
|
|
113
|
+
.cell-dropdown-field.error {
|
|
114
|
+
box-shadow: 0 0 0 2px var(--dh-color-negative), 0 0 0 5px color-mix(in srgb, var(--dh-color-negative) 25%, transparent);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*# sourceMappingURL=CellDropdownField.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../src/IrisGridTheme.module.scss","../../../node_modules/@deephaven/components/scss/custom.scss","../../../node_modules/@deephaven/components/scss/bootstrap_overrides.scss","../src/CellDropdownField.scss"],"names":[],"mappings":"AAAA;ACAA;AC6LA;AF7KA;EACE;EACA,MACE;EAEF;EACA;EACA;EACA;EACA,eApBc;EAqBd;EACA;EACA;EAGA;EACA;EACA;EACA,aACE;EAEF,YAjCW;EAkCX;EAEA,oCAlCmC;EAmCnC;EACA;EACA;EACA;EACA;EACA;EACA;EAIA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EAEA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;;;AGtGF;EACE;EAIA;EACA;EAIA;EACA;EAEA;EACA;EACA;EAIA;EAEA;EACA;EAEA;EA6CA,YH9DA;;AGqBA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EAOA;;AAKA;EACE;;AAIF;EACE;EACA;;AAQJ;EACE,YH7DF","file":"CellDropdownField.css","sourcesContent":["/* stylelint-disable */\n@import '@deephaven/components/scss/custom.scss';\n\n$font-size: 12px;\n$row-height: 19px;\n$header-height: 30px;\n$active-cell-selection-border-width: 2px;\n\n$cell-box-shadow:\n 0 0 0 $active-cell-selection-border-width\n var(--dh-color-grid-selection-outline),\n 0 0 0 5px accent-opacity(25);\n$cell-invalid-box-shadow:\n 0 0 0 $active-cell-selection-border-width var(--dh-color-negative),\n 0 0 0 5px negative-opacity(25);\n\n:export {\n grid-bg: var(--dh-color-grid-bg);\n font:\n $font-size Fira Sans,\n sans-serif; // must be preloaded\n white: var(--dh-color-white);\n black: var(--dh-color-black);\n header-bg: var(--dh-color-grid-header-bg);\n header-color: var(--dh-color-grid-header-text);\n header-height: $header-height;\n header-separator-color: var(--dh-color-grid-header-separator);\n header-separator-hover-color: var(--dh-color-grid-header-separator-hover);\n header-hidden-separator-hover-color: var(\n --dh-color-grid-header-separator-hidden-hover\n );\n header-sort-bar-color: var(--dh-color-grid-header-sort-bar);\n header-reverse-bar-color: var(--dh-color-grid-header-reverse-bar);\n header-bar-casing-color: var(--dh-color-grid-header-bar-casing);\n header-font:\n 600 $font-size Fira Sans,\n sans-serif; // must be preloaded\n row-height: $row-height;\n row-background-colors: var(--dh-color-grid-row-0-bg)\n var(--dh-color-grid-row-1-bg);\n active-cell-selection-border-width: $active-cell-selection-border-width;\n selection-color: var(--dh-color-grid-selection);\n selection-outline-color: var(--dh-color-grid-selection-outline);\n selection-outline-casing-color: var(--dh-color-grid-selection-outline-casing);\n row-hover-bg: var(--dh-color-grid-row-hover-bg);\n row-shadow-alpha: var(--dh-color-grid-row-shadow-alpha);\n selected-row-hover-bg: var(--dh-color-grid-row-hover-bg-selected);\n scroll-bar-active-selection-tick-color: var(\n --dh-color-grid-scroll-bar-active-selection-tick\n );\n\n scroll-bar-bg: var(--dh-color-grid-scroll-bar-bg);\n scroll-bar-hover-bg: var(--dh-color-grid-scroll-bar-hover-bg);\n scroll-bar-casing-color: var(--dh-color-grid-scroll-bar-casing);\n scroll-bar-corner-color: var(--dh-color-grid-scroll-bar-corner);\n scroll-bar-color: var(--dh-color-grid-scroll-bar);\n scroll-bar-hover-color: var(--dh-color-grid-scroll-bar-hover);\n scroll-bar-active-color: var(--dh-color-grid-scroll-bar-active);\n\n text-color: var(--dh-color-grid-text);\n hyperlink-color: var(--dh-color-grid-text-hyperlink);\n positive-number-color: var(--dh-color-grid-number-positive);\n negative-number-color: var(--dh-color-grid-number-negative);\n zero-number-color: var(--dh-color-grid-number-zero);\n date-color: var(--dh-color-grid-date);\n pending-text-color: var(--dh-color-grid-text-pending);\n error-text-color: var(--dh-color-grid-text-error);\n null-string-color: var(--dh-color-grid-string-null);\n\n filter-bar-active-bg: var(--dh-color-grid-filter-bar-active-bg);\n filter-bar-active-color: var(--dh-color-grid-filter-bar-active);\n filter-bar-expanded-bg: var(--dh-color-grid-filter-bar-expanded-bg);\n filter-bar-expanded-active-bg: var(\n --dh-color-grid-filter-bar-expanded-active-bg\n );\n filter-bar-expanded-active-cell-bg: var(\n --dh-color-grid-filter-bar-expanded-active-cell-bg\n );\n filter-bar-separator-color: var(--dh-color-grid-filter-bar-separator);\n filter-bar-error-color: var(--dh-color-grid-filter-bar-error);\n filter-icon-color: var(--dh-color-grid-filter-icon);\n\n scrim-color: var(--dh-color-grid-scrim);\n context-menu-sort-icon-color: var(--dh-color-grid-context-menu-sort-icon);\n context-menu-reverse-icon-color: var(\n --dh-color-grid-context-menu-reverse-icon\n );\n linker-column-hover-bg: var(--dh-color-grid-column-linker-hover-bg);\n tree-line-color: var(--dh-color-grid-tree-line);\n tree-marker-color: var(--dh-color-grid-tree-marker);\n tree-marker-hover-color: var(--dh-color-grid-tree-marker-hover);\n grouped-column-divider-color: var(--dh-color-grid-column-grouped-divider);\n\n floating-grid-row-color: var(--dh-color-grid-floating-row);\n floating-row-background-colors: var(--dh-color-grid-floating-row-bg);\n floating-divider-inner-color: var(--dh-color-grid-floating-divider-inner);\n floating-divider-outer-color: var(--dh-color-grid-floating-divider-outer);\n\n overflow-button-color: var(--dh-color-grid-overflow-button);\n overflow-button-hover-color: var(--dh-color-grid-overflow-button-hover);\n\n zero-line-color: var(--dh-color-grid-data-bar-zero-line);\n positive-bar-color: var(--dh-color-grid-data-bar-positive);\n negative-bar-color: var(--dh-color-grid-data-bar-negative);\n marker-bar-color: var(--dh-color-grid-data-bar-marker);\n}\n","/* stylelint-disable scss/at-import-no-partial-leading-underscore */\n// Consumers should be able to resolve bootstrap/ to node_modules/bootstrap\n\n//Make bootstrap functions available for use in overrides\n@import 'bootstrap/scss/_functions.scss';\n@import './bootstrap_overrides.scss';\n\n//_variable imports come after bootstrap default overrides,\n// makes all other variables and mixins from bootstrap available\n/// with just importing customer.scss\n@import 'bootstrap/scss/_variables.scss';\n@import 'bootstrap/scss/_mixins.scss';\n\n//New variables come after imports\n@import './new_variables.scss';\n@import './util.scss';\n","// Styling overrides for bootstrap\n@use 'sass:map';\n\n// Override / set color variables\n$red: var(--dh-color-visual-red);\n$orange: var(--dh-color-visual-orange);\n$yellow: var(--dh-color-visual-yellow);\n$green: var(--dh-color-visual-green);\n$blue: var(--dh-color-visual-blue);\n$purple: var(--dh-color-visual-purple);\n\n// Fallback colors are used if theme isn't loaded\n// this is required for error messages if the API doesn't load\n\n//Define our Gray scale\n$gray-100: var(--dh-color-gray-900, #fcfcfa);\n$gray-200: var(--dh-color-gray-800);\n$gray-300: var(--dh-color-gray-700);\n$gray-400: var(--dh-color-gray-600);\n$gray-500: var(--dh-color-gray-500);\n// intentional duplicate, scale doesn't line up otherwise\n// as we have gray-850 and spectrum doesn't and it is needed\n$gray-600: var(--dh-color-gray-500);\n$gray-700: var(--dh-color-gray-400);\n$gray-800: var(--dh-color-gray-300);\n$gray-850: var(--dh-color-gray-200);\n$gray-900: var(--dh-color-gray-75);\n$black: var(--dh-color-black, #1a171a);\n$white: var(--dh-color-white, #f0f0ee);\n\n//Define some UI colors\n$interfacegray: var(--dh-color-content-bg, #2d2a2e);\n$interfaceblue: var(--dh-color-accent-bg);\n$interfacewhite: $white;\n$interfaceblack: $black;\n$content-bg: var(--dh-color-content-bg, #2d2a2e);\n$background: var(--dh-color-bg, #1a171a);\n$foreground: var(--dh-color-fg, #f0f0ee);\n\n// Extend default Bootstrap $grays map\n$grays-custom: (\n '850': $gray-850,\n);\n$grays: () !default;\n$grays: map-merge($grays, $grays-custom);\n\n// Extend default Bootstrap $colors map\n$colors-custom: (\n 'black': $black,\n);\n$colors: () !default;\n$colors: map-merge($colors, $colors-custom);\n\n// Override default Bootstrap $theme-colors map by mapping each key to itself.\n// These will then be re-mapped inside of `button-outline-variant` and\n// `button-outline-variant` mixins in `bootstrap_override_mixins_buttons.scss`\n$theme-colors-self-map: ();\n@each $key\n in (\n 'primary',\n 'secondary',\n 'success',\n 'info',\n 'warning',\n 'danger',\n 'light',\n 'dark'\n )\n{\n $theme-colors-self-map: map.set($theme-colors-self-map, $key, $key);\n}\n$theme-colors: () !default;\n$theme-colors: map-merge($theme-colors, $theme-colors-self-map);\n\n// Used by bootstrap_override_mixins_buttons.scss to map Bootstrap colors to\n// DH semantic colors\n$bootstrap-dh-semantic-map: (\n 'primary': 'accent',\n 'secondary': 'neutral',\n 'success': 'positive',\n 'info': 'info',\n 'warning': 'notice',\n 'danger': 'negative',\n // We shouldn't be using these, but mapping so they work with our custom\n // `color-yiq` mixin. If we find a way to remove $light + $dark that are\n // defined in Bootstrap _variables.scss, we should remove these\n 'light': 'neutral',\n 'dark': 'neutral',\n);\n\n//Set default colors\n$body-bg: $black;\n$body-color: $interfacewhite;\n\n// Set brand colors\n$primary: var(--dh-color-accent-bg);\n$primary-hover: var(--dh-color-accent-hover-bg);\n$primary-dark: var(--dh-color-accent-down-bg);\n$secondary: var(--dh-color-neutral-bg);\n$secondary-hover: var(--dh-color-neutral-hover-bg);\n$success: $green;\n$info: $yellow;\n$warning: $orange;\n$danger: var(--dh-color-negative-bg);\n$danger-hover: var(--dh-color-negative-hover-bg);\n// We really don't want to use $light or $dark variables, but Bootstrap defines\n// them in _variables.scss. Explicitly setting them to ensure we are in control\n// of their values. If we can find a way to remove them, we should\n$light: var(--dh-color-gray-light);\n$dark: var(--dh-color-gray-dark);\n// Bootstrap doesn't define $mid, and we want to move away from this particular\n// semantic. Should be deleted by #1635\n$mid: var(--dh-color-gray-mid);\n\n$semantic-colors: (\n 'primary-hover': $primary-hover,\n 'primary-dark': $primary-dark,\n 'mid': $mid,\n 'content-bg': $interfacegray,\n 'background': $interfaceblack,\n 'foreground': $interfacewhite,\n 'secondary-hover': $secondary-hover,\n 'danger-hover': $danger-hover,\n);\n\n$component-active-bg: $primary;\n$theme-color-interval: 9%;\n$yiq-contrasted-threshold: 180;\n\n// Override fonts\n$font-family-sans-serif:\n 'Fira Sans',\n -apple-system,\n blinkmacsystemfont,\n 'Segoe UI',\n 'Roboto',\n 'Helvetica Neue',\n arial,\n sans-serif; //fira sans then native system ui fallbacks\n$font-family-monospace: 'Fira Mono', menlo, monaco, consolas, 'Liberation Mono',\n 'Courier New', monospace;\n$font-family-base: $font-family-sans-serif;\n\n$headings-font-weight: 400;\n\n//Text overides\n$text-muted: $gray-400;\n\n//Style Selection highlight color\n$text-select-color: var(--dh-color-text-highlight);\n\n//Grid variables, same value as default just making easily accessible\n$grid-gutter-width: 30px;\n\n//Visual Overrides\n$border-radius: 4px;\n$box-shadow: 0 0.1rem 1rem var(--dh-color-dropshadow);\n\n//Override Btn\n$btn-border-radius: 4rem;\n$btn-padding-x: 1.5rem;\n$btn-transition:\n color 0.12s ease-in-out,\n background-color 0.12s ease-in-out,\n border-color 0.12s ease-in-out,\n box-shadow 0.12s ease-in-out; //default 0.15 is too long\n$btn-border-width: 2px;\n$btn-font-weight: var(--spectrum-global-font-weight-bold);\n$btn-line-height: 1.3;\n\n//Override Inputs\n$input-bg: var(--dh-color-input-bg);\n$input-disabled-bg: var(--dh-color-input-disabled-bg);\n$input-color: var(--dh-color-input-fg);\n$input-border-color: var(--dh-color-input-border);\n$input-placeholder-color: var(--dh-color-input-placeholder);\n$input-focus-border-color: var(--dh-color-input-focus-border);\n\n$input-btn-focus-width: 0.2rem;\n$input-btn-focus-color: color-mix(\n in srgb,\n var(--dh-color-accent) 35%,\n transparent\n);\n$input-btn-focus-box-shadow: 0 0 0 $input-btn-focus-width $input-btn-focus-color;\n$input-btn-line-height: 1.3;\n// Bootstrap uses a calc expression to determine the input height (calc(line-height + 2*padding-y + border)).\n// The padding-y value has to be in rem to match units as it is a SASS calc.\n// Using 0.42145rem with 1.3 line height gets us to spectrum's 32px.\n/* stylelint-disable-next-line number-max-precision */\n$input-btn-padding-y: 0.42145rem;\n\n//checkbox\n$custom-control-indicator-bg: var(--dh-color-input-bg);\n$custom-control-indicator-border-color: var(--dh-color-input-border);\n$custom-checkbox-indicator-border-radius: 2px;\n$custom-control-indicator-border-width: 2px;\n$custom-control-indicator-active-bg: var(--dh-color-input-bg);\n$custom-control-indicator-active-border-color: var(--dh-color-input-fg);\n$custom-control-indicator-checked-bg: var(--dh-color-input-fg);\n$custom-control-indicator-checked-color: black; // used as mask fill color\n$custom-checkbox-indicator-indeterminate-bg: var(--dh-color-input-fg);\n$custom-control-indicator-bg-size: 75% 75%;\n$custom-control-indicator-disabled-bg: var(--dh-color-input-disabled-bg);\n$custom-control-indicator-checked-disabled-bg: var(\n --dh-color-input-disabled-bg\n);\n$custom-control-label-disabled-color: var(--dh-color-input-disabled-fg);\n\n// The $custom-select-indicator variable is used by Bootstrap to provide the\n// icon for the select dropdown. Inline svgs can't use CSS variables, so we hard\n// code the color to #929192 (the default value of --dh-color-gray-600). PR #1651\n// overrides this icon altogether for known dropdowns, so technically we may not\n// need this, but it's here in case there are any remaining instances.\n$custom-select-indicator-color: #929192;\n$custom-select-bg: var(--dh-color-selector-bg);\n$custom-select-bg-size: 16px 16px;\n//dhSort icon encoded\n$custom-select-indicator: str-replace(\n url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='#{$custom-select-indicator-color}' d='M4 7l-.4-.8 4-3.7h.8l4 3.7-.4.8H4zm0 2l-.4.8 4 3.7h.8l4-3.7L12 9H4z'/%3E%3C/svg%3E\"),\n '#',\n '%23'\n);\n$custom-select-focus-box-shadow: $input-btn-focus-box-shadow;\n$custom-select-disabled-color: $gray-500;\n$custom-select-disabled-bg: $gray-800;\n\n//modal\n$modal-content-bg: $content-bg;\n$modal-content-border-width: 0;\n$modal-md: 550px;\n$close-color: var(--dh-color-text);\n$close-text-shadow: none;\n\n// Toast notification\n$toast-bg: var(--dh-color-accent-100);\n$toast-color: var(--dh-color-text);\n$toast-error-bg: var(--dh-color-negative-bg);\n$toast-error-color: var(--dh-color-text);\n\n//tooltips\n$tooltip-bg: var(--dh-color-tooltip-bg);\n$tooltip-color: var(--dh-color-tooltip-fg);\n$tooltip-box-shadow: 0 0.1rem 1.5rem 0.1rem var(--dh-color-tooltip-box-shadow);\n\n//drowdowns\n$dropdown-bg: $gray-600;\n$dropdown-link-color: $foreground;\n$dropdown-link-hover-color: $foreground;\n$dropdown-link-hover-bg: var(--dh-color-item-list-hover-bg);\n$dropdown-divider-bg: $gray-700;\n\n//context menus\n$contextmenu-bg: var(--dh-color-popover-bg);\n$contextmenu-color: var(--dh-color-text);\n$contextmenu-disabled-color: var(--dh-color-text-disabled);\n$contextmenu-keyboard-selected-bg: var(--dh-color-keyboard-selected-bg);\n$contextmenu-selected-bg: var(--dh-color-item-list-hover-bg);\n$contextmenu-selected-color: var(--dh-color-item-list-selected-fg);\n\n//hr\n$hr-border-color: var(--dh-color-hr);\n\n//links\n$link-color: $gray-400;\n$link-hover-color: $foreground;\n\n//progress-bar\n$progress-bg: $gray-600;\n$progress-border-radius: 1rem;\n\n// Set global options\n$enable-shadows: false;\n$enable-gradients: false;\n$enable-print-styles: false; //I don't think anyone should expect to \"print\" this app.\n\n// Transition times\n$transition: 0.15s;\n$transition-mid: 0.2s;\n$transition-long: 0.3s;\n$transition-slow: 0.6s;\n\n//form-validation icon, uses vsWarning icon encoded here as svg\n$form-feedback-icon-invalid-color: $danger;\n$form-feedback-icon-invalid: str-replace(\n url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cg fill='none'%3E%3Cg fill='#{$form-feedback-icon-invalid-color}'%3E%3Cpath d='M7.56 1h.88l6.54 12.26-.44.74H1.44L1 13.26 7.56 1zM8 2.28 2.28 13H13.7L8 2.28zM8.625 12v-1h-1.25v1h1.25zm-1.25-2V6h1.25v4h-1.25z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E \"),\n '#',\n '%23'\n);\n\n// This section of variables is not consumed directly by DH, but they need to be\n// defined for sass to compile _variables\n$table-dark-bg: $gray-800;\n$table-dark-accent-bg: var(--dh-color-highlight-hover);\n$table-dark-hover-bg: var(--dh-color-highlight-active);\n$table-dark-border-color: $gray-700;\n$popover-bg: var(--dh-color-tooltip-bg);\n$popover-border-color: var(--dh-color-overlay-modal-bg);\n$popover-header-bg: #000;\n$popover-arrow-outer-color: var(--dh-color-dropshadow);\n$custom-range-thumb-active-bg: var(--dh-color-accent-1100);\n","@import './IrisGridTheme.module.scss';\n\n.cell-dropdown-field {\n position: absolute;\n // Span the full cell so the focus-ring box-shadow aligns with the cell\n // boundary, matching the canvas selection border (and the standard\n // CellInputField). Do not offset with `left`, as that shifts the border.\n left: 0;\n right: 0;\n // Align the label text with the grid canvas text, which is drawn at\n // `cellHorizontalPadding` from the cell's left edge (5px regular, 7px\n // spacious). Driven by the theme so it stays aligned across densities.\n padding-right: var(--grid-cell-horizontal-padding, 5px);\n padding-left: var(--grid-cell-horizontal-padding, 5px);\n // Clip to the cell row height; the Picker button is taller than the row.\n overflow: hidden;\n display: flex;\n align-items: center;\n\n // Override Spectrum Picker sizing to match grid cell dimensions.\n // --spectrum-dropdown-height drives the button block-size and internal padding.\n --spectrum-dropdown-height: var(--grid-row-height, 20px);\n // Remove Spectrum's minimum width so the Picker can be as narrow as the cell.\n --spectrum-dropdown-quiet-min-width: 0;\n --spectrum-dropdown-min-width: 0;\n // Match the grid font size (Spectrum reads this variable for the label text).\n --spectrum-dropdown-text-size: var(--grid-font-size, 12px);\n\n // Our own chevron rendered as a pseudo-element on the right.\n // Square element with border-right + border-bottom rotated 45° → symmetric V.\n &::after {\n content: '';\n display: block;\n flex-shrink: 0;\n width: 8px;\n height: 8px;\n border-right: 2px solid currentcolor;\n border-bottom: 2px solid currentcolor;\n transform: rotate(45deg);\n margin-left: 4px;\n margin-bottom: 4px; // shift up to visually center the rotated square\n opacity: 0.7;\n }\n\n .cell-dropdown-field-picker {\n flex: 1;\n min-width: 0;\n // The canvas centers cell text on rowHeight/2, but Spectrum's quiet Picker\n // rounds the label to an integer pixel. When (rowHeight - fontSize) is odd\n // (regular 19-12=7, compact 16-11=5) the label lands 1px above the canvas\n // text; when even (spacious 28-12=16) it is already aligned. Nudge down by\n // that parity so the label matches the canvas text across all densities.\n // Interpolated so Sass emits the CSS `mod()` instead of evaluating its own.\n transform: translateY(\n #{'mod(var(--grid-row-height, 19px) - var(--grid-font-size, 12px), 2px)'}\n );\n\n // Hide Spectrum's built-in chevron since we render our own.\n svg[class*='spectrum-Dropdown-chevron'] {\n display: none;\n }\n\n // Override font-family: Spectrum sets this via an ancestor i18n class.\n button {\n font-family: 'fira sans', sans-serif;\n color: inherit;\n }\n }\n\n // Apply the same focus-ring box-shadow as CellInputField (the textarea)\n // so the cell outline is visible when a dropdown editor is open.\n box-shadow: $cell-box-shadow;\n\n &.error {\n box-shadow: $cell-invalid-box-shadow;\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CellInputProps } from '@deephaven/grid';
|
|
2
|
+
import './CellDropdownField.scss';
|
|
3
|
+
export type CellDropdownFieldProps = CellInputProps & {
|
|
4
|
+
/** The list of allowed values to display in the dropdown. */
|
|
5
|
+
options: string[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A dropdown cell editor for use in an editable grid cell.
|
|
9
|
+
* Renders a Picker component in place of the standard textarea used by CellInputField.
|
|
10
|
+
* Intended to be supplied as the `renderCellInputComponent` prop on Grid when the
|
|
11
|
+
* column restriction requires a constrained set of values.
|
|
12
|
+
*/
|
|
13
|
+
export declare function CellDropdownField({ options, className, disabled, value: propsValue, onChange, onCancel, onDone, style, }: CellDropdownFieldProps): JSX.Element;
|
|
14
|
+
export default CellDropdownField;
|
|
15
|
+
//# sourceMappingURL=CellDropdownField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellDropdownField.d.ts","sourceRoot":"","sources":["../src/CellDropdownField.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,0BAA0B,CAAC;AAElC,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG;IACpD,6DAA6D;IAC7D,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,SAAc,EACd,QAAgB,EAChB,KAAK,EAAE,UAAe,EACtB,QAAyB,EACzB,QAAyB,EACzB,MAAuB,EACvB,KAAK,GACN,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA4HtC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { EMPTY_FUNCTION } from '@deephaven/utils';
|
|
10
|
+
import { Item, Picker } from '@deephaven/components';
|
|
11
|
+
import { SELECTION_DIRECTION } from '@deephaven/grid';
|
|
12
|
+
import "./CellDropdownField.css";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* A dropdown cell editor for use in an editable grid cell.
|
|
16
|
+
* Renders a Picker component in place of the standard textarea used by CellInputField.
|
|
17
|
+
* Intended to be supplied as the `renderCellInputComponent` prop on Grid when the
|
|
18
|
+
* column restriction requires a constrained set of values.
|
|
19
|
+
*/
|
|
20
|
+
export function CellDropdownField(_ref) {
|
|
21
|
+
var options = _ref.options,
|
|
22
|
+
_ref$className = _ref.className,
|
|
23
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
24
|
+
_ref$disabled = _ref.disabled,
|
|
25
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
26
|
+
_ref$value = _ref.value,
|
|
27
|
+
propsValue = _ref$value === void 0 ? '' : _ref$value,
|
|
28
|
+
_ref$onChange = _ref.onChange,
|
|
29
|
+
onChange = _ref$onChange === void 0 ? EMPTY_FUNCTION : _ref$onChange,
|
|
30
|
+
_ref$onCancel = _ref.onCancel,
|
|
31
|
+
onCancel = _ref$onCancel === void 0 ? EMPTY_FUNCTION : _ref$onCancel,
|
|
32
|
+
_ref$onDone = _ref.onDone,
|
|
33
|
+
onDone = _ref$onDone === void 0 ? EMPTY_FUNCTION : _ref$onDone,
|
|
34
|
+
style = _ref.style;
|
|
35
|
+
var _useState = useState(propsValue),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
value = _useState2[0],
|
|
38
|
+
setValue = _useState2[1];
|
|
39
|
+
// Use a ref for `isCancelled` so the focus change handler always sees the latest value
|
|
40
|
+
var isCancelled = useRef(false);
|
|
41
|
+
// Track whether a selection was committed so onOpenChange can distinguish ESC from a selection
|
|
42
|
+
var isSelectionCommitted = useRef(false);
|
|
43
|
+
// Direction to use when committing — set by capturing Enter before Spectrum consumes it
|
|
44
|
+
var commitDirection = useRef(null);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handle when the selected value changes in the Picker. Updates local state and calls onChange and onDone with the new value.
|
|
48
|
+
* @param key the key of the newly selected item, or null if no item is selected
|
|
49
|
+
*/
|
|
50
|
+
var handleChange = useCallback(key => {
|
|
51
|
+
var _key$toString;
|
|
52
|
+
var newValue = (_key$toString = key === null || key === void 0 ? void 0 : key.toString()) !== null && _key$toString !== void 0 ? _key$toString : '';
|
|
53
|
+
isSelectionCommitted.current = true;
|
|
54
|
+
setValue(newValue);
|
|
55
|
+
onChange(newValue);
|
|
56
|
+
onDone(newValue, {
|
|
57
|
+
direction: commitDirection.current
|
|
58
|
+
});
|
|
59
|
+
commitDirection.current = null;
|
|
60
|
+
}, [onChange, onDone]);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Capture Enter before Spectrum consumes it to record the intended commit direction.
|
|
64
|
+
* Spectrum handles Enter to select the highlighted item and fires onChange — by the
|
|
65
|
+
* time onChange fires the key event is gone, so we must capture direction here.
|
|
66
|
+
*/
|
|
67
|
+
var handleWrapperKeyDownCapture = useCallback(event => {
|
|
68
|
+
if (event.key === 'Enter') {
|
|
69
|
+
commitDirection.current = event.shiftKey ? SELECTION_DIRECTION.UP : SELECTION_DIRECTION.DOWN;
|
|
70
|
+
}
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Handle key down events on the Picker. Currently only handles Escape to cancel the edit, but could be expanded to handle committing the edit with Enter or other keys.
|
|
75
|
+
* @param event the keyboard event
|
|
76
|
+
*/
|
|
77
|
+
var handleKeyDown = useCallback(event => {
|
|
78
|
+
if (event.key === 'Escape') {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
event.stopPropagation();
|
|
81
|
+
isCancelled.current = true;
|
|
82
|
+
onCancel();
|
|
83
|
+
}
|
|
84
|
+
}, [onCancel]);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* When the overlay closes without a committed selection (e.g. ESC pressed while
|
|
88
|
+
* the menu is open), cancel the edit. Spectrum consumes the ESC keydown to close
|
|
89
|
+
* the overlay so onKeyDown never fires in that case.
|
|
90
|
+
*/
|
|
91
|
+
var handleOpenChange = useCallback(isOpen => {
|
|
92
|
+
if (!isOpen && !isSelectionCommitted.current) {
|
|
93
|
+
if (commitDirection.current !== null) {
|
|
94
|
+
// Enter was pressed on the already-selected item — Spectrum didn't fire
|
|
95
|
+
// onChange because the value didn't change, but we should still commit.
|
|
96
|
+
isSelectionCommitted.current = true;
|
|
97
|
+
onDone(value, {
|
|
98
|
+
direction: commitDirection.current
|
|
99
|
+
});
|
|
100
|
+
commitDirection.current = null;
|
|
101
|
+
} else {
|
|
102
|
+
isCancelled.current = true;
|
|
103
|
+
onCancel();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, [onCancel, onDone, value]);
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Commit the current value when the Picker loses focus entirely (trigger + overlay).
|
|
110
|
+
* Skipped if the edit was already cancelled via Escape.
|
|
111
|
+
*/
|
|
112
|
+
var handleFocusChange = useCallback(isFocused => {
|
|
113
|
+
if (!isFocused && !isCancelled.current) {
|
|
114
|
+
onDone(value, {
|
|
115
|
+
direction: null
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, [onDone, value]);
|
|
119
|
+
return (
|
|
120
|
+
/*#__PURE__*/
|
|
121
|
+
// onKeyDownCapture captures Enter before Spectrum consumes it to set commit direction
|
|
122
|
+
_jsx("div", {
|
|
123
|
+
className: classNames('grid-cell-input-field', 'cell-dropdown-field', className),
|
|
124
|
+
style: style,
|
|
125
|
+
onKeyDownCapture: handleWrapperKeyDownCapture,
|
|
126
|
+
children: /*#__PURE__*/_jsx(Picker, {
|
|
127
|
+
UNSAFE_className: "cell-dropdown-field-picker",
|
|
128
|
+
width: "100%",
|
|
129
|
+
selectedKey: value || null,
|
|
130
|
+
autoFocus: true,
|
|
131
|
+
defaultOpen: true,
|
|
132
|
+
onChange: handleChange,
|
|
133
|
+
onKeyDown: handleKeyDown,
|
|
134
|
+
onOpenChange: handleOpenChange,
|
|
135
|
+
onFocusChange: handleFocusChange,
|
|
136
|
+
"aria-label": "Cell value",
|
|
137
|
+
isDisabled: disabled,
|
|
138
|
+
isQuiet: true,
|
|
139
|
+
children: options.map(option => /*#__PURE__*/_jsx(Item, {
|
|
140
|
+
children: option
|
|
141
|
+
}, option))
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
export default CellDropdownField;
|
|
147
|
+
//# sourceMappingURL=CellDropdownField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellDropdownField.js","names":["React","useCallback","useRef","useState","classNames","EMPTY_FUNCTION","Item","Picker","SELECTION_DIRECTION","jsx","_jsx","CellDropdownField","_ref","options","_ref$className","className","_ref$disabled","disabled","_ref$value","value","propsValue","_ref$onChange","onChange","_ref$onCancel","onCancel","_ref$onDone","onDone","style","_useState","_useState2","_slicedToArray","setValue","isCancelled","isSelectionCommitted","commitDirection","handleChange","key","_key$toString","newValue","toString","current","direction","handleWrapperKeyDownCapture","event","shiftKey","UP","DOWN","handleKeyDown","preventDefault","stopPropagation","handleOpenChange","isOpen","handleFocusChange","isFocused","onKeyDownCapture","children","UNSAFE_className","width","selectedKey","autoFocus","defaultOpen","onKeyDown","onOpenChange","onFocusChange","isDisabled","isQuiet","map","option"],"sources":["../src/CellDropdownField.tsx"],"sourcesContent":["import React, { useCallback, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { EMPTY_FUNCTION } from '@deephaven/utils';\nimport { Item, Picker, type ItemKey } from '@deephaven/components';\nimport { SELECTION_DIRECTION, type CellInputProps } from '@deephaven/grid';\nimport './CellDropdownField.scss';\n\nexport type CellDropdownFieldProps = CellInputProps & {\n /** The list of allowed values to display in the dropdown. */\n options: string[];\n};\n\n/**\n * A dropdown cell editor for use in an editable grid cell.\n * Renders a Picker component in place of the standard textarea used by CellInputField.\n * Intended to be supplied as the `renderCellInputComponent` prop on Grid when the\n * column restriction requires a constrained set of values.\n */\nexport function CellDropdownField({\n options,\n className = '',\n disabled = false,\n value: propsValue = '',\n onChange = EMPTY_FUNCTION,\n onCancel = EMPTY_FUNCTION,\n onDone = EMPTY_FUNCTION,\n style,\n}: CellDropdownFieldProps): JSX.Element {\n const [value, setValue] = useState(propsValue);\n // Use a ref for `isCancelled` so the focus change handler always sees the latest value\n const isCancelled = useRef(false);\n // Track whether a selection was committed so onOpenChange can distinguish ESC from a selection\n const isSelectionCommitted = useRef(false);\n // Direction to use when committing — set by capturing Enter before Spectrum consumes it\n const commitDirection = useRef<SELECTION_DIRECTION | null>(null);\n\n /**\n * Handle when the selected value changes in the Picker. Updates local state and calls onChange and onDone with the new value.\n * @param key the key of the newly selected item, or null if no item is selected\n */\n const handleChange = useCallback(\n (key: ItemKey | null) => {\n const newValue = key?.toString() ?? '';\n isSelectionCommitted.current = true;\n setValue(newValue);\n onChange(newValue);\n onDone(newValue, { direction: commitDirection.current });\n commitDirection.current = null;\n },\n [onChange, onDone]\n );\n\n /**\n * Capture Enter before Spectrum consumes it to record the intended commit direction.\n * Spectrum handles Enter to select the highlighted item and fires onChange — by the\n * time onChange fires the key event is gone, so we must capture direction here.\n */\n const handleWrapperKeyDownCapture = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Enter') {\n commitDirection.current = event.shiftKey\n ? SELECTION_DIRECTION.UP\n : SELECTION_DIRECTION.DOWN;\n }\n },\n []\n );\n\n /**\n * Handle key down events on the Picker. Currently only handles Escape to cancel the edit, but could be expanded to handle committing the edit with Enter or other keys.\n * @param event the keyboard event\n */\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n isCancelled.current = true;\n onCancel();\n }\n },\n [onCancel]\n );\n\n /**\n * When the overlay closes without a committed selection (e.g. ESC pressed while\n * the menu is open), cancel the edit. Spectrum consumes the ESC keydown to close\n * the overlay so onKeyDown never fires in that case.\n */\n const handleOpenChange = useCallback(\n (isOpen: boolean) => {\n if (!isOpen && !isSelectionCommitted.current) {\n if (commitDirection.current !== null) {\n // Enter was pressed on the already-selected item — Spectrum didn't fire\n // onChange because the value didn't change, but we should still commit.\n isSelectionCommitted.current = true;\n onDone(value, { direction: commitDirection.current });\n commitDirection.current = null;\n } else {\n isCancelled.current = true;\n onCancel();\n }\n }\n },\n [onCancel, onDone, value]\n );\n\n /**\n * Commit the current value when the Picker loses focus entirely (trigger + overlay).\n * Skipped if the edit was already cancelled via Escape.\n */\n const handleFocusChange = useCallback(\n (isFocused: boolean) => {\n if (!isFocused && !isCancelled.current) {\n onDone(value, { direction: null });\n }\n },\n [onDone, value]\n );\n\n return (\n // onKeyDownCapture captures Enter before Spectrum consumes it to set commit direction\n <div\n className={classNames(\n 'grid-cell-input-field',\n 'cell-dropdown-field',\n className\n )}\n style={style}\n onKeyDownCapture={handleWrapperKeyDownCapture}\n >\n <Picker\n UNSAFE_className=\"cell-dropdown-field-picker\"\n width=\"100%\"\n selectedKey={value || null}\n autoFocus\n defaultOpen\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onOpenChange={handleOpenChange}\n onFocusChange={handleFocusChange}\n aria-label=\"Cell value\"\n isDisabled={disabled}\n isQuiet\n >\n {options.map(option => (\n <Item key={option}>{option}</Item>\n ))}\n </Picker>\n </div>\n );\n}\n\nexport default CellDropdownField;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,IAAI,EAAEC,MAAM,QAAsB,uBAAuB;AAClE,SAASC,mBAAmB,QAA6B,iBAAiB;AAAC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ3E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iB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