@plexui/vue 0.9.0 → 0.11.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.
Files changed (188) hide show
  1. package/dist/es/components/Alert/Alert.js +6 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/Avatar/Avatar.js +3 -1
  4. package/dist/es/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/es/components/ButtonGroup/ButtonGroup.js +7 -0
  6. package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
  7. package/dist/es/components/ButtonGroup/index.js.map +1 -1
  8. package/dist/es/components/Checkbox/Checkbox.js +5 -6
  9. package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
  10. package/dist/es/components/ColorPicker/ColorPicker.js +476 -0
  11. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
  12. package/dist/es/components/ColorPicker/ColorWell.js +186 -0
  13. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
  14. package/dist/es/components/ColorPicker/index.js +3 -0
  15. package/dist/es/components/ColorPicker/index.js.map +1 -0
  16. package/dist/es/components/ColorPicker/shared.js +132 -0
  17. package/dist/es/components/ColorPicker/shared.js.map +1 -0
  18. package/dist/es/components/ContextMenu/ContextMenu.js +223 -0
  19. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
  20. package/dist/es/components/ContextMenu/index.js +2 -0
  21. package/dist/es/components/ContextMenu/index.js.map +1 -0
  22. package/dist/es/components/ContextMenu/shared.js +58 -0
  23. package/dist/es/components/ContextMenu/shared.js.map +1 -0
  24. package/dist/es/components/DatePicker/DatePicker.js +19 -3
  25. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  26. package/dist/es/components/DateRangePicker/DateRangePicker.js +1 -1
  27. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  28. package/dist/es/components/Dialog/Dialog.js +245 -25
  29. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  30. package/dist/es/components/Dialog/dialogSteps.js +85 -0
  31. package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
  32. package/dist/es/components/Dialog/dialogViewport.js +74 -0
  33. package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
  34. package/dist/es/components/Dialog/index.js +1 -1
  35. package/dist/es/components/Dialog/index.js.map +1 -1
  36. package/dist/es/components/Dialog/sheetDrag.js +2 -1
  37. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  38. package/dist/es/components/Field/Field.js +11 -3
  39. package/dist/es/components/Field/Field.js.map +1 -1
  40. package/dist/es/components/FieldGroup/FieldGroup.js +12 -1
  41. package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
  42. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
  43. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
  44. package/dist/es/components/Icon/index.js +1 -0
  45. package/dist/es/components/Icon/index.js.map +1 -1
  46. package/dist/es/components/Icon/svg/Eyedropper.js +10 -0
  47. package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
  48. package/dist/es/components/IndexBar/IndexBar.js +215 -0
  49. package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
  50. package/dist/es/components/IndexBar/index.js +2 -0
  51. package/dist/es/components/IndexBar/index.js.map +1 -0
  52. package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
  53. package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
  54. package/dist/es/components/Input/Input.js +3 -2
  55. package/dist/es/components/Input/Input.js.map +1 -1
  56. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +149 -1
  57. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  58. package/dist/es/components/Menu/Menu.js +206 -33
  59. package/dist/es/components/Menu/Menu.js.map +1 -1
  60. package/dist/es/components/Menu/index.js +1 -1
  61. package/dist/es/components/Menu/index.js.map +1 -1
  62. package/dist/es/components/Page/Page.js +43 -11
  63. package/dist/es/components/Page/Page.js.map +1 -1
  64. package/dist/es/components/PageControl/PageControl.js +210 -0
  65. package/dist/es/components/PageControl/PageControl.js.map +1 -0
  66. package/dist/es/components/PageControl/index.js +2 -0
  67. package/dist/es/components/PageControl/index.js.map +1 -0
  68. package/dist/es/components/PhoneLayout/PhoneLayout.js +50 -0
  69. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
  70. package/dist/es/components/PhoneLayout/index.js +2 -0
  71. package/dist/es/components/PhoneLayout/index.js.map +1 -0
  72. package/dist/es/components/Popover/Popover.js +5 -1
  73. package/dist/es/components/Popover/Popover.js.map +1 -1
  74. package/dist/es/components/Popover/deferredPointerDownOutside.js +59 -4
  75. package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
  76. package/dist/es/components/Select/Select.js +18 -11
  77. package/dist/es/components/Select/Select.js.map +1 -1
  78. package/dist/es/components/SelectControl/SelectControl.js +1 -0
  79. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  80. package/dist/es/components/Sidebar/Sidebar.js +21 -6
  81. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  82. package/dist/es/components/Slider/Slider.js +44 -9
  83. package/dist/es/components/Slider/Slider.js.map +1 -1
  84. package/dist/es/components/Stepper/Stepper.js +195 -0
  85. package/dist/es/components/Stepper/Stepper.js.map +1 -0
  86. package/dist/es/components/Stepper/index.js +2 -0
  87. package/dist/es/components/Stepper/index.js.map +1 -0
  88. package/dist/es/components/SwipeActions/SwipeActions.js +374 -0
  89. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
  90. package/dist/es/components/SwipeActions/index.js +2 -0
  91. package/dist/es/components/SwipeActions/index.js.map +1 -0
  92. package/dist/es/components/Switch/Switch.js +3 -1
  93. package/dist/es/components/Switch/Switch.js.map +1 -1
  94. package/dist/es/components/TabBar/TabBar.js +205 -0
  95. package/dist/es/components/TabBar/TabBar.js.map +1 -0
  96. package/dist/es/components/TabBar/index.js +2 -0
  97. package/dist/es/components/TabBar/index.js.map +1 -0
  98. package/dist/es/components/Tabs/Tabs.js +10 -2
  99. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  100. package/dist/es/components/TagInput/TagInput.js +3 -46
  101. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  102. package/dist/es/components/Textarea/Textarea.js +2 -0
  103. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  104. package/dist/es/components/Tip/Tip.js +276 -0
  105. package/dist/es/components/Tip/Tip.js.map +1 -0
  106. package/dist/es/components/Tip/index.js +2 -0
  107. package/dist/es/components/Tip/index.js.map +1 -0
  108. package/dist/es/components/Toast/ToastRenderer.js +30 -13
  109. package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
  110. package/dist/es/components/Toast/Toaster.js +17 -6
  111. package/dist/es/components/Toast/Toaster.js.map +1 -1
  112. package/dist/es/components/Toast/toastLifecycle.js +113 -1
  113. package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
  114. package/dist/es/components/Toolbar/Toolbar.js +37 -6
  115. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  116. package/dist/es/components/Toolbar/index.js.map +1 -1
  117. package/dist/es/components/Tooltip/slot.js +3 -3
  118. package/dist/es/components/Tooltip/slot.js.map +1 -1
  119. package/dist/es/composables/useEscCloseStack.js +8 -4
  120. package/dist/es/composables/useEscCloseStack.js.map +1 -1
  121. package/dist/es/lib/fieldRow.js +15 -2
  122. package/dist/es/lib/fieldRow.js.map +1 -1
  123. package/dist/es/lib/floatingBoundary.js +3 -1
  124. package/dist/es/lib/floatingBoundary.js.map +1 -1
  125. package/dist/es/lib/helpers.js +21 -0
  126. package/dist/es/lib/helpers.js.map +1 -1
  127. package/dist/es/lib/menuSubmenuPlacement.js +51 -6
  128. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
  129. package/dist/es/lib/menuTriggerCover.js +70 -0
  130. package/dist/es/lib/menuTriggerCover.js.map +1 -0
  131. package/dist/es/lib/phoneLayout.js +16 -0
  132. package/dist/es/lib/phoneLayout.js.map +1 -0
  133. package/dist/es/lib/scrollEdges.js +34 -0
  134. package/dist/es/lib/scrollEdges.js.map +1 -0
  135. package/dist/es/lib/toastRegion.js +6 -0
  136. package/dist/es/lib/toastRegion.js.map +1 -0
  137. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +13 -0
  138. package/dist/types/components/ButtonGroup/index.d.ts +1 -1
  139. package/dist/types/components/ColorPicker/ColorPicker.d.ts +244 -0
  140. package/dist/types/components/ColorPicker/ColorWell.d.ts +334 -0
  141. package/dist/types/components/ColorPicker/index.d.ts +3 -0
  142. package/dist/types/components/ColorPicker/shared.d.ts +69 -0
  143. package/dist/types/components/ContextMenu/ContextMenu.d.ts +128 -0
  144. package/dist/types/components/ContextMenu/index.d.ts +1 -0
  145. package/dist/types/components/ContextMenu/shared.d.ts +51 -0
  146. package/dist/types/components/DatePicker/DatePicker.d.ts +24 -4
  147. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +4 -4
  148. package/dist/types/components/Dialog/Dialog.d.ts +100 -4
  149. package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
  150. package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
  151. package/dist/types/components/Dialog/index.d.ts +1 -1
  152. package/dist/types/components/Field/Field.d.ts +21 -2
  153. package/dist/types/components/FieldGroup/FieldGroup.d.ts +18 -1
  154. package/dist/types/components/Icon/index.d.ts +1 -0
  155. package/dist/types/components/Icon/svg/Eyedropper.d.ts +3 -0
  156. package/dist/types/components/IndexBar/IndexBar.d.ts +112 -0
  157. package/dist/types/components/IndexBar/index.d.ts +1 -0
  158. package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
  159. package/dist/types/components/Menu/Menu.d.ts +153 -40
  160. package/dist/types/components/Menu/index.d.ts +1 -1
  161. package/dist/types/components/Page/Page.d.ts +13 -5
  162. package/dist/types/components/PageControl/PageControl.d.ts +216 -0
  163. package/dist/types/components/PageControl/index.d.ts +1 -0
  164. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +21 -0
  165. package/dist/types/components/PhoneLayout/index.d.ts +1 -0
  166. package/dist/types/components/Popover/deferredPointerDownOutside.d.ts +1 -1
  167. package/dist/types/components/Select/Select.d.ts +6 -6
  168. package/dist/types/components/Stepper/Stepper.d.ts +338 -0
  169. package/dist/types/components/Stepper/index.d.ts +1 -0
  170. package/dist/types/components/SwipeActions/SwipeActions.d.ts +135 -0
  171. package/dist/types/components/SwipeActions/index.d.ts +1 -0
  172. package/dist/types/components/TabBar/TabBar.d.ts +405 -0
  173. package/dist/types/components/TabBar/index.d.ts +1 -0
  174. package/dist/types/components/Tip/Tip.d.ts +146 -0
  175. package/dist/types/components/Tip/index.d.ts +1 -0
  176. package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
  177. package/dist/types/components/Toolbar/Toolbar.d.ts +26 -9
  178. package/dist/types/components/Toolbar/index.d.ts +1 -1
  179. package/dist/types/components/Tooltip/CopyTooltip.d.ts +1 -1
  180. package/dist/types/composables/useEscCloseStack.d.ts +2 -2
  181. package/dist/types/lib/fieldRow.d.ts +5 -0
  182. package/dist/types/lib/helpers.d.ts +6 -0
  183. package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
  184. package/dist/types/lib/menuTriggerCover.d.ts +23 -0
  185. package/dist/types/lib/phoneLayout.d.ts +11 -0
  186. package/dist/types/lib/scrollEdges.d.ts +16 -0
  187. package/dist/types/lib/toastRegion.d.ts +5 -0
  188. package/package.json +2 -2
