@kanso-labs/kanso-ui 0.45.34 → 0.46.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/button/index.js +13 -9
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/styles.js +12 -7
- package/dist/calendar/styles.js.map +1 -1
- package/dist/chip/styles.js +1 -0
- package/dist/chip/styles.js.map +1 -1
- package/dist/collection/styles.js +1 -1
- package/dist/collection/styles.js.map +1 -1
- package/dist/components/breadcrumbs/index.js +4 -1
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +16 -3
- package/dist/components/button-group/index.js +53 -86
- package/dist/components/button-group/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +3 -3
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/card/index.js +5 -1
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/carousel/index.js +162 -105
- package/dist/components/carousel/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +38 -15
- package/dist/components/chip/index.js +104 -8
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +5 -3
- package/dist/components/color-area/index.js +5 -3
- package/dist/components/color-area/index.js.map +1 -1
- package/dist/components/color-picker/index.js +6 -3
- package/dist/components/color-picker/index.js.map +1 -1
- package/dist/components/color-swatch-picker/index.js +24 -9
- package/dist/components/color-swatch-picker/index.js.map +1 -1
- package/dist/components/combo-box/index.d.ts +11 -3
- package/dist/components/combo-box/index.js +66 -62
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/copy-field/index.js +1 -0
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/date-picker/index.d.ts +22 -3
- package/dist/components/date-picker/index.js +234 -45
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/date-range-picker/index.d.ts +3 -1
- package/dist/components/date-range-picker/index.js +6 -4
- package/dist/components/date-range-picker/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +4 -3
- package/dist/components/disclosure/index.js +159 -101
- package/dist/components/disclosure/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +3 -1
- package/dist/components/fab/index.js +25 -12
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/fab-menu/index.js +1 -1
- package/dist/components/fab-menu/index.js.map +1 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-rail/index.js +4 -4
- package/dist/components/navigation-rail/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +16 -13
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/popover/index.js +35 -33
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.js +41 -7
- package/dist/components/range-calendar/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +3 -2
- package/dist/components/segmented-button/index.js +46 -95
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/select/index.js +5 -2
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/slider/index.js +42 -10
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/time-picker/index.js +2 -0
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/token-field/index.js +89 -66
- package/dist/components/token-field/index.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +4 -0
- package/dist/components/toolbar/index.js +16 -5
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/components/tree/index.js +1 -1
- package/dist/components/tree/index.js.map +1 -1
- package/dist/fab/styles.js +12 -0
- package/dist/fab/styles.js.map +1 -1
- package/dist/field/styles.js +2 -2
- package/dist/field/styles.js.map +1 -1
- package/dist/hooks/useDockedMonths.js +36 -0
- package/dist/hooks/useDockedMonths.js.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +34 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/navigation/index.js +5 -5
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/styles.js +4 -0
- package/dist/navigation/styles.js.map +1 -1
- package/dist/row/context.js +6 -0
- package/dist/row/context.js.map +1 -0
- package/dist/row/index.js +77 -66
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +15 -0
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/index.js +2 -1
- package/dist/segments/index.js.map +1 -1
- package/dist/segments/styles.js +4 -0
- package/dist/segments/styles.js.map +1 -1
- package/dist/styles/chequer.js +1 -0
- package/dist/styles/chequer.js.map +1 -1
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles.css +158 -35
- package/dist/toggle-group/index.js +133 -0
- package/dist/toggle-group/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -95,9 +95,11 @@ function actionChipContent(children, icon, surface) {
|
|
|
95
95
|
* time or several, is a `ChipGroup`, which keeps the rule, moves between the
|
|
96
96
|
* chips with the arrow keys and labels the set.
|
|
97
97
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* label says so.
|
|
98
|
+
* `variant="dropdown"` is the page's dropdown filter chip: placed first
|
|
99
|
+
* inside a `Menu`, it opens the menu, and a `trailingIcon` arrow after its
|
|
100
|
+
* label says so. It is a menu button rather than a toggle, so it announces no
|
|
101
|
+
* pressed state; `isSelected` draws it selected once the menu has a choice,
|
|
102
|
+
* and its label is where to name that choice.
|
|
101
103
|
*
|
|
102
104
|
* `variant="assist"` and `variant="suggestion"` draw the page's two action
|
|
103
105
|
* chips instead: plain buttons, pressed with `onPress`, never selected.
|
|
@@ -114,7 +116,7 @@ function actionChipContent(children, icon, surface) {
|
|
|
114
116
|
* ```
|
|
115
117
|
*/
|
|
116
118
|
function Chip(props) {
|
|
117
|
-
const $ = c(
|
|
119
|
+
const $ = c(6);
|
|
118
120
|
if (isAction(props)) {
|
|
119
121
|
let t0;
|
|
120
122
|
if ($[0] !== props) {
|
|
@@ -124,12 +126,21 @@ function Chip(props) {
|
|
|
124
126
|
} else t0 = $[1];
|
|
125
127
|
return t0;
|
|
126
128
|
}
|
|
129
|
+
if (isDropdown(props)) {
|
|
130
|
+
let t0;
|
|
131
|
+
if ($[2] !== props) {
|
|
132
|
+
t0 = /* @__PURE__ */ jsx(DropdownChip, { ...props });
|
|
133
|
+
$[2] = props;
|
|
134
|
+
$[3] = t0;
|
|
135
|
+
} else t0 = $[3];
|
|
136
|
+
return t0;
|
|
137
|
+
}
|
|
127
138
|
let t0;
|
|
128
|
-
if ($[
|
|
139
|
+
if ($[4] !== props) {
|
|
129
140
|
t0 = /* @__PURE__ */ jsx(FilterChip, { ...props });
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
} else t0 = $[
|
|
141
|
+
$[4] = props;
|
|
142
|
+
$[5] = t0;
|
|
143
|
+
} else t0 = $[5];
|
|
133
144
|
return t0;
|
|
134
145
|
}
|
|
135
146
|
function chipContent(children, icon, trailingIcon, surface) {
|
|
@@ -140,6 +151,88 @@ function chipContent(children, icon, trailingIcon, surface) {
|
|
|
140
151
|
surface
|
|
141
152
|
] });
|
|
142
153
|
}
|
|
154
|
+
function DropdownChip(t0) {
|
|
155
|
+
const $ = c(20);
|
|
156
|
+
const { children, elevated: t1, icon, isSelected: t2, onClick, onContextMenu, onKeyDown, onKeyUp, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, render, trailingIcon, variant: _variant, ...props } = t0;
|
|
157
|
+
const elevated = t1 === void 0 ? false : t1;
|
|
158
|
+
const isSelected = t2 === void 0 ? false : t2;
|
|
159
|
+
const element = {
|
|
160
|
+
aria: ariaAttributesOf(props),
|
|
161
|
+
onKeyDown,
|
|
162
|
+
onKeyUp
|
|
163
|
+
};
|
|
164
|
+
let t3;
|
|
165
|
+
if ($[0] !== onClick || $[1] !== onContextMenu || $[2] !== onPointerCancel || $[3] !== onPointerDown || $[4] !== onPointerLeave || $[5] !== onPointerUp) {
|
|
166
|
+
t3 = {
|
|
167
|
+
onClick,
|
|
168
|
+
onContextMenu,
|
|
169
|
+
onPointerCancel,
|
|
170
|
+
onPointerDown,
|
|
171
|
+
onPointerLeave,
|
|
172
|
+
onPointerUp
|
|
173
|
+
};
|
|
174
|
+
$[0] = onClick;
|
|
175
|
+
$[1] = onContextMenu;
|
|
176
|
+
$[2] = onPointerCancel;
|
|
177
|
+
$[3] = onPointerDown;
|
|
178
|
+
$[4] = onPointerLeave;
|
|
179
|
+
$[5] = onPointerUp;
|
|
180
|
+
$[6] = t3;
|
|
181
|
+
} else t3 = $[6];
|
|
182
|
+
const ripple = useRipple(props.isDisabled !== true, t3);
|
|
183
|
+
const T0 = Button;
|
|
184
|
+
const t4 = buttonRenderer(element, render);
|
|
185
|
+
const t5 = ripple.handlers;
|
|
186
|
+
const t6 = mergeStatefulStyles(dropdownChipClasses(isSelected, elevated), props);
|
|
187
|
+
let t7;
|
|
188
|
+
if ($[7] !== children || $[8] !== icon || $[9] !== isSelected || $[10] !== ripple.surface || $[11] !== trailingIcon) {
|
|
189
|
+
t7 = dropdownChipContent(children, icon, trailingIcon, isSelected, ripple.surface);
|
|
190
|
+
$[7] = children;
|
|
191
|
+
$[8] = icon;
|
|
192
|
+
$[9] = isSelected;
|
|
193
|
+
$[10] = ripple.surface;
|
|
194
|
+
$[11] = trailingIcon;
|
|
195
|
+
$[12] = t7;
|
|
196
|
+
} else t7 = $[12];
|
|
197
|
+
let t8;
|
|
198
|
+
if ($[13] !== T0 || $[14] !== props || $[15] !== ripple.handlers || $[16] !== t4 || $[17] !== t6 || $[18] !== t7) {
|
|
199
|
+
t8 = /* @__PURE__ */ jsx(T0, {
|
|
200
|
+
render: t4,
|
|
201
|
+
...t5,
|
|
202
|
+
...props,
|
|
203
|
+
...t6,
|
|
204
|
+
children: t7
|
|
205
|
+
});
|
|
206
|
+
$[13] = T0;
|
|
207
|
+
$[14] = props;
|
|
208
|
+
$[15] = ripple.handlers;
|
|
209
|
+
$[16] = t4;
|
|
210
|
+
$[17] = t6;
|
|
211
|
+
$[18] = t7;
|
|
212
|
+
$[19] = t8;
|
|
213
|
+
} else t8 = $[19];
|
|
214
|
+
return t8;
|
|
215
|
+
}
|
|
216
|
+
function dropdownChipClasses(isSelected, elevated) {
|
|
217
|
+
return (state) => chipPropsFor({
|
|
218
|
+
...state,
|
|
219
|
+
isSelected
|
|
220
|
+
}, {
|
|
221
|
+
elevated,
|
|
222
|
+
kind: "filter"
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function dropdownChipContent(children, icon, trailingIcon, isSelected, surface) {
|
|
226
|
+
return (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
227
|
+
chipGlyph({
|
|
228
|
+
isDisabled: state.isDisabled,
|
|
229
|
+
isSelected
|
|
230
|
+
}, icon),
|
|
231
|
+
chipLabel(children),
|
|
232
|
+
chipTrailingIcon(trailingIcon),
|
|
233
|
+
surface
|
|
234
|
+
] });
|
|
235
|
+
}
|
|
143
236
|
function FilterChip(t0) {
|
|
144
237
|
const $ = c(19);
|
|
145
238
|
const { children, elevated: t1, icon, onClick, onContextMenu, onKeyDown, onKeyUp, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, render, trailingIcon, variant: t2, ...props } = t0;
|
|
@@ -210,6 +303,9 @@ function filterChipClasses(kind, elevated) {
|
|
|
210
303
|
function isAction(props) {
|
|
211
304
|
return props.variant === "assist" || props.variant === "suggestion";
|
|
212
305
|
}
|
|
306
|
+
function isDropdown(props) {
|
|
307
|
+
return props.variant === "dropdown";
|
|
308
|
+
}
|
|
213
309
|
export { Chip as default };
|
|
214
310
|
|
|
215
311
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","Button","ToggleButton","chipGlyph","chipLabel","chipPropsFor","chipTrailingIcon","useRipple","ariaAttributesOf","buttonRenderer","toggleButtonRenderer","mergeStatefulStyles","variant","children","elevated","icon","trailingIcon","ActionChip","t0","$","t1","onClick","onContextMenu","onKeyDown","onKeyUp","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","render","props","undefined","element","aria","t2","ripple","isDisabled","T0","t3","t4","handlers","t5","actionChipClasses","t6","surface","actionChipContent","t7","kind","state","isSelected","Chip","isAction","chipContent","FilterChip","filterChipClasses","t8"],"sources":["../../../src/components/chip/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode, RefAttributes } from 'react'\nimport type {\n ButtonRenderProps,\n FocusableElement,\n ButtonProps as RACButtonProps,\n ToggleButtonProps as RACToggleButtonProps,\n ToggleButtonRenderProps,\n} from 'react-aria-components'\n\nimport { Button, ToggleButton } from 'react-aria-components'\n\nimport type { ChipKind } from '../../chip'\n\nimport {\n chipGlyph,\n chipLabel,\n chipPropsFor,\n chipTrailingIcon,\n} from '../../chip'\nimport { useRipple } from '../../hooks/useRipple'\nimport {\n ariaAttributesOf,\n buttonRenderer,\n toggleButtonRenderer,\n} from '../../render/aria'\nimport { mergeStatefulStyles } from '../../styles/merge'\n\n// The pill, its containers, its check and its disabled treatment are the\n// chip module's in `src/chip`, shared with the chips a ChipGroup draws; what\n// is here is React Aria's button around them. Three of the chips page's four\n// chips are drawn here, and `variant` picks the button:\n//\n// - **A filter chip**, the default, is React Aria's `ToggleButton`: a\n// two-state button announced through `aria-pressed`, which takes the\n// secondary container and the check once selected.\n// - **An assist or suggestion chip** is React Aria's `Button`: an action, so\n// nothing is announced as pressed and nothing is ever selected. The two\n// differ in the label's role alone; see `src/chip/styles.ts`.\n//\n// The page's fourth, the input chip, is ChipGroup's removable chip, and a\n// token in a TokenField.\n//\n// Two of the call site's props go on the element through `src/render/aria`\n// rather than through that spread, as `Button` and `IconButton` do. React\n// Aria builds a button's attributes from an allowlist that holds only the\n// labelling `aria-*` and the state it manages itself, so any other one — a\n// shortcut, an owned element — is dropped before it reaches the DOM. And it\n// wraps a keyboard handler it is given so that the event stops there unless\n// the handler asks otherwise, which is its convention rather than the DOM's;\n// on the element the handler bubbles, so an Escape pressed on a chip inside\n// a dialog still reaches the dialog.\n//\n// A press ripples, as it does on every other pressable control here: the\n// chips page names the ripple as the pressed state, beside the layer.\n\n/** An assist or suggestion chip: an action, drawn as a plain button. */\ntype ChipActionProps = ChipBaseProps &\n Omit<RACButtonProps, 'children' | 'isPending'> & {\n // Described on the filter chip's `variant` alone: the table joins the\n // descriptions of both, and the one sentence there covers all three.\n variant: 'assist' | 'suggestion'\n }\n\n/**\n * What every chip takes, whichever button it is. Declared once rather than on\n * each member of the union, so each prop has one description: the props table\n * joins the descriptions of a prop the members declare apart.\n */\ntype ChipBaseProps = {\n /**\n * The chip's label. A node rather than React Aria's node-or-function, since\n * a filter chip puts its own check before whatever this is and a function\n * would be handed a `defaultChildren` the chip never rendered. ChipGroup's\n * chip narrows it the same way, for the same reason. Required: the page\n * draws no chip without one, and a chip with none is an empty button to a\n * screen reader.\n */\n children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline. A selected filter chip keeps the\n * secondary container.\n * @default false\n */\n elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * On a filter chip the check takes its place while the chip is selected, so\n * the chip keeps its width. An icon drawn in `em` takes its size from the\n * slot.\n */\n icon?: ReactNode\n}\n\n/** A filter chip: a two-state button, the default. */\ntype ChipFilterProps = ChipBaseProps &\n Omit<RACToggleButtonProps, 'children'> & {\n /**\n * An icon after the label, in the same 18dp slot and the chip's own\n * content role, which is the page's dropdown filter chip: an arrow here\n * says the chip opens a menu. It stays while the chip is selected. An\n * icon drawn in `em` takes its size from the slot.\n */\n trailingIcon?: ReactNode\n /**\n * `filter`, the default, for a two-state button; `assist` for an action\n * the chip's context suggests, and `suggestion` for one the product\n * generates. Either of those is an action rather than a selection, so\n * neither is ever selected.\n * @default 'filter'\n */\n variant?: 'filter'\n }\n\ntype ChipProps = ChipActionProps | ChipFilterProps\n\n/** Which of the chips page's chips a Chip is. */\ntype ChipVariant = 'assist' | 'filter' | 'suggestion'\n\nfunction ActionChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n variant,\n ...props\n}: ChipActionProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled, as on the filter chip. `onClick` goes through the\n // ripple too: on a mouse press the ripple ends on the click, so a call\n // site's own handler spread beside it would leave it pressed.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <Button\n render={buttonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(actionChipClasses(variant, elevated), props)}\n >\n {actionChipContent(children, icon, ripple.surface)}\n </Button>\n )\n}\n\n// An action chip's classes: the unselected pill, which it always is.\nfunction actionChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ButtonRenderProps) =>\n chipPropsFor({ ...state, isSelected: false }, { elevated, kind })\n}\n\n// What an action chip draws: its icon, if any, then the label, and the\n// ripple over both. Built by a call for the reason `chipContent` is.\nfunction actionChipContent(\n children: ReactNode,\n icon: ReactNode,\n surface: ReactNode,\n) {\n return (state: ButtonRenderProps) => (\n <>\n {chipGlyph(\n { isDisabled: state.isDisabled, isSelected: false },\n icon,\n false,\n )}\n {chipLabel(children)}\n {surface}\n </>\n )\n}\n\n/**\n * A chip. By default a filter chip, which is a two-state button, so its\n * selected state is React Aria's `isSelected`: pass it with `onChange` to\n * control it, or `defaultSelected` to let it keep its own state. Selection is\n * announced through `aria-pressed` rather than a role of its own.\n *\n * This is the chip on its own. A set of chips with a selection rule, one at a\n * time or several, is a `ChipGroup`, which keeps the rule, moves between the\n * chips with the arrow keys and labels the set.\n *\n * Given a `trailingIcon`, a filter chip is the page's dropdown filter chip:\n * placed first inside a `Menu`, it opens the menu, and an arrow after its\n * label says so.\n *\n * `variant=\"assist\"` and `variant=\"suggestion\"` draw the page's two action\n * chips instead: plain buttons, pressed with `onPress`, never selected.\n *\n * ```tsx\n * const [selected, setSelected] = useState(false)\n *\n * <Chip isSelected={selected} onChange={setSelected}>\n * Label\n * </Chip>\n * <Chip icon={<AddIcon />} onPress={onAdd} variant=\"assist\">\n * Label\n * </Chip>\n * ```\n */\nfunction Chip(props: ChipProps & RefAttributes<HTMLButtonElement>) {\n if (isAction(props)) {\n return <ActionChip {...props} />\n }\n return <FilterChip {...props} />\n}\n\n// What the chip draws, from React Aria's render state: the check while it is\n// selected or its icon while it is not, then the label and any trailing\n// icon, and the ripple over them all. Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs.\nfunction chipContent(\n children: ReactNode,\n icon: ReactNode,\n trailingIcon: ReactNode,\n surface: ReactNode,\n) {\n return (state: ToggleButtonRenderProps) => (\n <>\n {chipGlyph(state, icon)}\n {chipLabel(children)}\n {chipTrailingIcon(trailingIcon)}\n {surface}\n </>\n )\n}\n\nfunction FilterChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n trailingIcon,\n variant = 'filter',\n ...props\n}: ChipFilterProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled: React Aria still forwards pointer events to a\n // disabled element, and a press that changes nothing should not look like\n // one. Typed as Button's ripple is, since React Aria types a toggle\n // button's pointer events against a <div> rather than the <button> it\n // renders. `onClick` goes through it for the action chip's reason.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <ToggleButton\n render={toggleButtonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(filterChipClasses(variant, elevated), props)}\n >\n {chipContent(children, icon, trailingIcon, ripple.surface)}\n </ToggleButton>\n )\n}\n\n// A filter chip's classes, from its render state.\nfunction filterChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ToggleButtonRenderProps) =>\n chipPropsFor(state, { elevated, kind })\n}\n\n// Whether a chip is one of the two action chips. A guard rather than a\n// comparison at the call, since TypeScript does not narrow the union through\n// React Aria's mapped prop types on `variant` alone.\nfunction isAction(props: ChipProps): props is ChipActionProps {\n return props.variant === 'assist' || props.variant === 'suggestion'\n}\n\nexport type { ChipActionProps, ChipFilterProps, ChipProps, ChipVariant }\n\nexport default Chip\n"],"mappings":";;;;;;;;;AAyHA,SAAAiB,WAAAC,IAAA;CAAA,MAAAC,IAAAnB,EAAA,EAAA;CAAoB,MAAA,EAAAa,UAAAC,UAAAM,IAAAL,MAAAM,SAAAC,eAAAC,WAAAC,SAAAC,iBAAAC,eAAAC,gBAAAC,aAAAC,QAAAjB,SAAA,GAAAkB,UAAAZ;CAElB,MAAAJ,WAAAM,OAAAW,KAAAA,IAAA,QAAAX;CAcA,MAAAY,UAAgB;EAAAC,MAAQzB,iBAAiBsB,KAAK;EAACP;EAAAC;CAAqB;CAAC,IAAAU;CAAA,IAAAf,EAAA,OAAAE,WAAAF,EAAA,OAAAG,iBAAAH,EAAA,OAAAM,mBAAAN,EAAA,OAAAO,iBAAAP,EAAA,OAAAQ,kBAAAR,EAAA,OAAAS,aAAA;EAICM,KAAA;GAAAb;GAAAC;GAAAG;GAAAC;GAAAC;GAAAC;EAOtE;EAACT,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;EAAAT,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CAPD,MAAAgB,SAAe5B,UAA4BuB,MAAKM,eAAgB,MAAMF,EAOrE;CAGE,MAAAG,KAAApC;CACS,MAAAqC,KAAA7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AAA,KAAApC,EAAA;CAAA,OAPfoC;AAOe;AAKnB,SAASD,kBAAkBP,MAAgBjC,UAAmB;CAC5D,QAAQkC,UACN3C,aAAa2C,OAAO;EAAElC;EAAUiC;CAAK,CAAC;AAC1C;AAKA,SAASI,SAASrB,OAA4C;CAC5D,OAAOA,MAAMlB,YAAY,YAAYkB,MAAMlB,YAAY;AACzD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","Button","ToggleButton","chipGlyph","chipLabel","chipPropsFor","chipTrailingIcon","useRipple","ariaAttributesOf","buttonRenderer","toggleButtonRenderer","mergeStatefulStyles","variant","children","elevated","icon","isSelected","trailingIcon","ActionChip","t0","$","t1","onClick","onContextMenu","onKeyDown","onKeyUp","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","render","props","undefined","element","aria","t2","ripple","isDisabled","T0","t3","t4","handlers","t5","actionChipClasses","t6","surface","actionChipContent","t7","kind","state","Chip","isAction","isDropdown","chipContent","DropdownChip","_variant","dropdownChipClasses","dropdownChipContent","t8","FilterChip","filterChipClasses"],"sources":["../../../src/components/chip/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode, RefAttributes } from 'react'\nimport type {\n ButtonRenderProps,\n FocusableElement,\n ButtonProps as RACButtonProps,\n ToggleButtonProps as RACToggleButtonProps,\n ToggleButtonRenderProps,\n} from 'react-aria-components'\n\nimport { Button, ToggleButton } from 'react-aria-components'\n\nimport type { ChipKind } from '../../chip'\n\nimport {\n chipGlyph,\n chipLabel,\n chipPropsFor,\n chipTrailingIcon,\n} from '../../chip'\nimport { useRipple } from '../../hooks/useRipple'\nimport {\n ariaAttributesOf,\n buttonRenderer,\n toggleButtonRenderer,\n} from '../../render/aria'\nimport { mergeStatefulStyles } from '../../styles/merge'\n\n// The pill, its containers, its check and its disabled treatment are the\n// chip module's in `src/chip`, shared with the chips a ChipGroup draws; what\n// is here is React Aria's button around them. Three of the chips page's four\n// chips are drawn here, and `variant` picks the button:\n//\n// - **A filter chip**, the default, is React Aria's `ToggleButton`: a\n// two-state button announced through `aria-pressed`, which takes the\n// secondary container and the check once selected.\n// - **A dropdown chip** is the page's dropdown filter chip, a menu's\n// trigger, and React Aria's `Button`: a press opens the menu and toggles\n// nothing, so a toggle's `aria-pressed` would announce a pressed button\n// that is also a collapsed menu. It draws the filter chip's pill, and its\n// selected look is the call site's `isSelected`, drawn rather than\n// announced, since what the menu has chosen is the menu's to say.\n// - **An assist or suggestion chip** is React Aria's `Button`: an action, so\n// nothing is announced as pressed and nothing is ever selected. The two\n// differ in the label's role alone; see `src/chip/styles.ts`.\n//\n// The page's fourth, the input chip, is ChipGroup's removable chip, and a\n// token in a TokenField.\n//\n// Two of the call site's props go on the element through `src/render/aria`\n// rather than through that spread, as `Button` and `IconButton` do. React\n// Aria builds a button's attributes from an allowlist that holds only the\n// labelling `aria-*` and the state it manages itself, so any other one — a\n// shortcut, an owned element — is dropped before it reaches the DOM. And it\n// wraps a keyboard handler it is given so that the event stops there unless\n// the handler asks otherwise, which is its convention rather than the DOM's;\n// on the element the handler bubbles, so an Escape pressed on a chip inside\n// a dialog still reaches the dialog.\n//\n// A press ripples, as it does on every other pressable control here: the\n// chips page names the ripple as the pressed state, beside the layer.\n\n/** An assist or suggestion chip: an action, drawn as a plain button. */\ntype ChipActionProps = ChipBaseProps &\n Omit<RACButtonProps, 'children' | 'isPending'> & {\n // Described on the filter chip's `variant` alone: the table joins the\n // descriptions of both, and the one sentence there covers all three.\n variant: 'assist' | 'suggestion'\n }\n\n/**\n * What every chip takes, whichever button it is. Declared once rather than on\n * each member of the union, so each prop has one description: the props table\n * joins the descriptions of a prop the members declare apart.\n */\ntype ChipBaseProps = {\n /**\n * The chip's label. A node rather than React Aria's node-or-function, since\n * a filter chip puts its own check before whatever this is and a function\n * would be handed a `defaultChildren` the chip never rendered. ChipGroup's\n * chip narrows it the same way, for the same reason. Required: the page\n * draws no chip without one, and a chip with none is an empty button to a\n * screen reader.\n */\n children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline. A selected filter chip keeps the\n * secondary container.\n * @default false\n */\n elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * On a filter chip the check takes its place while the chip is selected, so\n * the chip keeps its width. An icon drawn in `em` takes its size from the\n * slot.\n */\n icon?: ReactNode\n}\n\n/** A dropdown chip: a menu's trigger, drawn as a filter chip. */\ntype ChipDropdownProps = ChipBaseProps &\n ChipSelectableProps &\n Omit<RACButtonProps, 'children' | 'isPending'> & {\n // Described on the filter chip's `variant`, for the action chip's reason.\n variant: 'dropdown'\n }\n\n/** A filter chip: a two-state button, the default. */\ntype ChipFilterProps = ChipBaseProps &\n ChipSelectableProps &\n Omit<RACToggleButtonProps, 'children' | 'isSelected'> & {\n /**\n * `filter`, the default, for a two-state button; `dropdown` for the\n * page's dropdown filter chip, which opens a menu and so is a plain\n * button rather than a toggle; `assist` for an action the chip's context\n * suggests, and `suggestion` for one the product generates. Either of\n * those two is an action rather than a selection, so neither is ever\n * selected.\n * @default 'filter'\n */\n variant?: 'filter'\n }\n\ntype ChipProps = ChipActionProps | ChipDropdownProps | ChipFilterProps\n\n/**\n * What the filter chip and the dropdown chip take and the action chips do\n * not: both draw the pill a selection changes. Declared once, for the reason\n * `ChipBaseProps` is.\n */\ntype ChipSelectableProps = {\n /**\n * Draws the chip selected: the secondary container, and the check in front\n * of the label. On a filter chip it is the toggle's state, announced\n * through `aria-pressed`: pass it with `onChange` to control it. On a\n * dropdown chip it is drawn only, for a menu that has a choice, and the\n * chip's label is the place to name that choice.\n */\n isSelected?: boolean\n /**\n * An icon after the label, in the same 18dp slot and the chip's own\n * content role, which is the page's dropdown filter chip: an arrow here\n * says the chip opens a menu. It stays while the chip is selected. An\n * icon drawn in `em` takes its size from the slot.\n */\n trailingIcon?: ReactNode\n}\n\n/** Which of the chips page's chips a Chip is. */\ntype ChipVariant = 'assist' | 'dropdown' | 'filter' | 'suggestion'\n\nfunction ActionChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n variant,\n ...props\n}: ChipActionProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled, as on the filter chip. `onClick` goes through the\n // ripple too: on a mouse press the ripple ends on the click, so a call\n // site's own handler spread beside it would leave it pressed.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <Button\n render={buttonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(actionChipClasses(variant, elevated), props)}\n >\n {actionChipContent(children, icon, ripple.surface)}\n </Button>\n )\n}\n\n// An action chip's classes: the unselected pill, which it always is.\nfunction actionChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ButtonRenderProps) =>\n chipPropsFor({ ...state, isSelected: false }, { elevated, kind })\n}\n\n// What an action chip draws: its icon, if any, then the label, and the\n// ripple over both. Built by a call for the reason `chipContent` is.\nfunction actionChipContent(\n children: ReactNode,\n icon: ReactNode,\n surface: ReactNode,\n) {\n return (state: ButtonRenderProps) => (\n <>\n {chipGlyph(\n { isDisabled: state.isDisabled, isSelected: false },\n icon,\n false,\n )}\n {chipLabel(children)}\n {surface}\n </>\n )\n}\n\n/**\n * A chip. By default a filter chip, which is a two-state button, so its\n * selected state is React Aria's `isSelected`: pass it with `onChange` to\n * control it, or `defaultSelected` to let it keep its own state. Selection is\n * announced through `aria-pressed` rather than a role of its own.\n *\n * This is the chip on its own. A set of chips with a selection rule, one at a\n * time or several, is a `ChipGroup`, which keeps the rule, moves between the\n * chips with the arrow keys and labels the set.\n *\n * `variant=\"dropdown\"` is the page's dropdown filter chip: placed first\n * inside a `Menu`, it opens the menu, and a `trailingIcon` arrow after its\n * label says so. It is a menu button rather than a toggle, so it announces no\n * pressed state; `isSelected` draws it selected once the menu has a choice,\n * and its label is where to name that choice.\n *\n * `variant=\"assist\"` and `variant=\"suggestion\"` draw the page's two action\n * chips instead: plain buttons, pressed with `onPress`, never selected.\n *\n * ```tsx\n * const [selected, setSelected] = useState(false)\n *\n * <Chip isSelected={selected} onChange={setSelected}>\n * Label\n * </Chip>\n * <Chip icon={<AddIcon />} onPress={onAdd} variant=\"assist\">\n * Label\n * </Chip>\n * ```\n */\nfunction Chip(props: ChipProps & RefAttributes<HTMLButtonElement>) {\n if (isAction(props)) {\n return <ActionChip {...props} />\n }\n if (isDropdown(props)) {\n return <DropdownChip {...props} />\n }\n return <FilterChip {...props} />\n}\n\n// What the chip draws, from React Aria's render state: the check while it is\n// selected or its icon while it is not, then the label and any trailing\n// icon, and the ripple over them all. Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs.\nfunction chipContent(\n children: ReactNode,\n icon: ReactNode,\n trailingIcon: ReactNode,\n surface: ReactNode,\n) {\n return (state: ToggleButtonRenderProps) => (\n <>\n {chipGlyph(state, icon)}\n {chipLabel(children)}\n {chipTrailingIcon(trailingIcon)}\n {surface}\n </>\n )\n}\n\nfunction DropdownChip({\n children,\n elevated = false,\n icon,\n isSelected = false,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n trailingIcon,\n // Taken out so it is not handed to the button: the chip is always the\n // dropdown here, and the pill it draws is the filter chip's.\n variant: _variant,\n ...props\n}: ChipDropdownProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled, and taking `onClick`, for the action chip's reasons.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <Button\n render={buttonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(dropdownChipClasses(isSelected, elevated), props)}\n >\n {dropdownChipContent(\n children,\n icon,\n trailingIcon,\n isSelected,\n ripple.surface,\n )}\n </Button>\n )\n}\n\n// A dropdown chip's classes: the filter chip's pill, selected as the call\n// site says rather than as a press leaves it.\nfunction dropdownChipClasses(isSelected: boolean, elevated: boolean) {\n return (state: ButtonRenderProps) =>\n chipPropsFor({ ...state, isSelected }, { elevated, kind: 'filter' })\n}\n\n// What a dropdown chip draws: what a filter chip draws, from the call site's\n// `isSelected` rather than a toggle's state.\nfunction dropdownChipContent(\n children: ReactNode,\n icon: ReactNode,\n trailingIcon: ReactNode,\n isSelected: boolean,\n surface: ReactNode,\n) {\n return (state: ButtonRenderProps) => (\n <>\n {chipGlyph({ isDisabled: state.isDisabled, isSelected }, icon)}\n {chipLabel(children)}\n {chipTrailingIcon(trailingIcon)}\n {surface}\n </>\n )\n}\n\nfunction FilterChip({\n children,\n elevated = false,\n icon,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n render,\n trailingIcon,\n variant = 'filter',\n ...props\n}: ChipFilterProps & RefAttributes<HTMLButtonElement>) {\n const element = { aria: ariaAttributesOf(props), onKeyDown, onKeyUp }\n // Off while disabled: React Aria still forwards pointer events to a\n // disabled element, and a press that changes nothing should not look like\n // one. Typed as Button's ripple is, since React Aria types a toggle\n // button's pointer events against a <div> rather than the <button> it\n // renders. `onClick` goes through it for the action chip's reason.\n const ripple = useRipple<FocusableElement>(props.isDisabled !== true, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n })\n\n return (\n <ToggleButton\n render={toggleButtonRenderer(element, render)}\n {...ripple.handlers}\n {...props}\n {...mergeStatefulStyles(filterChipClasses(variant, elevated), props)}\n >\n {chipContent(children, icon, trailingIcon, ripple.surface)}\n </ToggleButton>\n )\n}\n\n// A filter chip's classes, from its render state.\nfunction filterChipClasses(kind: ChipKind, elevated: boolean) {\n return (state: ToggleButtonRenderProps) =>\n chipPropsFor(state, { elevated, kind })\n}\n\n// Whether a chip is one of the two action chips. A guard rather than a\n// comparison at the call, since TypeScript does not narrow the union through\n// React Aria's mapped prop types on `variant` alone.\nfunction isAction(props: ChipProps): props is ChipActionProps {\n return props.variant === 'assist' || props.variant === 'suggestion'\n}\n\n// Whether a chip is the dropdown chip, a guard for the same reason.\nfunction isDropdown(props: ChipProps): props is ChipDropdownProps {\n return props.variant === 'dropdown'\n}\n\nexport type {\n ChipActionProps,\n ChipDropdownProps,\n ChipFilterProps,\n ChipProps,\n ChipVariant,\n}\n\nexport default Chip\n"],"mappings":";;;;;;;;;AA0JA,SAAAkB,WAAAC,IAAA;CAAA,MAAAC,IAAApB,EAAA,EAAA;CAAoB,MAAA,EAAAa,UAAAC,UAAAO,IAAAN,MAAAO,SAAAC,eAAAC,WAAAC,SAAAC,iBAAAC,eAAAC,gBAAAC,aAAAC,QAAAlB,SAAA,GAAAmB,UAAAZ;CAElB,MAAAL,WAAAO,OAAAW,KAAAA,IAAA,QAAAX;CAcA,MAAAY,UAAgB;EAAAC,MAAQ1B,iBAAiBuB,KAAK;EAACP;EAAAC;CAAqB;CAAC,IAAAU;CAAA,IAAAf,EAAA,OAAAE,WAAAF,EAAA,OAAAG,iBAAAH,EAAA,OAAAM,mBAAAN,EAAA,OAAAO,iBAAAP,EAAA,OAAAQ,kBAAAR,EAAA,OAAAS,aAAA;EAICM,KAAA;GAAAb;GAAAC;GAAAG;GAAAC;GAAAC;GAAAC;EAOtE;EAACT,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;EAAAT,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CAPD,MAAAgB,SAAe7B,UAA4BwB,MAAKM,eAAgB,MAAMF,E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AA2B;EAAA3B,EAAA,MAAAsC;CAAA,OAAAA,KAAAtC,EAAA;CAAA,OAPfsC;AAOe;AAKnB,SAASE,kBAAkBZ,MAAgBlC,UAAmB;CAC5D,QAAQmC,UACN5C,aAAa4C,OAAO;EAAEnC;EAAUkC;CAAK,CAAC;AAC1C;AAKA,SAASG,SAASpB,OAA4C;CAC5D,OAAOA,MAAMnB,YAAY,YAAYmB,MAAMnB,YAAY;AACzD;AAGA,SAASwC,WAAWrB,OAA8C;CAChE,OAAOA,MAAMnB,YAAY;AAC3B"}
|
|
@@ -29,9 +29,11 @@ type ColorAreaProps = Omit<ColorAreaProps$1, 'children' | 'className' | 'style'>
|
|
|
29
29
|
* convert it, or give the value in the space you mean to work in. The same
|
|
30
30
|
* trap `ColorSlider` documents.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* **Give `alpha` to a `ColorSlider` holding the same value, not to an axis.**
|
|
33
|
+
* On an axis in RGB the plane leaves one of the colour channels out, and so
|
|
34
|
+
* shows colours the value does not have while the handle shows the one it
|
|
35
|
+
* does; in HSL React Aria quietly draws the saturation and lightness plane
|
|
36
|
+
* instead. Neither says so.
|
|
35
37
|
*
|
|
36
38
|
* React Aria names the handle "Color picker" and announces both channels;
|
|
37
39
|
* pass `aria-label` to say what the plane is for instead.
|
|
@@ -25,9 +25,11 @@ import { ColorArea as ColorArea$1, ColorThumb } from "react-aria-components";
|
|
|
25
25
|
* convert it, or give the value in the space you mean to work in. The same
|
|
26
26
|
* trap `ColorSlider` documents.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* **Give `alpha` to a `ColorSlider` holding the same value, not to an axis.**
|
|
29
|
+
* On an axis in RGB the plane leaves one of the colour channels out, and so
|
|
30
|
+
* shows colours the value does not have while the handle shows the one it
|
|
31
|
+
* does; in HSL React Aria quietly draws the saturation and lightness plane
|
|
32
|
+
* instead. Neither says so.
|
|
31
33
|
*
|
|
32
34
|
* React Aria names the handle "Color picker" and announces both channels;
|
|
33
35
|
* pass `aria-label` to say what the plane is for instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","ColorArea","thumbClassName","mergeStyles","className","style","t0","$","props","ref","t1","isDisabled","undefined","t2","0","1","t3","Symbol","for","t4","t5","t6","t7","RACColorThumb","RACColorArea"],"sources":["../../../src/components/color-area/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, RefAttributes } from 'react';\nimport type { ColorAreaProps as RACColorAreaProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorArea as RACColorArea, ColorThumb as RACColorThumb } from 'react-aria-components';\nimport { thumbClassName } from '../../styles/color';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// Two channels of a colour at once, as a plane: one runs along the inline\n// axis and one along the block axis, and the handle sits where they meet.\n// React Aria paints both gradients on the plane's own inline `background`\n// and moves the handle in two axes, so what is here is the plane's shape and\n// the handle `ColorSlider` already draws, from `src/styles/color.ts`.\n//\n// The design carries no page for this, so the two choices below are the\n// library's own.\n//\n// **It is square, and takes the width it is given.** A plane has no natural\n// size, and a box that was not square would give its two channels unequal\n// travel — the same drag would move one further than the other, which is a\n// difference a reader cannot see and would feel as the control being wrong.\n//\n// **It carries no chequer, unlike a swatch or a colour slider's alpha\n// track.** Those two show the surface behind them where a colour thins out,\n// and a plane does not: React Aria stacks its gradients so the topmost is\n// opaque across the whole box, so nothing laid behind the plane is ever\n// seen. A chequer here was written first and then taken out, because it\n// could not be made to show under any pairing tried — including the RGB\n// alpha pairing whose gradient really does carry a `rgba(0, 0, 0, 0)` stop.\n//\n// **Alpha
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","ColorArea","thumbClassName","mergeStyles","className","style","t0","$","props","ref","t1","isDisabled","undefined","t2","0","1","t3","Symbol","for","t4","t5","t6","t7","RACColorThumb","RACColorArea"],"sources":["../../../src/components/color-area/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, RefAttributes } from 'react';\nimport type { ColorAreaProps as RACColorAreaProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorArea as RACColorArea, ColorThumb as RACColorThumb } from 'react-aria-components';\nimport { thumbClassName } from '../../styles/color';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// Two channels of a colour at once, as a plane: one runs along the inline\n// axis and one along the block axis, and the handle sits where they meet.\n// React Aria paints both gradients on the plane's own inline `background`\n// and moves the handle in two axes, so what is here is the plane's shape and\n// the handle `ColorSlider` already draws, from `src/styles/color.ts`.\n//\n// The design carries no page for this, so the two choices below are the\n// library's own.\n//\n// **It is square, and takes the width it is given.** A plane has no natural\n// size, and a box that was not square would give its two channels unequal\n// travel — the same drag would move one further than the other, which is a\n// difference a reader cannot see and would feel as the control being wrong.\n//\n// **It carries no chequer, unlike a swatch or a colour slider's alpha\n// track.** Those two show the surface behind them where a colour thins out,\n// and a plane does not: React Aria stacks its gradients so the topmost is\n// opaque across the whole box, so nothing laid behind the plane is ever\n// seen. A chequer here was written first and then taken out, because it\n// could not be made to show under any pairing tried — including the RGB\n// alpha pairing whose gradient really does carry a `rgba(0, 0, 0, 0)` stop.\n//\n// **Alpha belongs on a `ColorSlider` beside the plane, never on an axis.**\n// React Aria paints the plane from the two axis channels and one more, the\n// first of the space's colour channels the axes leave over, held at the\n// value's own. With alpha on an axis that leaves two colour channels over,\n// so the second is never painted: against `rgba(0, 170, 255, 0.6)` with red\n// and alpha on the axes, the plane runs from `rgb(0, 170, 0)` to\n// `rgb(255, 170, 0)` with no blue anywhere, while the handle shows the\n// light blue the value is. Nor does the alpha axis thin the plane, for the\n// reason above. In HSL it is not even that: React Aria draws the saturation\n// and lightness plane instead and says nothing, so a plane that will not\n// change is the only sign. Neither throws the way an unknown channel does,\n// which is why it is written down here. The `Alpha` story, and ColorPicker,\n// put the alpha on a slider holding the same value.\n\ntype ColorAreaProps = Omit<RACColorAreaProps, 'children' | 'className' | 'style'> & {\n /**\n * Lands on the square around the plane, which is the element a layout\n * positions and the one that carries its size.\n */\n className?: string;\n /** Lands on the square around the plane, as `className` does. */\n style?: CSSProperties;\n};\n\n/**\n * Two channels of a colour as a plane, with a handle where they meet. The\n * value is React Aria's: pass `value` with `onChange` to control it, or\n * `defaultValue`, as a CSS colour string or a `Color` from `parseColor`,\n * which this package re-exports.\n *\n * ```tsx\n * <ColorArea\n * defaultValue=\"hsl(200, 100%, 50%)\"\n * xChannel=\"saturation\"\n * yChannel=\"lightness\"\n * />\n * ```\n *\n * **`xChannel` and `yChannel` have to name channels the value's own space\n * has.** A hex or `rgb()` value parses as RGB, which has no saturation, so\n * naming one against it throws rather than converting — pass `colorSpace` to\n * convert it, or give the value in the space you mean to work in. The same\n * trap `ColorSlider` documents.\n *\n * **Give `alpha` to a `ColorSlider` holding the same value, not to an axis.**\n * On an axis in RGB the plane leaves one of the colour channels out, and so\n * shows colours the value does not have while the handle shows the one it\n * does; in HSL React Aria quietly draws the saturation and lightness plane\n * instead. Neither says so.\n *\n * React Aria names the handle \"Color picker\" and announces both channels;\n * pass `aria-label` to say what the plane is for instead.\n *\n * The call site's `className` and `style` land on the square around the\n * plane rather than on the plane itself, so setting an `inlineSize` is what\n * resizes one — and it stays square, since two channels sharing a box want\n * equal travel. React Aria's function forms are not taken here for the same\n * reason `ColorSwatch` does not take them: the element they would read\n * state for is not the one a layout reaches.\n */\n// The ref lands on the chequered ground, the element the call site's class\n// and style do, rather than on React Aria's area inside it.\nfunction ColorArea({\n className,\n isDisabled = false,\n ref,\n style,\n ...props\n}: ColorAreaProps & RefAttributes<HTMLDivElement>) {\n return <div ref={ref} {...mergeStyles({\n 0: {\n className: \"x1plog1 x1xdvaa9 x9f619 xh8yej3\"\n },\n 1: {\n className: \"x1plog1 x1xdvaa9 x9f619 xh8yej3 x1ppv7y9\"\n }\n }[!!isDisabled << 0], {\n className,\n style\n })}>\n <RACColorArea isDisabled={isDisabled} {...props} {...{\n 0: {\n className: \"x5yr21d x1xdvaa9 x9f619 xsid9ct xh8yej3 x5ve5x3\"\n },\n 1: {\n className: \"x5yr21d x1xdvaa9 x9f619 xh8yej3 x5ve5x3 x1h6gzvc\"\n }\n }[!!isDisabled << 0]}>\n <RACColorThumb className={thumbClassName} />\n </RACColorArea>\n </div>;\n}\nexport type { ColorAreaProps };\nexport default ColorArea;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,SAAAC,UAAAK,IAAA;CAAA,MAAAC,IAAAP,EAAA,EAAA;CAAA,IAAAI;CAAA,IAAAI;CAAA,IAAAC;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAH,EAAA,OAAAD,IAAA;EAAmB,CAAA,CAAAF,WAAAO,YAAAD,IAAAD,KAAAJ,OAAA,GAAAG,SAAAF;EAM8BC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAF;EAAAE,EAAA,KAAAG;CAAA,OAAA;EAAAN,YAAAG,EAAA;EAAAC,QAAAD,EAAA;EAAAE,MAAAF,EAAA;EAAAF,QAAAE,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAJ/C,MAAAI,aAAAD,OAAAE,KAAAA,IAAA,QAAAF;CAAkB,IAAAG;CAAA,IAAAN,EAAA,OAAAH,aAAAG,EAAA,OAAAI,cAAAJ,EAAA,OAAAF,OAAA;EAKQQ,KAAAV,YAAY;GAAAW,GACjC,EAAAV,WACU,kCACb;GAACW,GACE,EAAAX,WACU,2CACb;EACF,EAAE,CAAC,CAACO,cAAc,IAAI;GAAAP;GAAAC;EAGtB,CAAC;EAACE,EAAA,KAAAH;EAAAG,EAAA,KAAA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IpWk: "x1dkaolv",
|
|
34
|
-
|
|
35
|
+
ksu8eU: "x1y0btm7",
|
|
36
|
+
kMzoRj: "xmkeg23",
|
|
35
37
|
kB7OPa: "x9f619",
|
|
36
38
|
kMwMTN: "x139gbkf",
|
|
37
39
|
kkrTdU: "x1ypdohk",
|
|
@@ -42,12 +44,13 @@ const triggerStyles = {
|
|
|
42
44
|
kOIVth: "x126z3so",
|
|
43
45
|
kb6lSQ: "x155f00i",
|
|
44
46
|
kLWn49: "x1lz68p4",
|
|
45
|
-
k8WAf4: "
|
|
46
|
-
kg3NbH: "
|
|
47
|
+
k8WAf4: "xa9tkb9",
|
|
48
|
+
kg3NbH: "x9t8nta",
|
|
47
49
|
$$css: true
|
|
48
50
|
},
|
|
49
51
|
disabled: {
|
|
50
52
|
kWkggS: "x19v6zzp",
|
|
53
|
+
kVAM5u: "xrh88j3 xmnqt3w",
|
|
51
54
|
kMwMTN: "x1xj74d8",
|
|
52
55
|
kkrTdU: "x1h6gzvc",
|
|
53
56
|
$$css: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","parseColor","ColorPicker","useLocale","focus","mergeStatefulStyles","overlay","popoverClassName","styles","triggerSwatch","kZKoxP","kmuXW","kzqmXN","$$css","triggerSwatchDisabled","kSiTet","DISABLED_TRIGGER_SWATCH","triggerStyles","base","kGNEyG","kWkggS","kaIpWk","kMzoRj","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kOIVth","kb6lSQ","kLWn49","k8WAf4","kg3NbH","disabled","hovered","pressed","alpha","children","className","container","defaultOpen","isDisabled","isOpen","label","onOpenChange","style","CHANNELS","t0","$","props","ref","t1","t2","undefined","locale","t3","_temp","t4","state_0","state","t5","t6","Symbol","for","popupDialog","ring","t7","getChannelName","t8","t9","t10","t11","isHovered","isPressed","ColorSwatch","RACButton","ColorArea","ColorSlider","ColorField","RACDialog","RACPopover","RACDialogTrigger","RACColorPicker"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ColorPickerProps as RACColorPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { parseColor, Button as RACButton, ColorPicker as RACColorPicker, Dialog as RACDialog, DialogTrigger as RACDialogTrigger, Popover as RACPopover, useLocale } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay } from '../../styles/overlay';\nimport { popoverClassName } from '../../styles/picker';\nimport { SwatchSquareContext } from '../../swatch';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\nimport ColorArea from '../color-area';\nimport ColorField from '../color-field';\nimport ColorSlider from '../color-slider';\nimport ColorSwatch from '../color-swatch';\n\n// Everything in this phase, in one control: a swatch and a label as the\n// trigger, and a plane, a hue slider, an alpha slider and a text field on\n// the surface it opens. React Aria's `ColorPicker` renders nothing of its\n// own — it is the state the five share — so what is here is the trigger,\n// the overlay and the arrangement inside it.\n//\n// The design carries no page for a colour picker. What it does carry is the\n// text fields page, which the field inside this one already draws through,\n// and the overlay surface every popover here shares. Three choices are the\n// library's own.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch\n// on its own is a coloured square with no affordance — nothing says it can\n// be pressed, and a screen reader is told a colour rather than an action.\n// The label is what makes it a button.\n//\n// **Hue is a slider rather than a wheel here.** A wheel and the plane want\n// the same space and would make the surface square and large; the strip\n// sits under the plane at the width it already has. `ColorWheel` is for a\n// picker that wants to be round, which is a different shape rather than a\n// different control.\n//\n// **It is docked above the medium breakpoint and modal below it**, centred\n// over a scrim there — the same swap `DatePicker` makes, at the width `Sheet`\n// changes presentation too, and the shared one in `src/styles/picker.ts`\n// rather than a third copy. A 280dp surface anchored to a trigger is\n// unreachable at 375px.\n//\n// One thing the picker has to do that its parts do not. **The plane and the\n// hue strip are pinned to HSL.** A channel has to belong to the value's own\n// space or React Aria throws, and a hex parses as RGB, which has no\n// saturation — so `<ColorPicker defaultValue=\"#6750A4\" />`, the call anyone\n// writes first, would throw outright. Converting here is what makes the\n// picker take any notation, and it costs the caller nothing: the value\n// handed back is still in whatever they passed.\n\nconst styles = {\n triggerSwatch: {\n kZKoxP: \"xxk0z11\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n triggerSwatchDisabled: {\n kSiTet: \"x1ppv7y9\",\n $$css: true\n }\n};\n\n// Hoisted so the context is handed one array rather than a new one on every\n// render, which would re-render every swatch reading it.\nconst DISABLED_TRIGGER_SWATCH = [styles.triggerSwatch, styles.triggerSwatchDisabled];\nconst triggerStyles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"x1vnz5z6\",\n kaIpWk: \"x1dkaolv\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x18fpw6u\",\n $$css: true\n },\n disabled: {\n kWkggS: \"x19v6zzp\",\n kMwMTN: \"x1xj74d8\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n hovered: {\n kWkggS: \"x1ei6177\",\n $$css: true\n },\n pressed: {\n kWkggS: \"x1vt8e7r\",\n $$css: true\n }\n};\ntype ColorPickerProps = Omit<RACColorPickerProps, 'children'> & {\n /** Whether the alpha strip is drawn under the hue one. @default false */\n alpha?: boolean;\n /** Replaces everything on the surface, for a picker that arranges its own parts. */\n children?: ReactNode;\n /** Lands on the trigger, which is the element a layout positions. */\n className?: string;\n /**\n * Where to portal the surface. Defaults to the container of the `ThemeScope`\n * around it, which keeps the surface on that scope's tokens, or to the end of\n * `<body>` where there is none. A subtree themed through the `themeScope`\n * class has no container of its own, so point this inside it, or the surface\n * renders outside and keeps the page's tokens.\n */\n container?: Element;\n /** Whether the surface starts open. Uncontrolled; pair `isOpen` with `onOpenChange` instead. */\n defaultOpen?: boolean;\n /**\n * Whether the whole picker is inert — the trigger, and the plane, strips\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed\n * as `children` is the call site's own to disable.\n * @default false\n */\n isDisabled?: boolean;\n /** Whether the surface is open. Controlled; needs `onOpenChange`. */\n isOpen?: boolean;\n /** What the trigger says beside its swatch. Always rendered; it is the button's name. */\n label: string;\n /** Called when the surface opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Lands on the trigger, as `className` does. */\n style?: CSSProperties;\n};\n\n// Any HSL colour names the channels the two strips draw. The labels are read\n// off it in the reader's locale, as React Aria words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)');\n\n/**\n * A colour picked from a plane, a hue strip and a text field, behind a\n * trigger showing the colour. The value is React Aria's: pass `value` with\n * `onChange` to control it, or `defaultValue`, as a CSS colour string or a\n * `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency strip. Above the medium breakpoint the\n * surface is docked to the trigger; below it, it opens centred, the same\n * swap `DatePicker` makes. `defaultOpen`, `isOpen` and `onOpenChange` reach\n * the overlay, since the picker itself carries no open state — React Aria\n * keeps that on the dialog trigger this renders inside.\n *\n * Every part inside is this package's own — `ColorArea`, `ColorSlider`,\n * `ColorField` and `ColorSwatch` — and they share the picker's value\n * through React Aria's context rather than props. Passing `children`\n * replaces all of them, for a picker that wants a different arrangement.\n *\n * The call site's `className` and `style` land on the trigger, which is the\n * element a layout positions.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n className,\n container,\n defaultOpen,\n isDisabled = false,\n isOpen,\n label,\n onOpenChange,\n ref,\n style,\n ...props\n}: ColorPickerProps & RefAttributes<HTMLButtonElement>) {\n const {\n locale\n } = useLocale();\n return <RACColorPicker {...props}>\n <RACDialogTrigger defaultOpen={defaultOpen} isOpen={isOpen} onOpenChange={onOpenChange}>\n <RACButton isDisabled={isDisabled}\n // React Aria's picker renders no element of its own, so the ref\n // lands on the trigger, as the call site's class and style do.\n ref={ref} {...mergeStatefulStyles(\n // A function of the state rather than a fixed class, since the\n // trigger is the element a layout positions and the call site's\n // own class has to merge into it — a plain `className` would\n // overwrite one or the other.\n (state: ButtonRenderProps) => stylex.props(triggerStyles.base, focus.ring, state.isHovered && triggerStyles.hovered, state.isPressed && triggerStyles.pressed, state.isDisabled && triggerStyles.disabled), {\n className,\n style\n })}>\n {(state: ButtonRenderProps) => <>\n <SwatchSquareContext value={state.isDisabled ? DISABLED_TRIGGER_SWATCH : styles.triggerSwatch}>\n <ColorSwatch />\n </SwatchSquareContext>\n {label}\n </>}\n </RACButton>\n <RACPopover className={popoverClassName}\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container}>\n <RACDialog {...stylex.props(overlay.popupDialog, focus.ring)}>\n {/*\n Disabled reaches every control here, not only the trigger.\n React Aria's colour picker carries no disabled state of its\n own — react-stately's `useColorPickerState` has no such\n concept — so nothing hands it down the way a field's context\n would. And the surface opens independently of the trigger, so\n a disabled picker can still be on screen: already open when a\n form disables it, or opened from outside. Without this the\n plane could be dragged, the strips moved with the arrow keys\n and the field typed into, all changing the value of something\n documented as inert.\n An arrangement a call site passes as `children` is its own to\n disable; there is no context to reach it through.\n */}\n {children ?? <div className=\"x9f619 x78zum5 xdt5ytf x1gka490 x1dz1jew x193iq5w xgc26li\">\n <ColorArea aria-label={label} colorSpace=\"hsl\" isDisabled={isDisabled} xChannel=\"saturation\" yChannel=\"lightness\" />\n <ColorSlider channel=\"hue\" colorSpace=\"hsl\" isDisabled={isDisabled} label={CHANNELS.getChannelName('hue', locale)} />\n {alpha ? <ColorSlider channel=\"alpha\" isDisabled={isDisabled} label={CHANNELS.getChannelName('alpha', locale)} /> : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </div>}\n </RACDialog>\n </RACPopover>\n </RACDialogTrigger>\n </RACColorPicker>;\n}\nexport type { ColorPickerProps };\nexport default ColorPicker;"],"mappings":";;;;;;;;;;;;;;;AAsDA,MAAMS,SAAS;CACbC,eAAe;EACbC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,OAAO;CACT;CACAC,uBAAuB;EACrBC,QAAQ;EACRF,OAAO;CACT;AACF;AAIA,MAAMG,0BAA0B,CAACR,OAAOC,eAAeD,OAAOM,qBAAqB;AACnF,MAAMG,gBAAgB;CACpBC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRrB,OAAO;CACT;CACAsB,UAAU;EACRf,QAAQ;EACRI,QAAQ;EACRC,QAAQ;EACRZ,OAAO;CACT;CACAuB,SAAS;EACPhB,QAAQ;EACRP,OAAO;CACT;CACAwB,SAAS;EACPjB,QAAQ;EACRP,OAAO;CACT;AACF;AAuCA,MAAMmC,WAAW/C,WAAW,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;AA0B5C,SAAAC,YAAA+C,IAAA;CAAA,MAAAC,IAAAnD,EAAA,EAAA;CAAA,IAAAwC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAE;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAK;CAAA,IAAAC;CAAA,IAAAL;CAAA,IAAAM;CAAA,IAAAC;CAAA,I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AAOd,MAAK+D,MAAON,MAAKa,aAAczD,cAAamB,SAAUyB,MAAKc,aAAc1D,cAAaoB,SAAUwB,MAAKlB,cAAe1B,cAAakB,QAAS;AAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","parseColor","ColorPicker","useLocale","focus","mergeStatefulStyles","overlay","popoverClassName","styles","triggerSwatch","kZKoxP","kmuXW","kzqmXN","$$css","triggerSwatchDisabled","kSiTet","DISABLED_TRIGGER_SWATCH","triggerStyles","base","kGNEyG","kWkggS","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","kkrTdU","k1xSpc","kMv6JI","kGuDYH","k63SB2","kOIVth","kb6lSQ","kLWn49","k8WAf4","kg3NbH","disabled","hovered","pressed","alpha","children","className","container","defaultOpen","isDisabled","isOpen","label","onOpenChange","style","CHANNELS","t0","$","props","ref","t1","t2","undefined","locale","t3","_temp","t4","state_0","state","t5","t6","Symbol","for","popupDialog","ring","t7","getChannelName","t8","t9","t10","t11","isHovered","isPressed","ColorSwatch","RACButton","ColorArea","ColorSlider","ColorField","RACDialog","RACPopover","RACDialogTrigger","RACColorPicker"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { ButtonRenderProps, ColorPickerProps as RACColorPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { parseColor, Button as RACButton, ColorPicker as RACColorPicker, Dialog as RACDialog, DialogTrigger as RACDialogTrigger, Popover as RACPopover, useLocale } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport { overlay } from '../../styles/overlay';\nimport { popoverClassName } from '../../styles/picker';\nimport { SwatchSquareContext } from '../../swatch';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\nimport ColorArea from '../color-area';\nimport ColorField from '../color-field';\nimport ColorSlider from '../color-slider';\nimport ColorSwatch from '../color-swatch';\n\n// Everything in this phase, in one control: a swatch and a label as the\n// trigger, and a plane, a hue slider, an alpha slider and a text field on\n// the surface it opens. React Aria's `ColorPicker` renders nothing of its\n// own — it is the state the five share — so what is here is the trigger,\n// the overlay and the arrangement inside it.\n//\n// The design carries no page for a colour picker. What it does carry is the\n// text fields page, which the field inside this one already draws through,\n// and the overlay surface every popover here shares. Three choices are the\n// library's own.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch\n// on its own is a coloured square with no affordance — nothing says it can\n// be pressed, and a screen reader is told a colour rather than an action.\n// The label is what makes it a button. Its edge is a 1px border in outline\n// variant, as an unselected chip's is, rather than its container alone: the\n// container sits within about 1.05:1 of the surface, and a forced-colours\n// mode drops it outright, which left a swatch and a word with no edge at\n// all. Under that mode the border names `ButtonBorder`, and `GrayText`\n// while the trigger is disabled, as a disabled chip's does. The padding\n// gives the border's pixel back, so the trigger keeps its size.\n//\n// **Hue is a slider rather than a wheel here.** A wheel and the plane want\n// the same space and would make the surface square and large; the strip\n// sits under the plane at the width it already has. `ColorWheel` is for a\n// picker that wants to be round, which is a different shape rather than a\n// different control.\n//\n// **It is docked above the medium breakpoint and modal below it**, centred\n// over a scrim there — the same swap `DatePicker` makes, at the width `Sheet`\n// changes presentation too, and the shared one in `src/styles/picker.ts`\n// rather than a third copy. A 280dp surface anchored to a trigger is\n// unreachable at 375px.\n//\n// One thing the picker has to do that its parts do not. **The plane and the\n// hue strip are pinned to HSL.** A channel has to belong to the value's own\n// space or React Aria throws, and a hex parses as RGB, which has no\n// saturation — so `<ColorPicker defaultValue=\"#6750A4\" />`, the call anyone\n// writes first, would throw outright. Converting here is what makes the\n// picker take any notation, and it costs the caller nothing: the value\n// handed back is still in whatever they passed.\n\nconst styles = {\n triggerSwatch: {\n kZKoxP: \"xxk0z11\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n triggerSwatchDisabled: {\n kSiTet: \"x1ppv7y9\",\n $$css: true\n }\n};\n\n// Hoisted so the context is handed one array rather than a new one on every\n// render, which would re-render every swatch reading it.\nconst DISABLED_TRIGGER_SWATCH = [styles.triggerSwatch, styles.triggerSwatchDisabled];\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst triggerStyles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"x1vnz5z6\",\n kVAM5u: \"x133yhug x1qfu9ae\",\n kaIpWk: \"x1dkaolv\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xmkeg23\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kMv6JI: \"xkknnkr\",\n kGuDYH: \"x14zspaw\",\n k63SB2: \"x1v9cpvo\",\n kOIVth: \"x126z3so\",\n kb6lSQ: \"x155f00i\",\n kLWn49: \"x1lz68p4\",\n k8WAf4: \"xa9tkb9\",\n kg3NbH: \"x9t8nta\",\n $$css: true\n },\n disabled: {\n kWkggS: \"x19v6zzp\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n kMwMTN: \"x1xj74d8\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n hovered: {\n kWkggS: \"x1ei6177\",\n $$css: true\n },\n pressed: {\n kWkggS: \"x1vt8e7r\",\n $$css: true\n }\n};\ntype ColorPickerProps = Omit<RACColorPickerProps, 'children'> & {\n /** Whether the alpha strip is drawn under the hue one. @default false */\n alpha?: boolean;\n /** Replaces everything on the surface, for a picker that arranges its own parts. */\n children?: ReactNode;\n /** Lands on the trigger, which is the element a layout positions. */\n className?: string;\n /**\n * Where to portal the surface. Defaults to the container of the `ThemeScope`\n * around it, which keeps the surface on that scope's tokens, or to the end of\n * `<body>` where there is none. A subtree themed through the `themeScope`\n * class has no container of its own, so point this inside it, or the surface\n * renders outside and keeps the page's tokens.\n */\n container?: Element;\n /** Whether the surface starts open. Uncontrolled; pair `isOpen` with `onOpenChange` instead. */\n defaultOpen?: boolean;\n /**\n * Whether the whole picker is inert — the trigger, and the plane, strips\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed\n * as `children` is the call site's own to disable.\n * @default false\n */\n isDisabled?: boolean;\n /** Whether the surface is open. Controlled; needs `onOpenChange`. */\n isOpen?: boolean;\n /** What the trigger says beside its swatch. Always rendered; it is the button's name. */\n label: string;\n /** Called when the surface opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Lands on the trigger, as `className` does. */\n style?: CSSProperties;\n};\n\n// Any HSL colour names the channels the two strips draw. The labels are read\n// off it in the reader's locale, as React Aria words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)');\n\n/**\n * A colour picked from a plane, a hue strip and a text field, behind a\n * trigger showing the colour. The value is React Aria's: pass `value` with\n * `onChange` to control it, or `defaultValue`, as a CSS colour string or a\n * `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency strip. Above the medium breakpoint the\n * surface is docked to the trigger; below it, it opens centred, the same\n * swap `DatePicker` makes. `defaultOpen`, `isOpen` and `onOpenChange` reach\n * the overlay, since the picker itself carries no open state — React Aria\n * keeps that on the dialog trigger this renders inside.\n *\n * Every part inside is this package's own — `ColorArea`, `ColorSlider`,\n * `ColorField` and `ColorSwatch` — and they share the picker's value\n * through React Aria's context rather than props. Passing `children`\n * replaces all of them, for a picker that wants a different arrangement.\n *\n * The call site's `className` and `style` land on the trigger, which is the\n * element a layout positions.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n className,\n container,\n defaultOpen,\n isDisabled = false,\n isOpen,\n label,\n onOpenChange,\n ref,\n style,\n ...props\n}: ColorPickerProps & RefAttributes<HTMLButtonElement>) {\n const {\n locale\n } = useLocale();\n return <RACColorPicker {...props}>\n <RACDialogTrigger defaultOpen={defaultOpen} isOpen={isOpen} onOpenChange={onOpenChange}>\n <RACButton isDisabled={isDisabled}\n // React Aria's picker renders no element of its own, so the ref\n // lands on the trigger, as the call site's class and style do.\n ref={ref} {...mergeStatefulStyles(\n // A function of the state rather than a fixed class, since the\n // trigger is the element a layout positions and the call site's\n // own class has to merge into it — a plain `className` would\n // overwrite one or the other.\n (state: ButtonRenderProps) => stylex.props(triggerStyles.base, focus.ring, state.isHovered && triggerStyles.hovered, state.isPressed && triggerStyles.pressed, state.isDisabled && triggerStyles.disabled), {\n className,\n style\n })}>\n {(state: ButtonRenderProps) => <>\n <SwatchSquareContext value={state.isDisabled ? DISABLED_TRIGGER_SWATCH : styles.triggerSwatch}>\n <ColorSwatch />\n </SwatchSquareContext>\n {label}\n </>}\n </RACButton>\n <RACPopover className={popoverClassName}\n // oxlint-disable-next-line typescript/no-deprecated -- its replacement, UNSAFE_PortalProvider, is not exported by react-aria-components\n UNSTABLE_portalContainer={container}>\n <RACDialog {...stylex.props(overlay.popupDialog, focus.ring)}>\n {/*\n Disabled reaches every control here, not only the trigger.\n React Aria's colour picker carries no disabled state of its\n own — react-stately's `useColorPickerState` has no such\n concept — so nothing hands it down the way a field's context\n would. And the surface opens independently of the trigger, so\n a disabled picker can still be on screen: already open when a\n form disables it, or opened from outside. Without this the\n plane could be dragged, the strips moved with the arrow keys\n and the field typed into, all changing the value of something\n documented as inert.\n An arrangement a call site passes as `children` is its own to\n disable; there is no context to reach it through.\n */}\n {children ?? <div className=\"x9f619 x78zum5 xdt5ytf x1gka490 x1dz1jew x193iq5w xgc26li\">\n <ColorArea aria-label={label} colorSpace=\"hsl\" isDisabled={isDisabled} xChannel=\"saturation\" yChannel=\"lightness\" />\n <ColorSlider channel=\"hue\" colorSpace=\"hsl\" isDisabled={isDisabled} label={CHANNELS.getChannelName('hue', locale)} />\n {alpha ? <ColorSlider channel=\"alpha\" isDisabled={isDisabled} label={CHANNELS.getChannelName('alpha', locale)} /> : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </div>}\n </RACDialog>\n </RACPopover>\n </RACDialogTrigger>\n </RACColorPicker>;\n}\nexport type { ColorPickerProps };\nexport default ColorPicker;"],"mappings":";;;;;;;;;;;;;;;AA4DA,MAAMS,SAAS;CACbC,eAAe;EACbC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,OAAO;CACT;CACAC,uBAAuB;EACrBC,QAAQ;EACRF,OAAO;CACT;AACF;AAIA,MAAMG,0BAA0B,CAACR,OAAOC,eAAeD,OAAOM,qBAAqB;AAOnF,MAAMG,gBAAgB;CACpBC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRvB,OAAO;CACT;CACAwB,UAAU;EACRjB,QAAQ;EACRC,QAAQ;EACRK,QAAQ;EACRC,QAAQ;EACRd,OAAO;CACT;CACAyB,SAAS;EACPlB,QAAQ;EACRP,OAAO;CACT;CACA0B,SAAS;EACPnB,QAAQ;EACRP,OAAO;CACT;AACF;AAuCA,MAAMqC,WAAWjD,WAAW,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;AA0B5C,SAAAC,YAAAiD,IAAA;CAAA,MAAAC,IAAArD,EAAA,EAAA;CAAA,IAAA0C;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAE;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAK;CAAA,IAAAC;CAAA,IAAAL;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,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AAKa,aAAc3D,cAAaqB,SAAUyB,MAAKc,aAAc5D,cAAasB,SAAUwB,MAAKlB,cAAe5B,cAAaoB,QAAS;AAAC"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
3
|
+
import { focus } from "../../styles/focus.js";
|
|
3
4
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
5
|
+
import { colors } from "../../tokens/design.tokens.stylex.js";
|
|
4
6
|
import ColorSwatch$1 from "../color-swatch/index.js";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
6
8
|
import { jsx } from "react/jsx-runtime";
|
|
7
9
|
import { ColorSwatchPicker as ColorSwatchPicker$1, ColorSwatchPickerItem as ColorSwatchPickerItem$1 } from "react-aria-components";
|
|
8
10
|
// src/components/color-swatch-picker/index.tsx
|
|
11
|
+
`${colors.surface}${colors.onSurface}${colors.surface}`;
|
|
9
12
|
const styles = {
|
|
10
13
|
item: {
|
|
11
|
-
kUfP38: "
|
|
14
|
+
kUfP38: "xdzrvcx",
|
|
12
15
|
kbwMcY: "x1v5kskh",
|
|
13
16
|
kPGmMm: "x1941vk7",
|
|
14
17
|
kWgvks: "xx38sju",
|
|
15
18
|
k5JduY: "x1s928wv",
|
|
16
|
-
kv0HGH: "
|
|
19
|
+
kv0HGH: "xzkkzs7",
|
|
17
20
|
kloYau: "x2q1x1w",
|
|
18
21
|
kwXMNM: "x1j6awrg",
|
|
19
22
|
kaIpWk: "x1tfhd1",
|
|
@@ -25,15 +28,20 @@ const styles = {
|
|
|
25
28
|
$$css: true
|
|
26
29
|
},
|
|
27
30
|
itemDisabled: {
|
|
31
|
+
k3DiCg: "xkqgyyi x1vz15c4",
|
|
32
|
+
kPB484: "x13uuyx9",
|
|
33
|
+
kQmYQc: "xtql2tq",
|
|
34
|
+
kgeoSG: "x1cpjm7i",
|
|
35
|
+
ku0W4C: "x13rwrtk",
|
|
36
|
+
kFcpXp: "xxx281p",
|
|
37
|
+
km8f2m: "xkk1bqk",
|
|
38
|
+
kEoFBp: "x1hmns74",
|
|
39
|
+
kxmVGU: "x12maryy",
|
|
28
40
|
kkrTdU: "xt0e3qv",
|
|
29
|
-
kSiTet: "x1ppv7y9",
|
|
30
41
|
$$css: true
|
|
31
42
|
},
|
|
32
43
|
itemFocused: {
|
|
33
|
-
kjBf7l: "xrgy624",
|
|
34
44
|
kInvED: "x8wkva7",
|
|
35
|
-
k3XXqK: "xaatb59",
|
|
36
|
-
kMeerF: "x1de99jn",
|
|
37
45
|
$$css: true
|
|
38
46
|
},
|
|
39
47
|
itemHovered: {
|
|
@@ -47,8 +55,9 @@ const styles = {
|
|
|
47
55
|
$$css: true
|
|
48
56
|
},
|
|
49
57
|
itemSelected: {
|
|
50
|
-
kXtpa: "
|
|
58
|
+
kXtpa: "xmi6dwc",
|
|
51
59
|
kbwMcY: "x86avzo",
|
|
60
|
+
kPGmMm: "x14wq4lv",
|
|
52
61
|
$$css: true
|
|
53
62
|
}
|
|
54
63
|
};
|
|
@@ -121,7 +130,13 @@ function ColorSwatchPickerItem(t0) {
|
|
|
121
130
|
}
|
|
122
131
|
let t3;
|
|
123
132
|
if ($[5] !== children) {
|
|
124
|
-
t3 =
|
|
133
|
+
t3 = (state) => /* @__PURE__ */ jsx("span", {
|
|
134
|
+
...{
|
|
135
|
+
0: { className: "x9f619 x3nfvp2" },
|
|
136
|
+
1: { className: "x9f619 x3nfvp2 x1ppv7y9" }
|
|
137
|
+
}[!!state.isDisabled << 0],
|
|
138
|
+
children: children ?? /* @__PURE__ */ jsx(ColorSwatch$1, {})
|
|
139
|
+
});
|
|
125
140
|
$[5] = children;
|
|
126
141
|
$[6] = t3;
|
|
127
142
|
} else t3 = $[6];
|
|
@@ -141,7 +156,7 @@ function ColorSwatchPickerItem(t0) {
|
|
|
141
156
|
return t4;
|
|
142
157
|
}
|
|
143
158
|
function itemStyles(state) {
|
|
144
|
-
return props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && styles.itemFocused, state.isDisabled && styles.itemDisabled);
|
|
159
|
+
return props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && [focus.ringVisible, styles.itemFocused], state.isDisabled && styles.itemDisabled);
|
|
145
160
|
}
|
|
146
161
|
ColorSwatchPicker.Item = ColorSwatchPickerItem;
|
|
147
162
|
export { ColorSwatchPickerItem, ColorSwatchPicker as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","ColorSwatchPicker","ColorSwatchPickerItem","RACColorSwatchPickerItem","mergeStatefulStyles","styles","item","kUfP38","kbwMcY","kPGmMm","kWgvks","k5JduY","kv0HGH","kloYau","kwXMNM","kaIpWk","kB7OPa","kkrTdU","k1xSpc","k3XXqK","kVAEAm","$$css","itemDisabled","kSiTet","itemFocused","kjBf7l","kInvED","kMeerF","itemHovered","kXtpa","itemPressed","itemSelected","children","className","props","$","t0","t1","T0","t2","t3","itemStyles","t4","state","isDisabled","isFocusVisible","isHovered","isPressed","isSelected","Item","RACColorSwatchPicker","ColorSwatch"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is the primary role, and offset.** It is the same weight and\n// colour the focus ring takes elsewhere, one step out from the swatch so the\n// colour stays whole — a ring drawn on the swatch would eat two pixels of\n// the thing being chosen.\n//\n// **Focus and selection are drawn by different properties.** An element has\n// one outline, so with both drawn in it the second replaced the first, and a\n// keyboard arrowing onto the chosen colour saw a swatch that looked\n// unchosen. The focus ring is the item's outline, 6px out; the selection\n// ring is a border on a box laid 2px around the swatch, inside it. Both are\n// properties forced colours keep, which a box shadow is not.\n//\n// **Hover and press are a ring too, in the slot selection would take.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen:\n// behind it the tint is hidden, over it the tint changes the colour. So an\n// unselected swatch under the pointer takes a ring at the selection ring's\n// offset, drawn in the outline roles rather than primary so it cannot be read\n// as chosen — outline variant while a pointer is over it, and outline while a\n// touch or a pen holds it. Those are the only presses anyone sees: React Aria\n// chooses a swatch the moment a mouse or a key presses it, and on release for\n// a touch, so that press is the one a reader waits through before the swatch\n// is theirs. Under forced colours both roles become one system colour, so the\n// ring turns dashed there, where the selection ring stays solid.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n item: {\n kUfP38: \"x1upluxz\",\n kbwMcY: \"x1v5kskh\",\n kPGmMm: \"x1941vk7\",\n kWgvks: \"xx38sju\",\n k5JduY: \"x1s928wv\",\n kv0HGH: \"xramuyw\",\n kloYau: \"x2q1x1w\",\n kwXMNM: \"x1j6awrg\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n k3XXqK: \"x1t137rt\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemDisabled: {\n kkrTdU: \"xt0e3qv\",\n kSiTet: \"x1ppv7y9\",\n $$css: true\n },\n itemFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x8wkva7\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n itemHovered: {\n kXtpa: \"x1ek9lwj\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemPressed: {\n kXtpa: \"xrwozs3\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemSelected: {\n kXtpa: \"xtl7nvb\",\n kbwMcY: \"x86avzo\",\n $$css: true\n }\n};\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPickerItem {...props} {...mergeStatefulStyles(itemStyles, props)}>\n {children ?? <ColorSwatch />}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's styles, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters where two styles draw on one property. The hover and\n// press rings come before `selected`, which draws on the same border, so a\n// chosen swatch keeps the ring that says so. `focused` draws on the outline,\n// which nothing else touches, so a swatch that is chosen and focused keeps\n// both. `disabled` is last, so it takes the cursor with it; React Aria\n// reports neither hover nor press on one.\nfunction itemStyles(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n}) {\n return stylex.props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && styles.itemFocused, state.isDisabled && styles.itemDisabled);\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, ColorSwatchPickerProps };\nexport { ColorSwatchPickerItem };\nexport default ColorSwatchPicker;"],"mappings":";;;;;;;;AAkDA,MAAMM,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,O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D,KAAAH,EAAA;EAAAH,WAAAG,EAAA;EAAAE,KAAAF,EAAA;EAAAI,KAAAJ,EAAA;CAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAH,UAAA;EACjFQ,KAAAR,YAAY,oBAACmB,eAAD,CAAY,CAAA;EAAGhB,EAAA,KAAAH;EAAAG,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAG,MAAAH,EAAA,OAAAE,MAAAF,EAAA,OAAAI,MAAAJ,EAAA,QAAAK,IAAA;EADzBE,KAAA,oBAAC,IAAD;GAAyB,GAAKR;GAAK,GAAMK;GAC3CC,UAAAA;EAD2B,CAAA;EAEHL,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAFtBO;AAEsB;AAa/B,SAASD,WAAWE,OAMjB;CACD,OAAO3C,MAAaK,OAAOC,MAAMqC,MAAMG,aAAazC,OAAOuB,aAAae,MAAMI,aAAa1C,OAAOyB,aAAaa,MAAMK,cAAc3C,OAAO0B,cAAcY,MAAME,kBAAkBxC,OAAOmB,aAAamB,MAAMC,cAAcvC,OAAOiB,YAAY;AAC7O;AACArB,kBAAkBgD,OAAO/C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","ColorSwatchPicker","ColorSwatchPickerItem","RACColorSwatchPickerItem","focus","mergeStatefulStyles","colors","surface","onSurface","styles","item","kUfP38","kbwMcY","kPGmMm","kWgvks","k5JduY","kv0HGH","kloYau","kwXMNM","kaIpWk","kB7OPa","kkrTdU","k1xSpc","k3XXqK","kVAEAm","$$css","itemDisabled","k3DiCg","kPB484","kQmYQc","kgeoSG","ku0W4C","kFcpXp","km8f2m","kEoFBp","kxmVGU","itemFocused","kInvED","itemHovered","kXtpa","itemPressed","itemSelected","children","className","props","$","t0","t1","T0","t2","t3","itemStyles","state","0","1","isDisabled","t4","isFocusVisible","isHovered","isPressed","isSelected","ringVisible","Item","RACColorSwatchPicker","ColorSwatch"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is 3px of on-surface, and offset.** It sits 2px out from the\n// swatch so the colour stays whole — a ring drawn on the swatch would eat\n// pixels of the thing being chosen. It is not the focus ring's colour or\n// weight on purpose: the arrow keys move focus without choosing, so one\n// swatch is chosen while another is focused, and when both rings were 2px of\n// primary only their distance from the swatch told them apart. Focus keeps\n// the library's ring, the one every other control draws, so the selection\n// ring is the one that differs, heavier and in on-surface.\n//\n// **Focus and selection are drawn by different properties.** An element has\n// one outline, so with both drawn in it the second replaced the first, and a\n// keyboard arrowing onto the chosen colour saw a swatch that looked\n// unchosen. The focus ring is the item's outline, 6px out; the selection\n// ring is a border on a box laid 5px around the swatch, inside it, with 1px\n// clear between the two. Both are properties forced colours keep, which a\n// box shadow is not, and there the difference in weight is what is left.\n//\n// **Hover and press are a ring too, in the slot selection would take.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen:\n// behind it the tint is hidden, over it the tint changes the colour. So an\n// unselected swatch under the pointer takes a ring at the selection ring's\n// outer edge, 2px wide and in the outline roles, so it cannot be read\n// as chosen — outline variant while a pointer is over it, and outline while a\n// touch or a pen holds it. Those are the only presses anyone sees: React Aria\n// chooses a swatch the moment a mouse or a key presses it, and on release for\n// a touch, so that press is the one a reader waits through before the swatch\n// is theirs. Under forced colours both roles become one system colour, so the\n// ring turns dashed there, where the selection ring stays solid.\n//\n// **A colour that cannot be chosen is struck through, as well as faded.**\n// Faded alone it read as a paler colour, and a pale colour is as good an\n// option as any. The slash is drawn over the swatch, where the first choice\n// says no single ink reads against every colour, so it is two: an on-surface\n// line edged in surface, and whichever of the two the colour beneath is\n// nearer to, the other reads against it. The fade is on the item's contents\n// rather than the item, so the slash over them keeps its full strength.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\n\n// The slash, corner to corner across a square: a 2px line of ink with 1.5px\n// of edge either side, measured across the line rather than along the\n// square's side. Written out twice, once per pair of colours, since StyleX\n// evaluates a constant but not a function building one.\nconst SLASH = `linear-gradient(to top right, transparent calc(50% - 2.5px), ${colors.surface} calc(50% - 2.5px) calc(50% - 1px), ${colors.onSurface} calc(50% - 1px) calc(50% + 1px), ${colors.surface} calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))`;\nconst SLASH_FORCED = 'linear-gradient(to top right, transparent calc(50% - 2.5px), Canvas calc(50% - 2.5px) calc(50% - 1px), GrayText calc(50% - 1px) calc(50% + 1px), Canvas calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))';\nconst styles = {\n item: {\n kUfP38: \"xdzrvcx\",\n kbwMcY: \"x1v5kskh\",\n kPGmMm: \"x1941vk7\",\n kWgvks: \"xx38sju\",\n k5JduY: \"x1s928wv\",\n kv0HGH: \"xzkkzs7\",\n kloYau: \"x2q1x1w\",\n kwXMNM: \"x1j6awrg\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n k3XXqK: \"x1t137rt\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemDisabled: {\n k3DiCg: \"xkqgyyi x1vz15c4\",\n kPB484: \"x13uuyx9\",\n kQmYQc: \"xtql2tq\",\n kgeoSG: \"x1cpjm7i\",\n ku0W4C: \"x13rwrtk\",\n kFcpXp: \"xxx281p\",\n km8f2m: \"xkk1bqk\",\n kEoFBp: \"x1hmns74\",\n kxmVGU: \"x12maryy\",\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n itemFocused: {\n kInvED: \"x8wkva7\",\n $$css: true\n },\n itemHovered: {\n kXtpa: \"x1ek9lwj\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemPressed: {\n kXtpa: \"xrwozs3\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemSelected: {\n kXtpa: \"xmi6dwc\",\n kbwMcY: \"x86avzo\",\n kPGmMm: \"x14wq4lv\",\n $$css: true\n }\n};\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPickerItem {...props} {...mergeStatefulStyles(itemStyles, props)}>\n {state => <span {...{\n 0: {\n className: \"x9f619 x3nfvp2\"\n },\n 1: {\n className: \"x9f619 x3nfvp2 x1ppv7y9\"\n }\n }[!!state.isDisabled << 0]}>\n {children ?? <ColorSwatch />}\n </span>}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's styles, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters where two styles draw on one property. The hover and\n// press rings come before `selected`, which draws on the same border, so a\n// chosen swatch keeps the ring that says so. Focus is the library's ring and\n// then `focused`, which moves it out; both draw on the outline, which\n// nothing else touches but the item's resting `none`, so a swatch that is\n// chosen and focused keeps both. `disabled` is last, so it takes the cursor\n// with it, and draws the slash; React Aria reports neither hover nor press\n// on one.\nfunction itemStyles(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n}) {\n return stylex.props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && [focus.ringVisible, styles.itemFocused], state.isDisabled && styles.itemDisabled);\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, ColorSwatchPickerProps };\nexport { ColorSwatchPickerItem };\nexport default ColorSwatchPicker;"],"mappings":";;;;;;;;;;AAqEc,GAAgEO,OAAOC,UAA8CD,OAAOE,YAA8CF,OAAOC;AAE/L,MAAME,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,cAAc;EACZC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRd,QAAQ;EACRI,OAAO;CACT;CACAW,aAAa;EACXC,QAAQ;EACRZ,OAAO;CACT;CACAa,aAAa;EACXC,OAAO;EACP3B,QAAQ;EACRa,OAAO;CACT;CACAe,aAAa;EACXD,OAAO;EACP3B,QAAQ;EACRa,OAAO;CACT;CACAgB,cAAc;EACZF,OAAO;EACP3B,QAAQ;EACRC,QAAQ;EACRY,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAAxB,kBAAA2C,OAAA;CAAA,MAAAC,IAAA9C,EAAA,CAAA;CAAA,IAAA+C;CAAA,IAAAD,EAAA,OAAAD,OAAA;EAC8CE,KAAAzC,oBAAoB,EAAAsC,WACnD,4CACb,GAAGC,KAAK;EAACC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA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