@kanso-labs/kanso-ui 0.45.34 → 0.47.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/label.js +1 -0
- package/dist/chip/label.js.map +1 -1
- package/dist/chip/styles.js +2 -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/code/index.js +32 -26
- package/dist/components/code/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/index.js +1 -1
- package/dist/components/color-swatch/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 +3 -3
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +3 -3
- package/dist/components/link/index.js +2 -2
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/menu/index.js +5 -2
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-bar/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/progress-indicator/index.js +258 -172
- package/dist/components/progress-indicator/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/search-view/index.js +1 -1
- package/dist/components/search-view/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/table/index.d.ts +26 -5
- package/dist/components/table/index.js +93 -75
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/tag/index.js +1 -0
- package/dist/components/tag/index.js.map +1 -1
- package/dist/components/time-picker/index.js +37 -5
- 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 +8 -3
- package/dist/components/toolbar/index.js +123 -43
- 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 +3 -3
- package/dist/navigation/index.js +5 -5
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/styles.js +5 -1
- 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 -5
- package/dist/segments/index.js.map +1 -1
- package/dist/segments/literal.js +66 -0
- package/dist/segments/literal.js.map +1 -0
- package/dist/segments/styles.js +8 -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 +509 -69
- package/dist/toggle-group/index.js +133 -0
- package/dist/toggle-group/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -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,UAA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J;EAAAI,EAAA,KAAAgB,OAAAS;EAAAzB,EAAA,MAAAH;EAAAG,EAAA,MAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,IAAAoC;CAAA,IAAApC,EAAA,QAAAkB,MAAAlB,EAAA,QAAAW,SAAAX,EAAA,QAAAgB,OAAAK,YAAArB,EAAA,QAAAoB,MAAApB,EAAA,QAAAwB,MAAAxB,EAAA,QAAA2B,IAAA;EAN5DS,KAAA,oBAAC,IAAD;GACU,QAAAhB;GAAqC,GACzCE;GAAe,GACfX;GAAK,GACLa;GAEHG,UAAAA;EANU,CAAA;EAOE3B,EAAA,MAAAkB;EAAAlB,EAAA,MAAAW;EAAAX,EAAA,MAAAgB,OAAAK;EAAArB,EAAA,MAAAoB;EAAApB,EAAA,MAAAwB;EAAAxB,EAAA,MAAA2B;EAAA3B,EAAA,MAAAoC;CAAA,OAAAA,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,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AACzB,EAAA,KAAAP;EAAAO,EAAA,KAAAL;EAAAK,EAAA,KAAAgB,OAAAS;EAAAzB,EAAA,MAAAH;EAAAG,EAAA,MAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,IAAAsC;CAAA,IAAAtC,EAAA,QAAAkB,MAAAlB,EAAA,QAAAW,SAAAX,EAAA,QAAAgB,OAAAK,YAAArB,EAAA,QAAAoB,MAAApB,EAAA,QAAAwB,MAAAxB,EAAA,QAAA2B,IAAA;EAN5DW,KAAA,oBAAC,IAAD;GACU,QAAAlB;GAAqC,GACzCE;GAAe,GACfX;GAAK,GACLa;GAEHG,UAAAA;EANU,CAAA;EAOE3B,EAAA,MAAAkB;EAAAlB,EAAA,MAAAW;EAAAX,EAAA,MAAAgB,OAAAK;EAAArB,EAAA,MAAAoB;EAAApB,EAAA,MAAAwB;EAAAxB,EAAA,MAAA2B;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"}
|
|
@@ -8,55 +8,61 @@ import { c } from "react/compiler-runtime";
|
|
|
8
8
|
* renders a `<code>` and takes its scale from the text around it.
|
|
9
9
|
*/
|
|
10
10
|
function Code(t0) {
|
|
11
|
-
const $ = c(
|
|
11
|
+
const $ = c(15);
|
|
12
12
|
let render;
|
|
13
13
|
let t1;
|
|
14
14
|
let t2;
|
|
15
15
|
let t3;
|
|
16
16
|
let t4;
|
|
17
|
+
let t5;
|
|
17
18
|
if ($[0] !== t0) {
|
|
18
|
-
const { render:
|
|
19
|
-
render =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
t1 =
|
|
23
|
-
t2 =
|
|
19
|
+
const { render: t6, ...props } = t0;
|
|
20
|
+
render = t6;
|
|
21
|
+
t5 = useRender;
|
|
22
|
+
t4 = "code";
|
|
23
|
+
t1 = "en";
|
|
24
|
+
t2 = props;
|
|
25
|
+
t3 = mergeStyles({ className: "x9f619 x1heor9g xbppi91 x1s8wshw xj0a0fe" }, props);
|
|
24
26
|
$[0] = t0;
|
|
25
27
|
$[1] = render;
|
|
26
28
|
$[2] = t1;
|
|
27
29
|
$[3] = t2;
|
|
28
30
|
$[4] = t3;
|
|
29
31
|
$[5] = t4;
|
|
32
|
+
$[6] = t5;
|
|
30
33
|
} else {
|
|
31
34
|
render = $[1];
|
|
32
35
|
t1 = $[2];
|
|
33
36
|
t2 = $[3];
|
|
34
37
|
t3 = $[4];
|
|
35
38
|
t4 = $[5];
|
|
39
|
+
t5 = $[6];
|
|
36
40
|
}
|
|
37
|
-
let t5;
|
|
38
|
-
if ($[6] !== t1 || $[7] !== t2) {
|
|
39
|
-
t5 = {
|
|
40
|
-
...t1,
|
|
41
|
-
...t2
|
|
42
|
-
};
|
|
43
|
-
$[6] = t1;
|
|
44
|
-
$[7] = t2;
|
|
45
|
-
$[8] = t5;
|
|
46
|
-
} else t5 = $[8];
|
|
47
41
|
let t6;
|
|
48
|
-
if ($[
|
|
42
|
+
if ($[7] !== t1 || $[8] !== t2 || $[9] !== t3) {
|
|
49
43
|
t6 = {
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
lang: t1,
|
|
45
|
+
...t2,
|
|
46
|
+
...t3
|
|
47
|
+
};
|
|
48
|
+
$[7] = t1;
|
|
49
|
+
$[8] = t2;
|
|
50
|
+
$[9] = t3;
|
|
51
|
+
$[10] = t6;
|
|
52
|
+
} else t6 = $[10];
|
|
53
|
+
let t7;
|
|
54
|
+
if ($[11] !== render || $[12] !== t4 || $[13] !== t6) {
|
|
55
|
+
t7 = {
|
|
56
|
+
defaultTagName: t4,
|
|
57
|
+
props: t6,
|
|
52
58
|
render
|
|
53
59
|
};
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
} else
|
|
59
|
-
return
|
|
60
|
+
$[11] = render;
|
|
61
|
+
$[12] = t4;
|
|
62
|
+
$[13] = t6;
|
|
63
|
+
$[14] = t7;
|
|
64
|
+
} else t7 = $[14];
|
|
65
|
+
return t5(t7);
|
|
60
66
|
}
|
|
61
67
|
export { Code as default };
|
|
62
68
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","useRender","mergeStyles","Code","t0","$","render","t1","t2","t3","t4","t5","props","className","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","useRender","mergeStyles","Code","t0","$","render","t1","t2","t3","t4","t5","t6","props","className","lang","t7","defaultTagName"],"sources":["../../../src/components/code/index.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport type { RenderComponentProps } from '../../render/useRender';\nimport { useRender } from '../../render/useRender';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { typography } from '../../tokens/design.tokens.stylex';\n\n// Sized in em rather than px, so a fragment of code takes the scale of\n// whatever it interrupts. A mono face at the same nominal size as the prose\n// around it reads a little larger — its glyphs are wider and its x-height\n// taller — so 0.875em is what makes the two look level rather than what makes\n// them measure the same.\n//\n// No background. The mono face against the serif and sans faces the rest of\n// the system uses is already an unmistakable signal, and a tint here would\n// introduce a second surface inside Card and Sheet, competing with the\n// hierarchy those already establish. A call site wanting one can wrap this.\n//\n// No Material Design page draws inline code. What it follows is the type it\n// interrupts: the role and the colour of the prose around it, at the ratio\n// above, in the mono face the type tokens carry.\n//\n// The colour is inherited rather than set. A fixed on surface matched the\n// prose only when the prose was on surface too: inside a muted or an error\n// line it went dark mid-sentence, and on an inverse surface, a tooltip's or a\n// snackbar's, it was on surface over inverse surface and could not be read.\n// Whatever paints a surface around Code sets the colour that pairs with it,\n// as CopyField does for its value.\n//\n// It is in English whatever the page's language, through `lang` on the\n// element, as CopyField's value is. The mono stack names no face Windows\n// ships ahead of the generic `monospace`, and Chromium resolves that generic\n// by language: under Japanese it picked MS Gothic, which draws U+005C as a\n// yen sign, and under Korean a face drawing it as a won sign, so a path\n// showed one character and copied another. A Latin fragment gets a Latin\n// face, and one with Japanese in it still draws, since the browser falls back\n// character by character for what that face lacks. A call site's own `lang`\n// wins, for a fragment that is in another language.\n\ntype CodeProps = RenderComponentProps<'code'>;\n\n/**\n * A fragment of code, a path, or an identifier set in the mono face. It\n * renders a `<code>` and takes its scale from the text around it.\n */\nfunction Code({\n render,\n ...props\n}: CodeProps) {\n return useRender({\n defaultTagName: 'code',\n props: {\n lang: 'en',\n ...props,\n ...mergeStyles({\n className: \"x9f619 x1heor9g xbppi91 x1s8wshw xj0a0fe\"\n }, props)\n },\n render\n });\n}\nexport type { CodeProps };\nexport default Code;"],"mappings":";;;;;;;;;AA+CA,SAAAG,KAAAC,IAAA;CAAA,MAAAC,IAAAL,EAAA,EAAA;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAN,EAAA,OAAAD,IAAA;EAAc,MAAA,EAAAE,QAAAM,IAAA,GAAAC,UAAAT;EAAAE,SAAAM;EAILX,KAAAA;EACWS,KAAA;EAERH,KAAA;EACHM,KAAAA;EACAJ,KAAAP,YAAY,EAAAY,WACF,2CACb,GAAGD,KAAK;EAACR,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAA;EAAAL,SAAAD,EAAA;EAAAE,KAAAF,EAAA;EAAAG,KAAAH,EAAA;EAAAI,KAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;CAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAE,MAAAF,EAAA,OAAAG,MAAAH,EAAA,OAAAI,IAAA;EALJG,KAAA;GAAAG,MACCR;GAAI,GACPM;GAAK,GACLJ;EAGL;EAACJ,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,IAAAW;CAAA,IAAAX,EAAA,QAAAC,UAAAD,EAAA,QAAAK,MAAAL,EAAA,QAAAO,IAAA;EARcI,KAAA;GAAAC,gBACCP;GAAMG,OACfD;GAMNN;EAEH;EAACD,EAAA,MAAAC;EAAAD,EAAA,MAAAK;EAAAL,EAAA,MAAAO;EAAAP,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAVMJ,GAAUe,EAUhB;AAAC"}
|
|
@@ -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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EAAA;CAAA,OArBDe;AAqBC"}
|
|
@@ -30,8 +30,10 @@ const triggerStyles = {
|
|
|
30
30
|
base: {
|
|
31
31
|
kGNEyG: "x6s0dn4",
|
|
32
32
|
kWkggS: "x1vnz5z6",
|
|
33
|
+
kVAM5u: "x133yhug x1qfu9ae",
|
|
33
34
|
kaIpWk: "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,IAA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BqB,UAAAA;EADkB,CAAA;EAgDHtB,EAAA,MAAAC;EAAAD,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,MAAAvB,EAAA;CAAA,OAhDZuB;AAgDY;AAjErB,SAAAf,MAAAG,OAAA;CAAA,OA2BoC7D,MAAaiB,cAAaC,MAAOd,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,IAA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A;EAgDHtB,EAAA,MAAAC;EAAAD,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,MAAAvB,EAAA;CAAA,OAhDZuB;AAgDY;AAjErB,SAAAf,MAAAG,OAAA;CAAA,OA2BoC/D,MAAaiB,cAAaC,MAAOd,MAAKiE,MAAON,MAAKa,aAAc3D,cAAaqB,SAAUyB,MAAKc,aAAc5D,cAAasB,SAAUwB,MAAKlB,cAAe5B,cAAaoB,QAAS;AAAC"}
|
|
@@ -73,7 +73,7 @@ function ColorSwatch(t0) {
|
|
|
73
73
|
if ($[9] !== props$1) {
|
|
74
74
|
t2 = /* @__PURE__ */ jsx(ColorSwatch$1, {
|
|
75
75
|
...props$1,
|
|
76
|
-
className: "x5yr21d x1tfhd1
|
|
76
|
+
className: "x5yr21d x1tfhd1 xos13b x9f619 x1lliihq xh8yej3"
|
|
77
77
|
});
|
|
78
78
|
$[9] = props$1;
|
|
79
79
|
$[10] = t2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_c","stylex","useContext","ColorSwatch","chequer","mergeStyles","SwatchSquareContext","styles","ground","kZKoxP","kaIpWk","kB7OPa","k1xSpc","kzqmXN","kVQacm","$$css","className","style","t0","$","props","ref","placed","t1","t2","t3","RACColorSwatch"],"sources":["../../../src/components/color-swatch/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, RefAttributes } from 'react';\nimport type { ColorSwatchProps as RACColorSwatchProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { ColorSwatch as RACColorSwatch } from 'react-aria-components';\nimport { chequer } from '../../styles/chequer';\nimport { mergeStyles } from '../../styles/merge';\nimport { SwatchSquareContext } from '../../swatch';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii } from '../../tokens/design.tokens.stylex';\n\n// A single colour, drawn as a square. The design carries no page for this —\n// its colour guidance is about the roles a component takes, not about\n// showing a colour as a value — so the shape here is the library's own,\n// built from what the rest of it already uses.\n//\n// Three things follow from that, and each is a choice rather than a reading.\n//\n// **A swatch is outlined.** Its own colour is the content, so it cannot\n// carry a contrasting one — and a white swatch on a light surface, or a\n// near-black one in dark mode, would otherwise have no edge at all.
|
|
1
|
+
{"version":3,"file":"index.js","names":["_c","stylex","useContext","ColorSwatch","chequer","mergeStyles","SwatchSquareContext","styles","ground","kZKoxP","kaIpWk","kB7OPa","k1xSpc","kzqmXN","kVQacm","$$css","className","style","t0","$","props","ref","placed","t1","t2","t3","RACColorSwatch"],"sources":["../../../src/components/color-swatch/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, RefAttributes } from 'react';\nimport type { ColorSwatchProps as RACColorSwatchProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { ColorSwatch as RACColorSwatch } from 'react-aria-components';\nimport { chequer } from '../../styles/chequer';\nimport { mergeStyles } from '../../styles/merge';\nimport { SwatchSquareContext } from '../../swatch';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii } from '../../tokens/design.tokens.stylex';\n\n// A single colour, drawn as a square. The design carries no page for this —\n// its colour guidance is about the roles a component takes, not about\n// showing a colour as a value — so the shape here is the library's own,\n// built from what the rest of it already uses.\n//\n// Three things follow from that, and each is a choice rather than a reading.\n//\n// **A swatch is outlined.** Its own colour is the content, so it cannot\n// carry a contrasting one — and a white swatch on a light surface, or a\n// near-black one in dark mode, would otherwise have no edge at all. That edge\n// carries the value, so it is a boundary a reader has to see, and it takes\n// the outline role a field's box takes rather than outline variant, which\n// Material Design keeps for decoration that needs no contrast: outline\n// variant stood at about 1.6:1 against the surface, short of the 3:1 WCAG\n// asks of a boundary.\n//\n// **Transparency is drawn against a chequer rather than against the page.**\n// A half-transparent red over a white surface and an opaque pink are the\n// same pixels; the chequer is what tells them apart. It is built from two\n// surface tokens, so it follows the theme rather than being a fixed grey.\n//\n// **The chequer is a layer behind the swatch, not a background on it.**\n// React Aria sets the colour through the element's own inline\n// `background-color`, and CSS paints a background image over a background\n// colour rather than under it — so a chequer on the same element would\n// cover the colour it is there to reveal.\n\nconst SQUARE = '40px';\nconst styles = {\n ground: {\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1rg5ohu\",\n kzqmXN: \"x100vrsf\",\n kVQacm: \"xb3r6kr\",\n $$css: true\n }\n};\ntype ColorSwatchProps = Omit<RACColorSwatchProps, 'className' | 'style'> & {\n /**\n * Lands on the square around the swatch, 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 swatch, as `className` does. */\n style?: CSSProperties;\n};\n\n/**\n * A colour shown as a value: a square of it, with a chequer behind so\n * transparency reads as transparency. The colour is React Aria's — a CSS\n * string, or a `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * import { parseColor } from '@kanso-labs/kanso-ui'\n *\n * <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />\n * ```\n *\n * React Aria names it from the colour itself — \"light vibrant cyan blue, 60%\n * transparent\" — so it needs no label. Pass `colorName` to say something\n * else instead.\n *\n * The call site's `className` and `style` land on the square around the\n * swatch rather than on the swatch itself, which is what makes setting a\n * size from outside work — the colour fills whatever square it is given.\n * React Aria's function forms are not taken here, since a swatch has no\n * interactive state for one to read.\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 swatch inside it.\nfunction ColorSwatch({\n className,\n ref,\n style,\n ...props\n}: ColorSwatchProps & RefAttributes<HTMLSpanElement>) {\n const placed = useContext(SwatchSquareContext);\n return <span ref={ref} {...mergeStyles(stylex.props(chequer.ground, styles.ground, placed), {\n className,\n style\n })}>\n <RACColorSwatch {...props} className=\"x5yr21d x1tfhd1 xos13b x9f619 x1lliihq xh8yej3\" />\n </span>;\n}\nexport type { ColorSwatchProps };\nexport default ColorSwatch;"],"mappings":";;;;;;;;;;AAyCA,MAAMO,SAAS,EACbC,QA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