@@ -0,0 +1,476 @@
1
+ import { computed, defineComponent, h, ref, shallowRef, useId } from "vue";
2
+ import s from "@plexui/styles/components/ColorPicker/ColorPicker.module.css";
3
+ import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "../ContextMenu/index.js";
4
+ import { Plus, RemoveTrash } from "../Icon/index.js";
5
+ import { MenuItem } from "../Menu/index.js";
6
+ import { PageControl } from "../PageControl/index.js";
7
+ import { prefersReducedMotion } from "../../lib/helpers.js";
8
+ import { SegmentedControl, SegmentedControlOption } from "../SegmentedControl/index.js";
9
+ import { SliderRoot, SliderThumb, SliderTrack } from "../Slider/sliderPrimitive.js";
10
+ import { alphaPercent, channelTrack, COLOR_PICKER_CHANNELS, COLOR_PICKER_GRID_COLUMNS, COLOR_PICKER_MODES, COLOR_PICKER_SWATCHES_PER_PAGE, cssColor, formatColor, gridColor, gridIndex, gridMove, hexDigits, listMove, opacityTrack, parseColor, parseNumber, sameRgb, spectrumColor, spectrumPoint, swatchPageCount, } from "./shared.js";
11
+ // Vue port of packages/ui/src/components/ColorPicker/ColorPicker.tsx: the same DOM (the Mode segmented control,
12
+ // Grid, Spectrum or Sliders, the Opacity slider and the saved colors with Add), keys and pointer. React's
13
+ // `value` + `onChange` become `value` + `update:value` (`v-model:value`) and `change`; `onModeChange` becomes
14
+ // `update:mode` (`v-model:mode`) and `modeChange`; `onSwatchesChange` becomes `update:swatches`
15
+ // (`v-model:swatches`) and `swatchesChange`.
16
+ const BLACK = { r: 0, g: 0, b: 0, a: 1 };
17
+ const GRID_CELLS = COLOR_PICKER_GRID_COLUMNS * 10;
18
+ const NAVIGATION_KEYS = ["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp", "Home", "End"];
19
+ /** A slider on a colored track, after the kit's Opacity slider (515:47434): a 36px ring on a 40px capsule. */
20
+ const colorSlider = ({ labelId, value, max, track, valueText, onChange }) => h("div", { class: s.Track, style: { "--color-picker-track": track } }, [
21
+ h(SliderRoot, {
22
+ class: s.SliderRoot,
23
+ min: 0,
24
+ max,
25
+ step: 1,
26
+ values: [value],
27
+ onValueChange: ([next]) => onChange(next ?? value),
28
+ }, {
29
+ default: () => [
30
+ h(SliderTrack, { class: s.SliderTrack }),
31
+ h(SliderThumb, { "class": s.Knob, "aria-labelledby": labelId, "aria-valuetext": valueText }),
32
+ ],
33
+ }),
34
+ ]);
35
+ /** The value beside a slider, after the kit's Percentage field (515:47438); typing a value and Enter or leaving it applies it. */
36
+ const ColorField = defineComponent({
37
+ name: "ColorPickerField",
38
+ props: {
39
+ value: { type: String, required: true },
40
+ label: String,
41
+ labelledBy: String,
42
+ inputMode: { type: String, required: true },
43
+ wide: { type: Boolean, default: false },
44
+ onCommit: { type: Function, required: true },
45
+ },
46
+ setup(props) {
47
+ const draft = ref(null);
48
+ const commit = () => {
49
+ if (draft.value !== null)
50
+ props.onCommit(draft.value);
51
+ draft.value = null;
52
+ };
53
+ return () => h("input", {
54
+ "class": s.Field,
55
+ "data-wide": props.wide ? "" : undefined,
56
+ "type": "text",
57
+ "inputmode": props.inputMode,
58
+ "autocomplete": "off",
59
+ "spellcheck": "false",
60
+ "aria-label": props.label,
61
+ "aria-labelledby": props.labelledBy,
62
+ "value": draft.value ?? props.value,
63
+ "onFocus": (event) => {
64
+ draft.value = props.value;
65
+ event.currentTarget.select();
66
+ },
67
+ "onInput": (event) => {
68
+ draft.value = event.currentTarget.value;
69
+ },
70
+ "onBlur": commit,
71
+ "onKeydown": (event) => {
72
+ if (event.key !== "Enter")
73
+ return;
74
+ event.preventDefault();
75
+ commit();
76
+ },
77
+ });
78
+ },
79
+ });
80
+ /** The kit's Color Grid: twelve hues across, grays then nine shades down; the selected cell has a 3px white ring. */
81
+ const colorGrid = (color, onSelect) => {
82
+ const selected = gridIndex(color);
83
+ const focusable = selected === -1 ? 0 : selected;
84
+ const onKeydown = (event) => {
85
+ const from = Number(event.target.dataset.index);
86
+ if (!Number.isInteger(from) || !NAVIGATION_KEYS.includes(event.key))
87
+ return;
88
+ event.preventDefault();
89
+ const next = gridMove(from, event.key);
90
+ if (next === from)
91
+ return;
92
+ const cell = event.currentTarget.querySelector(`[data-index="${next}"]`);
93
+ cell?.focus();
94
+ onSelect({ ...(parseColor(gridColor(next)) ?? BLACK), a: color.a });
95
+ };
96
+ return h("div", { "role": "radiogroup", "aria-label": "Grid", "class": s.Grid, onKeydown }, Array.from({ length: GRID_CELLS }, (_, index) => {
97
+ const hex = gridColor(index);
98
+ return h("button", {
99
+ "key": hex,
100
+ "type": "button",
101
+ "role": "radio",
102
+ "aria-checked": index === selected,
103
+ "aria-label": hex.toUpperCase(),
104
+ "tabindex": index === focusable ? 0 : -1,
105
+ "data-index": index,
106
+ "class": s.Cell,
107
+ "style": { backgroundColor: hex },
108
+ "onClick": () => onSelect({ ...(parseColor(hex) ?? BLACK), a: color.a }),
109
+ });
110
+ }));
111
+ };
112
+ const SPECTRUM_STEP = 0.01;
113
+ /**
114
+ * The spectrum: hue from top to bottom, white to the full hue to black across. Up and Down change the hue, Left
115
+ * and Right the lightness, by 1% (10% with Shift or Page Up and Page Down).
116
+ */
117
+ const ColorSpectrum = defineComponent({
118
+ name: "ColorPickerSpectrum",
119
+ props: {
120
+ color: { type: Object, required: true },
121
+ onSelect: { type: Function, required: true },
122
+ },
123
+ setup(props) {
124
+ const held = shallowRef({ point: spectrumPoint(props.color), digits: hexDigits(props.color) });
125
+ // The point the picker last chose stays while the color is the one it chose: a hex color loses the exact point,
126
+ // and a gray or white has no hue of its own.
127
+ const point = computed(() => (held.value.digits === hexDigits(props.color) ? held.value.point : spectrumPoint(props.color, held.value.point)));
128
+ const choose = (next) => {
129
+ const clamped = { x: Math.min(1, Math.max(0, next.x)), y: Math.min(1, Math.max(0, next.y)) };
130
+ const chosen = spectrumColor(clamped, props.color.a);
131
+ held.value = { point: clamped, digits: hexDigits(chosen) };
132
+ props.onSelect(chosen);
133
+ };
134
+ const fromPointer = (event) => {
135
+ const box = event.currentTarget.getBoundingClientRect();
136
+ if (box.width === 0 || box.height === 0)
137
+ return;
138
+ choose({ x: (event.clientX - box.left) / box.width, y: (event.clientY - box.top) / box.height });
139
+ };
140
+ const onKeydown = (event) => {
141
+ const { x, y } = point.value;
142
+ const step = event.shiftKey ? SPECTRUM_STEP * 10 : SPECTRUM_STEP;
143
+ const moves = {
144
+ ArrowLeft: { x: x - step, y },
145
+ ArrowRight: { x: x + step, y },
146
+ ArrowUp: { x, y: y - step },
147
+ ArrowDown: { x, y: y + step },
148
+ PageUp: { x, y: y - SPECTRUM_STEP * 10 },
149
+ PageDown: { x, y: y + SPECTRUM_STEP * 10 },
150
+ };
151
+ const next = moves[event.key];
152
+ if (!next)
153
+ return;
154
+ event.preventDefault();
155
+ choose(next);
156
+ };
157
+ return () => {
158
+ const { x, y } = point.value;
159
+ const hue = Math.round(y * 360);
160
+ return h("div", {
161
+ "role": "slider",
162
+ "tabindex": 0,
163
+ "aria-label": "Spectrum",
164
+ "aria-valuemin": 0,
165
+ "aria-valuemax": 360,
166
+ "aria-valuenow": hue,
167
+ "aria-valuetext": `#${hexDigits(props.color)}, hue ${hue}°, lightness ${Math.round((1 - x) * 100)}%`,
168
+ "class": s.Spectrum,
169
+ "onPointerdown": (event) => {
170
+ if (event.button !== 0)
171
+ return;
172
+ const target = event.currentTarget;
173
+ target.setPointerCapture?.(event.pointerId);
174
+ target.focus({ preventScroll: true });
175
+ fromPointer(event);
176
+ },
177
+ "onPointermove": (event) => {
178
+ if (event.currentTarget.hasPointerCapture?.(event.pointerId))
179
+ fromPointer(event);
180
+ },
181
+ onKeydown,
182
+ }, [h("span", { class: s.Loupe, style: { left: `${x * 100}%`, top: `${y * 100}%`, backgroundColor: cssColor(props.color, 1) } })]);
183
+ };
184
+ },
185
+ });
186
+ /** Red, Green and Blue, each a slider and a field from 0 to 255, then the Hex field. */
187
+ const colorSliders = (uid, color, onSelect) => h("div", { class: s.Sliders }, [
188
+ ...COLOR_PICKER_CHANNELS.map(({ channel, label }) => {
189
+ const labelId = `${uid}-${channel}`;
190
+ return h("div", { key: channel, class: s.Channel }, [
191
+ h("span", { id: labelId, class: s.Label }, label),
192
+ h("div", { class: s.Row }, [
193
+ colorSlider({
194
+ labelId,
195
+ value: color[channel],
196
+ max: 255,
197
+ track: channelTrack(color, channel),
198
+ valueText: String(color[channel]),
199
+ onChange: (next) => onSelect({ ...color, [channel]: next }),
200
+ }),
201
+ h(ColorField, {
202
+ value: String(color[channel]),
203
+ labelledBy: labelId,
204
+ inputMode: "numeric",
205
+ onCommit: (text) => {
206
+ const next = parseNumber(text, 0, 255);
207
+ if (next !== null)
208
+ onSelect({ ...color, [channel]: next });
209
+ },
210
+ }),
211
+ ]),
212
+ ]);
213
+ }),
214
+ h("div", { class: s.Hex }, [
215
+ h("span", { id: `${uid}-hex`, class: s.Label }, "Hex Color #"),
216
+ h(ColorField, {
217
+ value: hexDigits(color),
218
+ labelledBy: `${uid}-hex`,
219
+ inputMode: "text",
220
+ wide: true,
221
+ onCommit: (text) => {
222
+ const next = parseColor(text);
223
+ if (next)
224
+ onSelect({ ...next, a: color.a });
225
+ },
226
+ }),
227
+ ]),
228
+ ]);
229
+ const colorName = (color) => `#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : ""}`;
230
+ /**
231
+ * The current color, and the saved colors in pages of two rows of five with Add after the last (kit Swatches
232
+ * 515:46585). A saved color is a radio; Delete or Backspace, or Delete in its context menu, removes it.
233
+ */
234
+ const ColorSwatches = defineComponent({
235
+ name: "ColorPickerSwatches",
236
+ props: {
237
+ color: { type: Object, required: true },
238
+ swatches: { type: Array, required: true },
239
+ onSelect: { type: Function, required: true },
240
+ onChange: { type: Function, required: true },
241
+ },
242
+ setup(props) {
243
+ const pagesRef = ref(null);
244
+ const page = ref(0);
245
+ const reveal = (element) => element?.scrollIntoView?.({ block: "nearest", inline: "nearest" });
246
+ const remove = (index, pages) => {
247
+ const { swatches } = props;
248
+ props.onChange(swatches.filter((_, i) => i !== index));
249
+ // Focus stays in the list: on the color that takes the place, the one before at the end, or Add.
250
+ const target = Math.min(index, swatches.length - 2);
251
+ requestAnimationFrame(() => {
252
+ const next = target >= 0 ? pages?.querySelector(`[data-swatch="${target}"]`) : pages?.querySelector("[data-add]");
253
+ next?.focus();
254
+ reveal(next);
255
+ });
256
+ };
257
+ return () => {
258
+ const { color, swatches } = props;
259
+ const saved = swatches.map((hex) => parseColor(hex) ?? BLACK);
260
+ const current = formatColor(color);
261
+ const checked = saved.findIndex((swatch) => sameRgb(swatch, color) && alphaPercent(swatch.a) === alphaPercent(color.a));
262
+ const focusable = checked === -1 ? 0 : checked;
263
+ const pageCount = swatchPageCount(swatches.length);
264
+ const onKeydown = (event) => {
265
+ const from = Number(event.target.dataset.swatch);
266
+ if (!Number.isInteger(from))
267
+ return;
268
+ if (event.key === "Delete" || event.key === "Backspace") {
269
+ event.preventDefault();
270
+ remove(from, event.currentTarget);
271
+ return;
272
+ }
273
+ if (!NAVIGATION_KEYS.includes(event.key))
274
+ return;
275
+ event.preventDefault();
276
+ const next = listMove(from, swatches.length, event.key);
277
+ if (next === from)
278
+ return;
279
+ const element = event.currentTarget.querySelector(`[data-swatch="${next}"]`);
280
+ element?.focus();
281
+ reveal(element);
282
+ const swatch = saved[next];
283
+ if (swatch)
284
+ props.onSelect(swatch);
285
+ };
286
+ const items = [...swatches.map((hex, index) => ({ hex, index })), null];
287
+ const pages = Array.from({ length: pageCount }, (_, p) => items.slice(p * COLOR_PICKER_SWATCHES_PER_PAGE, (p + 1) * COLOR_PICKER_SWATCHES_PER_PAGE));
288
+ const swatchButton = (index) => {
289
+ const swatch = saved[index] ?? BLACK;
290
+ return h(ContextMenu, { key: `${index}-${swatches[index]}` }, () => [
291
+ h(ContextMenuTrigger, null, () => h("button", {
292
+ "type": "button",
293
+ "role": "radio",
294
+ "aria-checked": index === checked,
295
+ "aria-label": colorName(swatch),
296
+ "tabindex": index === focusable ? 0 : -1,
297
+ "data-swatch": index,
298
+ "class": s.Swatch,
299
+ "onClick": () => props.onSelect(swatch),
300
+ }, [h("span", { class: s.SwatchFill, style: { backgroundColor: cssColor(swatch) } })])),
301
+ h(ContextMenuContent, null, () => h(MenuItem, { danger: true, onSelect: () => remove(index, pagesRef.value) }, () => [h(RemoveTrash, { width: 20, height: 20 }), " Delete"])),
302
+ ]);
303
+ };
304
+ const addButton = () => h("button", {
305
+ "key": "add",
306
+ "type": "button",
307
+ "data-add": "",
308
+ "class": s.Add,
309
+ "aria-label": "Add color",
310
+ "onClick": (event) => {
311
+ props.onChange([...swatches, current]);
312
+ const add = event.currentTarget;
313
+ requestAnimationFrame(() => reveal(add));
314
+ },
315
+ }, [h(Plus)]);
316
+ return h("div", { class: s.Swatches }, [
317
+ h("div", { "role": "img", "aria-label": `Selected color ${colorName(color)}`, "class": s.Current }, [
318
+ h("span", { class: s.CurrentFill, style: { backgroundColor: cssColor(color) } }),
319
+ ]),
320
+ h("div", { class: s.Saved }, [
321
+ h("div", {
322
+ "ref": pagesRef,
323
+ "role": "radiogroup",
324
+ "aria-label": "Saved colors",
325
+ "class": s.Pages,
326
+ onKeydown,
327
+ "onScroll": (event) => {
328
+ const { scrollLeft, clientWidth } = event.currentTarget;
329
+ if (clientWidth > 0)
330
+ page.value = Math.round(scrollLeft / clientWidth);
331
+ },
332
+ }, pages.map((pageItems, p) => h("div", { key: p, class: s.Page }, pageItems.map((item) => (item === null ? addButton() : swatchButton(item.index)))))),
333
+ // The row of the page control keeps its height with one page, so the picker does not change size.
334
+ h("div", { class: s.PageControlRow }, pageCount > 1
335
+ ? [
336
+ h(PageControl, {
337
+ "count": pageCount,
338
+ "value": Math.min(page.value, pageCount - 1),
339
+ "ariaLabel": "Saved color pages",
340
+ "onUpdate:value": (index) => {
341
+ const pagesElement = pagesRef.value;
342
+ if (!pagesElement)
343
+ return;
344
+ page.value = index;
345
+ pagesElement.scrollTo?.({ left: index * pagesElement.clientWidth, behavior: prefersReducedMotion() ? "auto" : "smooth" });
346
+ },
347
+ }),
348
+ ]
349
+ : []),
350
+ ]),
351
+ ]);
352
+ };
353
+ },
354
+ });
355
+ const ColorPickerComponent = defineComponent({
356
+ name: "ColorPicker",
357
+ inheritAttrs: false,
358
+ props: {
359
+ /** The `id` of the picker. */
360
+ id: String,
361
+ /** The controlled color, `#rrggbb` or `#rrggbbaa`. Bind with `v-model:value`. */
362
+ value: { type: String, default: undefined },
363
+ /** The color when it is initially rendered. Use when you do not need to control the color. @default "#000000" */
364
+ defaultValue: { type: String, default: undefined },
365
+ /** Shows the Opacity slider, as `supportsAlpha` of the system picker. @default true */
366
+ supportsAlpha: { type: Boolean, default: true },
367
+ /** The controlled way to choose a color. Bind with `v-model:mode`. */
368
+ mode: { type: String, default: undefined },
369
+ /** The way to choose a color when the picker is initially rendered. @default "grid" */
370
+ defaultMode: { type: String, default: "grid" },
371
+ /** The controlled saved colors. Bind with `v-model:swatches`. */
372
+ swatches: { type: Array, default: undefined },
373
+ /** The saved colors when the picker is initially rendered. @default [] */
374
+ defaultSwatches: { type: Array, default: undefined },
375
+ /** Accessible name of the picker. @default "Colors" */
376
+ ariaLabel: { type: String, default: "Colors" },
377
+ },
378
+ emits: {
379
+ /** The color changed: `#rrggbb`, or `#rrggbbaa` when it is not opaque */
380
+ "update:value": (value) => typeof value === "string",
381
+ /** The color changed (React `onChange`) */
382
+ "change": (value) => typeof value === "string",
383
+ /** Another of Grid, Spectrum and Sliders was chosen */
384
+ "update:mode": (mode) => typeof mode === "string",
385
+ /** Another way was chosen (React `onModeChange`) */
386
+ "modeChange": (mode) => typeof mode === "string",
387
+ /** Add saved the current color or Delete removed one */
388
+ "update:swatches": (swatches) => Array.isArray(swatches),
389
+ /** The saved colors changed (React `onSwatchesChange`) */
390
+ "swatchesChange": (swatches) => Array.isArray(swatches),
391
+ },
392
+ setup(props, { attrs, emit }) {
393
+ const uid = useId();
394
+ const internalValue = ref(props.defaultValue ?? "#000000");
395
+ const color = computed(() => parseColor(props.value ?? internalValue.value) ?? BLACK);
396
+ const internalMode = ref(props.defaultMode);
397
+ const mode = computed(() => props.mode ?? internalMode.value);
398
+ const internalSwatches = ref(props.defaultSwatches ?? []);
399
+ const swatches = computed(() => props.swatches ?? internalSwatches.value);
400
+ const commit = (next) => {
401
+ const formatted = formatColor(props.supportsAlpha ? next : { ...next, a: 1 });
402
+ // Only a color other than the one shown is reported; an owner that keeps its color hears every new choice.
403
+ if (formatted === formatColor(color.value))
404
+ return;
405
+ // A controlled color changes only when the owner passes it back.
406
+ if (props.value === undefined)
407
+ internalValue.value = formatted;
408
+ emit("update:value", formatted);
409
+ emit("change", formatted);
410
+ };
411
+ const changeMode = (next) => {
412
+ const chosen = next;
413
+ if (props.mode === undefined)
414
+ internalMode.value = chosen;
415
+ emit("update:mode", chosen);
416
+ emit("modeChange", chosen);
417
+ };
418
+ const changeSwatches = (next) => {
419
+ if (props.swatches === undefined)
420
+ internalSwatches.value = next;
421
+ emit("update:swatches", next);
422
+ emit("swatchesChange", next);
423
+ };
424
+ return () => {
425
+ const current = color.value;
426
+ const opacityId = `${uid}-opacity`;
427
+ return h("div", {
428
+ ...attrs,
429
+ "id": props.id,
430
+ "role": "group",
431
+ "aria-label": props.ariaLabel,
432
+ "class": [s.ColorPicker, attrs.class],
433
+ "data-mode": mode.value,
434
+ }, [
435
+ h(SegmentedControl, { "aria-label": "Mode", "value": mode.value, "block": true, "class": s.Modes, "onChange": changeMode }, { default: () => COLOR_PICKER_MODES.map((option) => h(SegmentedControlOption, { key: option.value, value: option.value }, () => option.label)) }),
436
+ h("div", { class: s.Body }, [
437
+ mode.value === "grid" ? colorGrid(current, commit) : null,
438
+ mode.value === "spectrum" ? h(ColorSpectrum, { color: current, onSelect: commit }) : null,
439
+ mode.value === "sliders" ? colorSliders(uid, current, commit) : null,
440
+ ]),
441
+ props.supportsAlpha
442
+ ? h("div", { class: s.Opacity }, [
443
+ h("span", { id: opacityId, class: s.Label }, "Opacity"),
444
+ h("div", { class: s.Row }, [
445
+ colorSlider({
446
+ labelId: opacityId,
447
+ value: alphaPercent(current.a),
448
+ max: 100,
449
+ track: opacityTrack(current),
450
+ valueText: `${alphaPercent(current.a)}%`,
451
+ onChange: (percent) => commit({ ...color.value, a: percent / 100 }),
452
+ }),
453
+ h(ColorField, {
454
+ value: `${alphaPercent(current.a)}%`,
455
+ labelledBy: opacityId,
456
+ inputMode: "numeric",
457
+ onCommit: (text) => {
458
+ const percent = parseNumber(text, 0, 100);
459
+ if (percent !== null)
460
+ commit({ ...color.value, a: percent / 100 });
461
+ },
462
+ }),
463
+ ]),
464
+ ])
465
+ : null,
466
+ h(ColorSwatches, { color: current, swatches: swatches.value, onSelect: commit, onChange: changeSwatches }),
467
+ ]);
468
+ };
469
+ },
470
+ });
471
+ /**
472
+ * The system color picker of iOS 26 (kit Color Picker - iPhone 0:5275): Grid, Spectrum and Sliders, the Opacity
473
+ * slider, and the saved colors with Add. Show it inside a Popover or a Sheet, or use `ColorWell`, which does.
474
+ */
475
+ export const ColorPicker = ColorPickerComponent;
476
+ //# sourceMappingURL=ColorPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/ColorPicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAA6B,MAAM,KAAK,CAAA;AACrG,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC7F,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,8BAA8B,EAC9B,QAAQ,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,WAAW,EACX,OAAO,EACP,aAAa,EACb,aAAa,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AAC;gCACV,OAAO,EAAE,SAAS;gCAClB,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;gCAC9B,GAAG,EAAE,GAAG;gCACR,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC;gCAC5B,SAAS,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;gCACxC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,CAAC;6BACpE,CAAC;4BACF,CAAC,CAAC,UAAU,EAAE;gCACZ,KAAK,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;gCACpC,UAAU,EAAE,SAAS;gCACrB,SAAS,EAAE,SAAS;gCACpB,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE;oCACzB,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;oCACzC,IAAI,OAAO,KAAK,IAAI;wCAAE,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,CAAC,CAAA;gCACpE,CAAC;6BACF,CAAC;yBACH,CAAC;qBACH,CAAC;oBACJ,CAAC,CAAC,IAAI;gBACR,CAAC,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;aAC3G,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAIF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAA","sourcesContent":["import { computed, defineComponent, h, ref, shallowRef, useId, type PropType, type VNode } from \"vue\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { ContextMenu, ContextMenuContent, ContextMenuTrigger } from \"../ContextMenu/index.js\"\nimport { Plus, RemoveTrash } from \"../Icon/index.js\"\nimport { MenuItem } from \"../Menu/index.js\"\nimport { PageControl } from \"../PageControl/index.js\"\nimport { prefersReducedMotion } from \"../../lib/helpers.js\"\nimport { SegmentedControl, SegmentedControlOption } from \"../SegmentedControl/index.js\"\nimport { SliderRoot, SliderThumb, SliderTrack } from \"../Slider/sliderPrimitive.js\"\nimport {\n alphaPercent,\n channelTrack,\n COLOR_PICKER_CHANNELS,\n COLOR_PICKER_GRID_COLUMNS,\n COLOR_PICKER_MODES,\n COLOR_PICKER_SWATCHES_PER_PAGE,\n cssColor,\n formatColor,\n gridColor,\n gridIndex,\n gridMove,\n hexDigits,\n listMove,\n opacityTrack,\n parseColor,\n parseNumber,\n sameRgb,\n spectrumColor,\n spectrumPoint,\n swatchPageCount,\n type ColorPickerMode,\n type Rgba,\n type SpectrumPoint,\n} from \"./shared.js\"\n\n// Vue port of packages/ui/src/components/ColorPicker/ColorPicker.tsx: the same DOM (the Mode segmented control,\n// Grid, Spectrum or Sliders, the Opacity slider and the saved colors with Add), keys and pointer. React's\n// `value` + `onChange` become `value` + `update:value` (`v-model:value`) and `change`; `onModeChange` becomes\n// `update:mode` (`v-model:mode`) and `modeChange`; `onSwatchesChange` becomes `update:swatches`\n// (`v-model:swatches`) and `swatchesChange`.\n\nconst BLACK: Rgba = { r: 0, g: 0, b: 0, a: 1 }\nconst GRID_CELLS = COLOR_PICKER_GRID_COLUMNS * 10\nconst NAVIGATION_KEYS = [\"ArrowRight\", \"ArrowLeft\", \"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"]\n\ntype Select = (color: Rgba) => void\n\ntype ColorSliderOptions = {\n labelId: string\n value: number\n max: number\n track: string\n valueText: string\n onChange: (value: number) => void\n}\n\n/** A slider on a colored track, after the kit's Opacity slider (515:47434): a 36px ring on a 40px capsule. */\nconst colorSlider = ({ labelId, value, max, track, valueText, onChange }: ColorSliderOptions) =>\n h(\"div\", { class: s.Track, style: { \"--color-picker-track\": track } }, [\n h(\n SliderRoot,\n {\n class: s.SliderRoot,\n min: 0,\n max,\n step: 1,\n values: [value],\n onValueChange: ([next]: number[]) => onChange(next ?? value),\n },\n {\n default: () => [\n h(SliderTrack, { class: s.SliderTrack }),\n h(SliderThumb, { \"class\": s.Knob, \"aria-labelledby\": labelId, \"aria-valuetext\": valueText }),\n ],\n },\n ),\n ])\n\n/** The value beside a slider, after the kit's Percentage field (515:47438); typing a value and Enter or leaving it applies it. */\nconst ColorField = defineComponent({\n name: \"ColorPickerField\",\n props: {\n value: { type: String, required: true },\n label: String,\n labelledBy: String,\n inputMode: { type: String as PropType<\"numeric\" | \"text\">, required: true },\n wide: { type: Boolean, default: false },\n onCommit: { type: Function as PropType<(text: string) => void>, required: true },\n },\n setup(props) {\n const draft = ref<string | null>(null)\n const commit = () => {\n if (draft.value !== null) props.onCommit(draft.value)\n draft.value = null\n }\n return () =>\n h(\"input\", {\n \"class\": s.Field,\n \"data-wide\": props.wide ? \"\" : undefined,\n \"type\": \"text\",\n \"inputmode\": props.inputMode,\n \"autocomplete\": \"off\",\n \"spellcheck\": \"false\",\n \"aria-label\": props.label,\n \"aria-labelledby\": props.labelledBy,\n \"value\": draft.value ?? props.value,\n \"onFocus\": (event: FocusEvent) => {\n draft.value = props.value\n ;(event.currentTarget as HTMLInputElement).select()\n },\n \"onInput\": (event: Event) => {\n draft.value = (event.currentTarget as HTMLInputElement).value\n },\n \"onBlur\": commit,\n \"onKeydown\": (event: KeyboardEvent) => {\n if (event.key !== \"Enter\") return\n event.preventDefault()\n commit()\n },\n })\n },\n})\n\n/** The kit's Color Grid: twelve hues across, grays then nine shades down; the selected cell has a 3px white ring. */\nconst colorGrid = (color: Rgba, onSelect: Select) => {\n const selected = gridIndex(color)\n const focusable = selected === -1 ? 0 : selected\n\n const onKeydown = (event: KeyboardEvent) => {\n const from = Number((event.target as HTMLElement).dataset.index)\n if (!Number.isInteger(from) || !NAVIGATION_KEYS.includes(event.key)) return\n event.preventDefault()\n const next = gridMove(from, event.key)\n if (next === from) return\n const cell = (event.currentTarget as HTMLElement).querySelector<HTMLElement>(`[data-index=\"${next}\"]`)\n cell?.focus()\n onSelect({ ...(parseColor(gridColor(next)) ?? BLACK), a: color.a })\n }\n\n return h(\n \"div\",\n { \"role\": \"radiogroup\", \"aria-label\": \"Grid\", \"class\": s.Grid, onKeydown },\n Array.from({ length: GRID_CELLS }, (_, index) => {\n const hex = gridColor(index)\n return h(\"button\", {\n \"key\": hex,\n \"type\": \"button\",\n \"role\": \"radio\",\n \"aria-checked\": index === selected,\n \"aria-label\": hex.toUpperCase(),\n \"tabindex\": index === focusable ? 0 : -1,\n \"data-index\": index,\n \"class\": s.Cell,\n \"style\": { backgroundColor: hex },\n \"onClick\": () => onSelect({ ...(parseColor(hex) ?? BLACK), a: color.a }),\n })\n }),\n )\n}\n\nconst SPECTRUM_STEP = 0.01\n\n/**\n * The spectrum: hue from top to bottom, white to the full hue to black across. Up and Down change the hue, Left\n * and Right the lightness, by 1% (10% with Shift or Page Up and Page Down).\n */\nconst ColorSpectrum = defineComponent({\n name: \"ColorPickerSpectrum\",\n props: {\n color: { type: Object as PropType<Rgba>, required: true },\n onSelect: { type: Function as PropType<Select>, required: true },\n },\n setup(props) {\n const held = shallowRef<{ point: SpectrumPoint; digits: string }>({ point: spectrumPoint(props.color), digits: hexDigits(props.color) })\n // The point the picker last chose stays while the color is the one it chose: a hex color loses the exact point,\n // and a gray or white has no hue of its own.\n const point = computed(() => (held.value.digits === hexDigits(props.color) ? held.value.point : spectrumPoint(props.color, held.value.point)))\n\n const choose = (next: SpectrumPoint) => {\n const clamped = { x: Math.min(1, Math.max(0, next.x)), y: Math.min(1, Math.max(0, next.y)) }\n const chosen = spectrumColor(clamped, props.color.a)\n held.value = { point: clamped, digits: hexDigits(chosen) }\n props.onSelect(chosen)\n }\n\n const fromPointer = (event: PointerEvent) => {\n const box = (event.currentTarget as HTMLElement).getBoundingClientRect()\n if (box.width === 0 || box.height === 0) return\n choose({ x: (event.clientX - box.left) / box.width, y: (event.clientY - box.top) / box.height })\n }\n\n const onKeydown = (event: KeyboardEvent) => {\n const { x, y } = point.value\n const step = event.shiftKey ? SPECTRUM_STEP * 10 : SPECTRUM_STEP\n const moves: Record<string, SpectrumPoint> = {\n ArrowLeft: { x: x - step, y },\n ArrowRight: { x: x + step, y },\n ArrowUp: { x, y: y - step },\n ArrowDown: { x, y: y + step },\n PageUp: { x, y: y - SPECTRUM_STEP * 10 },\n PageDown: { x, y: y + SPECTRUM_STEP * 10 },\n }\n const next = moves[event.key]\n if (!next) return\n event.preventDefault()\n choose(next)\n }\n\n return () => {\n const { x, y } = point.value\n const hue = Math.round(y * 360)\n return h(\n \"div\",\n {\n \"role\": \"slider\",\n \"tabindex\": 0,\n \"aria-label\": \"Spectrum\",\n \"aria-valuemin\": 0,\n \"aria-valuemax\": 360,\n \"aria-valuenow\": hue,\n \"aria-valuetext\": `#${hexDigits(props.color)}, hue ${hue}°, lightness ${Math.round((1 - x) * 100)}%`,\n \"class\": s.Spectrum,\n \"onPointerdown\": (event: PointerEvent) => {\n if (event.button !== 0) return\n const target = event.currentTarget as HTMLElement\n target.setPointerCapture?.(event.pointerId)\n target.focus({ preventScroll: true })\n fromPointer(event)\n },\n \"onPointermove\": (event: PointerEvent) => {\n if ((event.currentTarget as HTMLElement).hasPointerCapture?.(event.pointerId)) fromPointer(event)\n },\n onKeydown,\n },\n [h(\"span\", { class: s.Loupe, style: { left: `${x * 100}%`, top: `${y * 100}%`, backgroundColor: cssColor(props.color, 1) } })],\n )\n }\n },\n})\n\n/** Red, Green and Blue, each a slider and a field from 0 to 255, then the Hex field. */\nconst colorSliders = (uid: string, color: Rgba, onSelect: Select) =>\n h(\"div\", { class: s.Sliders }, [\n ...COLOR_PICKER_CHANNELS.map(({ channel, label }) => {\n const labelId = `${uid}-${channel}`\n return h(\"div\", { key: channel, class: s.Channel }, [\n h(\"span\", { id: labelId, class: s.Label }, label),\n h(\"div\", { class: s.Row }, [\n colorSlider({\n labelId,\n value: color[channel],\n max: 255,\n track: channelTrack(color, channel),\n valueText: String(color[channel]),\n onChange: (next) => onSelect({ ...color, [channel]: next }),\n }),\n h(ColorField, {\n value: String(color[channel]),\n labelledBy: labelId,\n inputMode: \"numeric\",\n onCommit: (text: string) => {\n const next = parseNumber(text, 0, 255)\n if (next !== null) onSelect({ ...color, [channel]: next })\n },\n }),\n ]),\n ])\n }),\n h(\"div\", { class: s.Hex }, [\n h(\"span\", { id: `${uid}-hex`, class: s.Label }, \"Hex Color #\"),\n h(ColorField, {\n value: hexDigits(color),\n labelledBy: `${uid}-hex`,\n inputMode: \"text\",\n wide: true,\n onCommit: (text: string) => {\n const next = parseColor(text)\n if (next) onSelect({ ...next, a: color.a })\n },\n }),\n ]),\n ])\n\nconst colorName = (color: Rgba) => `#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`\n\n/**\n * The current color, and the saved colors in pages of two rows of five with Add after the last (kit Swatches\n * 515:46585). A saved color is a radio; Delete or Backspace, or Delete in its context menu, removes it.\n */\nconst ColorSwatches = defineComponent({\n name: \"ColorPickerSwatches\",\n props: {\n color: { type: Object as PropType<Rgba>, required: true },\n swatches: { type: Array as PropType<string[]>, required: true },\n onSelect: { type: Function as PropType<Select>, required: true },\n onChange: { type: Function as PropType<(swatches: string[]) => void>, required: true },\n },\n setup(props) {\n const pagesRef = ref<HTMLElement | null>(null)\n const page = ref(0)\n\n const reveal = (element: HTMLElement | null | undefined) => element?.scrollIntoView?.({ block: \"nearest\", inline: \"nearest\" })\n\n const remove = (index: number, pages: HTMLElement | null) => {\n const { swatches } = props\n props.onChange(swatches.filter((_, i) => i !== index))\n // Focus stays in the list: on the color that takes the place, the one before at the end, or Add.\n const target = Math.min(index, swatches.length - 2)\n requestAnimationFrame(() => {\n const next = target >= 0 ? pages?.querySelector<HTMLElement>(`[data-swatch=\"${target}\"]`) : pages?.querySelector<HTMLElement>(\"[data-add]\")\n next?.focus()\n reveal(next)\n })\n }\n\n return () => {\n const { color, swatches } = props\n const saved = swatches.map((hex) => parseColor(hex) ?? BLACK)\n const current = formatColor(color)\n const checked = saved.findIndex((swatch) => sameRgb(swatch, color) && alphaPercent(swatch.a) === alphaPercent(color.a))\n const focusable = checked === -1 ? 0 : checked\n const pageCount = swatchPageCount(swatches.length)\n\n const onKeydown = (event: KeyboardEvent) => {\n const from = Number((event.target as HTMLElement).dataset.swatch)\n if (!Number.isInteger(from)) return\n if (event.key === \"Delete\" || event.key === \"Backspace\") {\n event.preventDefault()\n remove(from, event.currentTarget as HTMLElement)\n return\n }\n if (!NAVIGATION_KEYS.includes(event.key)) return\n event.preventDefault()\n const next = listMove(from, swatches.length, event.key)\n if (next === from) return\n const element = (event.currentTarget as HTMLElement).querySelector<HTMLElement>(`[data-swatch=\"${next}\"]`)\n element?.focus()\n reveal(element)\n const swatch = saved[next]\n if (swatch) props.onSelect(swatch)\n }\n\n const items = [...swatches.map((hex, index) => ({ hex, index })), null]\n const pages = Array.from({ length: pageCount }, (_, p) => items.slice(p * COLOR_PICKER_SWATCHES_PER_PAGE, (p + 1) * COLOR_PICKER_SWATCHES_PER_PAGE))\n\n const swatchButton = (index: number): VNode => {\n const swatch = saved[index] ?? BLACK\n return h(ContextMenu, { key: `${index}-${swatches[index]}` }, () => [\n h(ContextMenuTrigger, null, () =>\n h(\n \"button\",\n {\n \"type\": \"button\",\n \"role\": \"radio\",\n \"aria-checked\": index === checked,\n \"aria-label\": colorName(swatch),\n \"tabindex\": index === focusable ? 0 : -1,\n \"data-swatch\": index,\n \"class\": s.Swatch,\n \"onClick\": () => props.onSelect(swatch),\n },\n [h(\"span\", { class: s.SwatchFill, style: { backgroundColor: cssColor(swatch) } })],\n ),\n ),\n h(ContextMenuContent, null, () =>\n h(MenuItem, { danger: true, onSelect: () => remove(index, pagesRef.value) }, () => [h(RemoveTrash, { width: 20, height: 20 }), \" Delete\"]),\n ),\n ])\n }\n\n const addButton = () =>\n h(\n \"button\",\n {\n \"key\": \"add\",\n \"type\": \"button\",\n \"data-add\": \"\",\n \"class\": s.Add,\n \"aria-label\": \"Add color\",\n \"onClick\": (event: MouseEvent) => {\n props.onChange([...swatches, current])\n const add = event.currentTarget as HTMLElement\n requestAnimationFrame(() => reveal(add))\n },\n },\n [h(Plus)],\n )\n\n return h(\"div\", { class: s.Swatches }, [\n h(\"div\", { \"role\": \"img\", \"aria-label\": `Selected color ${colorName(color)}`, \"class\": s.Current }, [\n h(\"span\", { class: s.CurrentFill, style: { backgroundColor: cssColor(color) } }),\n ]),\n h(\"div\", { class: s.Saved }, [\n h(\n \"div\",\n {\n \"ref\": pagesRef,\n \"role\": \"radiogroup\",\n \"aria-label\": \"Saved colors\",\n \"class\": s.Pages,\n onKeydown,\n \"onScroll\": (event: Event) => {\n const { scrollLeft, clientWidth } = event.currentTarget as HTMLElement\n if (clientWidth > 0) page.value = Math.round(scrollLeft / clientWidth)\n },\n },\n pages.map((pageItems, p) =>\n h(\"div\", { key: p, class: s.Page }, pageItems.map((item) => (item === null ? addButton() : swatchButton(item.index)))),\n ),\n ),\n // The row of the page control keeps its height with one page, so the picker does not change size.\n h(\n \"div\",\n { class: s.PageControlRow },\n pageCount > 1\n ? [\n h(PageControl, {\n \"count\": pageCount,\n \"value\": Math.min(page.value, pageCount - 1),\n \"ariaLabel\": \"Saved color pages\",\n \"onUpdate:value\": (index: number) => {\n const pagesElement = pagesRef.value\n if (!pagesElement) return\n page.value = index\n pagesElement.scrollTo?.({ left: index * pagesElement.clientWidth, behavior: prefersReducedMotion() ? \"auto\" : \"smooth\" })\n },\n }),\n ]\n : [],\n ),\n ]),\n ])\n }\n },\n})\n\nconst ColorPickerComponent = defineComponent({\n name: \"ColorPicker\",\n inheritAttrs: false,\n props: {\n /** The `id` of the picker. */\n id: String,\n /** The controlled color, `#rrggbb` or `#rrggbbaa`. Bind with `v-model:value`. */\n value: { type: String, default: undefined },\n /** The color when it is initially rendered. Use when you do not need to control the color. @default \"#000000\" */\n defaultValue: { type: String, default: undefined },\n /** Shows the Opacity slider, as `supportsAlpha` of the system picker. @default true */\n supportsAlpha: { type: Boolean, default: true },\n /** The controlled way to choose a color. Bind with `v-model:mode`. */\n mode: { type: String as PropType<ColorPickerMode>, default: undefined },\n /** The way to choose a color when the picker is initially rendered. @default \"grid\" */\n defaultMode: { type: String as PropType<ColorPickerMode>, default: \"grid\" },\n /** The controlled saved colors. Bind with `v-model:swatches`. */\n swatches: { type: Array as PropType<string[]>, default: undefined },\n /** The saved colors when the picker is initially rendered. @default [] */\n defaultSwatches: { type: Array as PropType<string[]>, default: undefined },\n /** Accessible name of the picker. @default \"Colors\" */\n ariaLabel: { type: String, default: \"Colors\" },\n },\n emits: {\n /** The color changed: `#rrggbb`, or `#rrggbbaa` when it is not opaque */\n \"update:value\": (value: string) => typeof value === \"string\",\n /** The color changed (React `onChange`) */\n \"change\": (value: string) => typeof value === \"string\",\n /** Another of Grid, Spectrum and Sliders was chosen */\n \"update:mode\": (mode: ColorPickerMode) => typeof mode === \"string\",\n /** Another way was chosen (React `onModeChange`) */\n \"modeChange\": (mode: ColorPickerMode) => typeof mode === \"string\",\n /** Add saved the current color or Delete removed one */\n \"update:swatches\": (swatches: string[]) => Array.isArray(swatches),\n /** The saved colors changed (React `onSwatchesChange`) */\n \"swatchesChange\": (swatches: string[]) => Array.isArray(swatches),\n },\n setup(props, { attrs, emit }) {\n const uid = useId()\n const internalValue = ref(props.defaultValue ?? \"#000000\")\n const color = computed(() => parseColor(props.value ?? internalValue.value) ?? BLACK)\n\n const internalMode = ref<ColorPickerMode>(props.defaultMode)\n const mode = computed(() => props.mode ?? internalMode.value)\n\n const internalSwatches = ref<string[]>(props.defaultSwatches ?? [])\n const swatches = computed(() => props.swatches ?? internalSwatches.value)\n\n const commit = (next: Rgba) => {\n const formatted = formatColor(props.supportsAlpha ? next : { ...next, a: 1 })\n // Only a color other than the one shown is reported; an owner that keeps its color hears every new choice.\n if (formatted === formatColor(color.value)) return\n // A controlled color changes only when the owner passes it back.\n if (props.value === undefined) internalValue.value = formatted\n emit(\"update:value\", formatted)\n emit(\"change\", formatted)\n }\n\n const changeMode = (next: string) => {\n const chosen = next as ColorPickerMode\n if (props.mode === undefined) internalMode.value = chosen\n emit(\"update:mode\", chosen)\n emit(\"modeChange\", chosen)\n }\n\n const changeSwatches = (next: string[]) => {\n if (props.swatches === undefined) internalSwatches.value = next\n emit(\"update:swatches\", next)\n emit(\"swatchesChange\", next)\n }\n\n return () => {\n const current = color.value\n const opacityId = `${uid}-opacity`\n return h(\n \"div\",\n {\n ...attrs,\n \"id\": props.id,\n \"role\": \"group\",\n \"aria-label\": props.ariaLabel,\n \"class\": [s.ColorPicker, attrs.class],\n \"data-mode\": mode.value,\n },\n [\n h(\n SegmentedControl,\n { \"aria-label\": \"Mode\", \"value\": mode.value, \"block\": true, \"class\": s.Modes, \"onChange\": changeMode },\n { default: () => COLOR_PICKER_MODES.map((option) => h(SegmentedControlOption, { key: option.value, value: option.value }, () => option.label)) },\n ),\n h(\"div\", { class: s.Body }, [\n mode.value === \"grid\" ? colorGrid(current, commit) : null,\n mode.value === \"spectrum\" ? h(ColorSpectrum, { color: current, onSelect: commit }) : null,\n mode.value === \"sliders\" ? colorSliders(uid, current, commit) : null,\n ]),\n props.supportsAlpha\n ? h(\"div\", { class: s.Opacity }, [\n h(\"span\", { id: opacityId, class: s.Label }, \"Opacity\"),\n h(\"div\", { class: s.Row }, [\n colorSlider({\n labelId: opacityId,\n value: alphaPercent(current.a),\n max: 100,\n track: opacityTrack(current),\n valueText: `${alphaPercent(current.a)}%`,\n onChange: (percent) => commit({ ...color.value, a: percent / 100 }),\n }),\n h(ColorField, {\n value: `${alphaPercent(current.a)}%`,\n labelledBy: opacityId,\n inputMode: \"numeric\",\n onCommit: (text: string) => {\n const percent = parseNumber(text, 0, 100)\n if (percent !== null) commit({ ...color.value, a: percent / 100 })\n },\n }),\n ]),\n ])\n : null,\n h(ColorSwatches, { color: current, swatches: swatches.value, onSelect: commit, onChange: changeSwatches }),\n ],\n )\n }\n },\n})\n\nexport type ColorPickerProps = InstanceType<typeof ColorPickerComponent>[\"$props\"]\n\n/**\n * The system color picker of iOS 26 (kit Color Picker - iPhone 0:5275): Grid, Spectrum and Sliders, the Opacity\n * slider, and the saved colors with Add. Show it inside a Popover or a Sheet, or use `ColorWell`, which does.\n */\nexport const ColorPicker = ColorPickerComponent\n"]}