@kanso-labs/kanso-ui 0.16.0 → 0.17.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/components/checkbox/index.js +46 -41
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +31 -62
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/container/index.js +1 -1
- package/dist/components/container/index.js.map +1 -1
- package/dist/components/form/index.d.ts +31 -0
- package/dist/components/form/index.js +27 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/icon-button/index.js +7 -5
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +5 -1
- package/dist/components/number-field/index.d.ts +75 -0
- package/dist/components/number-field/index.js +158 -0
- package/dist/components/number-field/index.js.map +1 -0
- package/dist/components/radio-group/index.js +4 -3
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +44 -0
- package/dist/components/search-field/index.js +64 -0
- package/dist/components/search-field/index.js.map +1 -0
- package/dist/components/switch/index.js +158 -10
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +69 -0
- package/dist/components/text-area/index.js +47 -0
- package/dist/components/text-area/index.js.map +1 -0
- package/dist/components/text-field/index.d.ts +44 -2
- package/dist/components/text-field/index.js +21 -6
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/field/index.d.ts +7 -0
- package/dist/field/index.js +462 -67
- package/dist/field/index.js.map +1 -1
- package/dist/field/root.js +29 -6
- package/dist/field/root.js.map +1 -1
- package/dist/glyphs/index.js +66 -2
- package/dist/glyphs/index.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/react-aria.d.ts +2 -2
- package/dist/react-aria.js +2 -2
- package/dist/styles.css +236 -10
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@ import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
|
2
2
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
3
3
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
4
4
|
import { FieldMessage } from "../../field/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
|
|
6
6
|
import { CheckGlyph, IndeterminateGlyph } from "../../glyphs/index.js";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
@@ -153,32 +153,37 @@ function buttonContent(children, ripple) {
|
|
|
153
153
|
* which is the element a layout positions.
|
|
154
154
|
*/
|
|
155
155
|
function Checkbox(t0) {
|
|
156
|
-
const $ = c(
|
|
156
|
+
const $ = c(18);
|
|
157
157
|
const { children, description, error, ...props } = t0;
|
|
158
158
|
const ripple = useRipple();
|
|
159
|
+
const validationBehavior = useFieldValidationBehavior();
|
|
159
160
|
const T0 = CheckboxField;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
let t1;
|
|
162
|
+
if ($[0] !== error) {
|
|
163
|
+
t1 = invalidFrom(error);
|
|
164
|
+
$[0] = error;
|
|
165
|
+
$[1] = t1;
|
|
166
|
+
} else t1 = $[1];
|
|
167
|
+
const t2 = mergeStatefulStyles({ className: "x7a106z x9f619 xpr5407 xrvj5dj x1pmbctz" }, props);
|
|
168
|
+
let t3;
|
|
169
|
+
if ($[2] !== children || $[3] !== ripple) {
|
|
170
|
+
t3 = buttonContent(children, ripple);
|
|
171
|
+
$[2] = children;
|
|
172
|
+
$[3] = ripple;
|
|
173
|
+
$[4] = t3;
|
|
174
|
+
} else t3 = $[4];
|
|
163
175
|
let t4;
|
|
164
|
-
if ($[
|
|
165
|
-
t4 =
|
|
166
|
-
$[0] = children;
|
|
167
|
-
$[1] = ripple;
|
|
168
|
-
$[2] = t4;
|
|
169
|
-
} else t4 = $[2];
|
|
170
|
-
let t5;
|
|
171
|
-
if ($[3] !== t4) {
|
|
172
|
-
t5 = /* @__PURE__ */ jsx(CheckboxButton, {
|
|
176
|
+
if ($[5] !== t3) {
|
|
177
|
+
t4 = /* @__PURE__ */ jsx(CheckboxButton, {
|
|
173
178
|
className: "xjp7ctv",
|
|
174
|
-
children:
|
|
179
|
+
children: t3
|
|
175
180
|
});
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
} else
|
|
179
|
-
let
|
|
180
|
-
if ($[
|
|
181
|
-
|
|
181
|
+
$[5] = t3;
|
|
182
|
+
$[6] = t4;
|
|
183
|
+
} else t4 = $[6];
|
|
184
|
+
let t5;
|
|
185
|
+
if ($[7] !== description || $[8] !== error) {
|
|
186
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
182
187
|
className: "x1xdureb",
|
|
183
188
|
children: /* @__PURE__ */ jsx(FieldMessage, {
|
|
184
189
|
description,
|
|
@@ -186,29 +191,29 @@ function Checkbox(t0) {
|
|
|
186
191
|
inset: false
|
|
187
192
|
})
|
|
188
193
|
});
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
} else
|
|
193
|
-
let
|
|
194
|
-
if ($[
|
|
195
|
-
|
|
194
|
+
$[7] = description;
|
|
195
|
+
$[8] = error;
|
|
196
|
+
$[9] = t5;
|
|
197
|
+
} else t5 = $[9];
|
|
198
|
+
let t6;
|
|
199
|
+
if ($[10] !== T0 || $[11] !== props || $[12] !== t1 || $[13] !== t2 || $[14] !== t4 || $[15] !== t5 || $[16] !== validationBehavior) {
|
|
200
|
+
t6 = /* @__PURE__ */ jsxs(T0, {
|
|
196
201
|
isInvalid: t1,
|
|
197
|
-
validationBehavior
|
|
202
|
+
validationBehavior,
|
|
198
203
|
...props,
|
|
199
|
-
...
|
|
200
|
-
children: [
|
|
204
|
+
...t2,
|
|
205
|
+
children: [t4, t5]
|
|
201
206
|
});
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
204
|
-
$[
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
} else
|
|
211
|
-
return
|
|
207
|
+
$[10] = T0;
|
|
208
|
+
$[11] = props;
|
|
209
|
+
$[12] = t1;
|
|
210
|
+
$[13] = t2;
|
|
211
|
+
$[14] = t4;
|
|
212
|
+
$[15] = t5;
|
|
213
|
+
$[16] = validationBehavior;
|
|
214
|
+
$[17] = t6;
|
|
215
|
+
} else t6 = $[17];
|
|
216
|
+
return t6;
|
|
212
217
|
}
|
|
213
218
|
//#endregion
|
|
214
219
|
export { Checkbox as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["FIELD_VALIDATION_BEHAVIOR","description","error"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxButton, CheckboxField } from 'react-aria-components';\nimport { FieldMessage } from '../../field';\nimport { FIELD_VALIDATION_BEHAVIOR } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\nconst styles = {\n box: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"xrpadme\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x3y1ksm\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x100vrsf\",\n kjj79g: \"xl56j7k\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x15406qy\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n controlDisabled: {\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n controlFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x1hl8ikr\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n controlReadOnly: {\n kkrTdU: \"xt0e3qv\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLSpanElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// 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. The ripple's handlers and surface go on the\n// control while the checkbox can change, and are left off while it cannot,\n// since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, ripple: Ripple) {\n return (state: CheckboxButtonRenderProps) => {\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...interactive ? ripple.handlers : {}} {...stylex.props(styles.control, state.isReadOnly && styles.controlReadOnly, state.isDisabled && styles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && styles.controlFocused)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n {state.isIndeterminate ? <IndeterminateGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : state.isSelected ? <CheckGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : null}\n </span>\n {interactive ? ripple.surface : null}\n </span>\n {children === undefined ? null : <span {...{\n 0: {\n className: \"x9f619 x139gbkf x1ypdohk x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll\"\n },\n 2: {\n className: \"x9f619 x139gbkf x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll xt0e3qv\"\n },\n 1: {\n className: \"x9f619 x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll x1xj74d8 x1h6gzvc\"\n },\n 3: {\n className: \"x9f619 x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll x1xj74d8 x1h6gzvc\"\n }\n }[!!state.isReadOnly << 1 | !!state.isDisabled << 0]}>\n {children}\n </span>}\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps) {\n const ripple = useRipple<HTMLSpanElement>();\n return <CheckboxField isInvalid={error !== undefined} validationBehavior={FIELD_VALIDATION_BEHAVIOR} {...props} {...mergeStatefulStyles({\n className: \"x7a106z x9f619 xpr5407 xrvj5dj x1pmbctz\"\n }, props)}>\n <CheckboxButton className=\"xjp7ctv\">\n {buttonContent(children, ripple)}\n </CheckboxButton>\n <div className=\"x1xdureb\">\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </CheckboxField>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;AAgCA,MAAM,SAAS;CACb,KAAK;EACH,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,mBAAmB;EACjB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,gBAAgB;EACd,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,mBAAmB;EACjB,QAAQ;EACR,OAAO;CACT;CACA,qBAAqB;EACnB,QAAQ;EACR,OAAO;CACT;CACA,kBAAkB;EAChB,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAA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AAK,CAAA;EAC9D,CAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA,EAAA,OAAA,SAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EARH,KAAA,qBAAC,IAAD;GAA0B,WAAA;GAAyCA,oBAAAA;GAAyB,GAAM;GAAK,GAAM;GAA7G,UAAA,CAGH,IAGA,EANiB;;EASH,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OATX;AASW"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["description","error","validationBehavior"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxButton, CheckboxField } from 'react-aria-components';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\nconst styles = {\n box: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"xrpadme\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x3y1ksm\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x139gbkf\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"x100vrsf\",\n kjj79g: \"xl56j7k\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x15406qy\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n controlDisabled: {\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n controlFocused: {\n kjBf7l: \"xrgy624\",\n kInvED: \"x1hl8ikr\",\n k3XXqK: \"xaatb59\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n controlReadOnly: {\n kkrTdU: \"xt0e3qv\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLSpanElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// 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. The ripple's handlers and surface go on the\n// control while the checkbox can change, and are left off while it cannot,\n// since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, ripple: Ripple) {\n return (state: CheckboxButtonRenderProps) => {\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...interactive ? ripple.handlers : {}} {...stylex.props(styles.control, state.isReadOnly && styles.controlReadOnly, state.isDisabled && styles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && styles.controlFocused)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n {state.isIndeterminate ? <IndeterminateGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : state.isSelected ? <CheckGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : null}\n </span>\n {interactive ? ripple.surface : null}\n </span>\n {children === undefined ? null : <span {...{\n 0: {\n className: \"x9f619 x139gbkf x1ypdohk x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll\"\n },\n 2: {\n className: \"x9f619 x139gbkf x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll xt0e3qv\"\n },\n 1: {\n className: \"x9f619 x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll x1xj74d8 x1h6gzvc\"\n },\n 3: {\n className: \"x9f619 x16svsjw x1848etk x1c52epr x1qn8t5l xh7dzej x1cmllll x1xj74d8 x1h6gzvc\"\n }\n }[!!state.isReadOnly << 1 | !!state.isDisabled << 0]}>\n {children}\n </span>}\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps) {\n const ripple = useRipple<HTMLSpanElement>();\n const validationBehavior = useFieldValidationBehavior();\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles({\n className: \"x7a106z x9f619 xpr5407 xrvj5dj x1pmbctz\"\n }, props)}>\n <CheckboxButton className=\"xjp7ctv\">\n {buttonContent(children, ripple)}\n </CheckboxButton>\n <div className=\"x1xdureb\">\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </CheckboxField>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;AAgCA,MAAM,SAAS;CACb,KAAK;EACH,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,mBAAmB;EACjB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,gBAAgB;EACd,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,mBAAmB;EACjB,QAAQ;EACR,OAAO;CACT;CACA,qBAAqB;EACnB,QAAQ;EACR,OAAO;CACT;CACA,kBAAkB;EAChB,QAAQ;EACR,OAAO;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ADlC,KAAA,oBAAC,gBAAD;GAA0B,WAAA;GACvB,UAAA;EADY,CAAA;EAEE,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,eAAA,EAAA,OAAA,OAAA;EACjB,KAAA,oBAAA,OAAA;GAAe,WAAA;GACb,UAAA,oBAAC,cAAD;IAA2B;IAAoB;IAAc,OAAA;GAAK,CAAA;EAC9D,CAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,MAAA,EAAA,QAAA,SAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,oBAAA;EARH,KAAA,qBAAC,IAAD;GAA0B,WAAA;GAAwC;GAAkB,GAAM;GAAK,GAAM;GAArG,UAAA,CAGH,IAGA,EANiB;;EASH,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OATX;AASW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
2
2
|
import { FieldLabel, FieldMessage } from "../../field/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { CheckboxGroup } from "react-aria-components";
|
|
@@ -16,75 +16,44 @@ import { CheckboxGroup } from "react-aria-components";
|
|
|
16
16
|
* which is the element a layout positions.
|
|
17
17
|
*/
|
|
18
18
|
function CheckboxGroup$1(t0) {
|
|
19
|
-
const $ = c(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let error;
|
|
24
|
-
let label;
|
|
19
|
+
const $ = c(14);
|
|
20
|
+
const { children, description, error, label, ...props } = t0;
|
|
21
|
+
const validationBehavior = useFieldValidationBehavior();
|
|
22
|
+
const T0 = CheckboxGroup;
|
|
25
23
|
let t1;
|
|
26
|
-
|
|
24
|
+
if ($[0] !== error) {
|
|
25
|
+
t1 = invalidFrom(error);
|
|
26
|
+
$[0] = error;
|
|
27
|
+
$[1] = t1;
|
|
28
|
+
} else t1 = $[1];
|
|
29
|
+
const t2 = mergeStatefulStyles({ className: "x9f619 x78zum5 xdt5ytf xzoy561" }, props);
|
|
27
30
|
let t3;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const { children: t5, description: t6, error: t7, label: t8, ...props } = t0;
|
|
31
|
-
children = t5;
|
|
32
|
-
description = t6;
|
|
33
|
-
error = t7;
|
|
34
|
-
label = t8;
|
|
35
|
-
T0 = CheckboxGroup;
|
|
36
|
-
t1 = error !== void 0;
|
|
37
|
-
t2 = FIELD_VALIDATION_BEHAVIOR;
|
|
38
|
-
t3 = props;
|
|
39
|
-
t4 = mergeStatefulStyles({ className: "x9f619 x78zum5 xdt5ytf xzoy561" }, props);
|
|
40
|
-
$[0] = t0;
|
|
41
|
-
$[1] = T0;
|
|
31
|
+
if ($[2] !== children || $[3] !== description || $[4] !== error || $[5] !== label) {
|
|
32
|
+
t3 = groupContent(label, children, description, error);
|
|
42
33
|
$[2] = children;
|
|
43
34
|
$[3] = description;
|
|
44
35
|
$[4] = error;
|
|
45
36
|
$[5] = label;
|
|
46
|
-
$[6] =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
T0 = $[1];
|
|
52
|
-
children = $[2];
|
|
53
|
-
description = $[3];
|
|
54
|
-
error = $[4];
|
|
55
|
-
label = $[5];
|
|
56
|
-
t1 = $[6];
|
|
57
|
-
t2 = $[7];
|
|
58
|
-
t3 = $[8];
|
|
59
|
-
t4 = $[9];
|
|
60
|
-
}
|
|
61
|
-
let t5;
|
|
62
|
-
if ($[10] !== children || $[11] !== description || $[12] !== error || $[13] !== label) {
|
|
63
|
-
t5 = groupContent(label, children, description, error);
|
|
64
|
-
$[10] = children;
|
|
65
|
-
$[11] = description;
|
|
66
|
-
$[12] = error;
|
|
67
|
-
$[13] = label;
|
|
68
|
-
$[14] = t5;
|
|
69
|
-
} else t5 = $[14];
|
|
70
|
-
let t6;
|
|
71
|
-
if ($[15] !== T0 || $[16] !== t1 || $[17] !== t2 || $[18] !== t3 || $[19] !== t4 || $[20] !== t5) {
|
|
72
|
-
t6 = /* @__PURE__ */ jsx(T0, {
|
|
37
|
+
$[6] = t3;
|
|
38
|
+
} else t3 = $[6];
|
|
39
|
+
let t4;
|
|
40
|
+
if ($[7] !== T0 || $[8] !== props || $[9] !== t1 || $[10] !== t2 || $[11] !== t3 || $[12] !== validationBehavior) {
|
|
41
|
+
t4 = /* @__PURE__ */ jsx(T0, {
|
|
73
42
|
isInvalid: t1,
|
|
74
|
-
validationBehavior
|
|
75
|
-
...
|
|
76
|
-
...
|
|
77
|
-
children:
|
|
43
|
+
validationBehavior,
|
|
44
|
+
...props,
|
|
45
|
+
...t2,
|
|
46
|
+
children: t3
|
|
78
47
|
});
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
} else
|
|
87
|
-
return
|
|
48
|
+
$[7] = T0;
|
|
49
|
+
$[8] = props;
|
|
50
|
+
$[9] = t1;
|
|
51
|
+
$[10] = t2;
|
|
52
|
+
$[11] = t3;
|
|
53
|
+
$[12] = validationBehavior;
|
|
54
|
+
$[13] = t4;
|
|
55
|
+
} else t4 = $[13];
|
|
56
|
+
return t4;
|
|
88
57
|
}
|
|
89
58
|
function groupContent(label, children, description, error) {
|
|
90
59
|
return (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["validationBehavior"],"sources":["../../../src/components/checkbox-group/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { CheckboxGroupRenderProps, CheckboxGroupProps as RACCheckboxGroupProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxGroup as RACCheckboxGroup } from 'react-aria-components';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { spacing, typography } from '../../tokens/design.tokens.stylex';\n\n// A labelled set of checkboxes sharing one value. The checkbox page draws\n// the boxes; the group is what the ARIA pattern asks for around them — a\n// group named by its label, described by its description, and invalid as a\n// whole — and its label, description and error are the field chrome's, so a\n// group reads like the fields beside it. The label is label-large, the role\n// a field's label takes at rest, since a group has no box to float it in.\n\ntype CheckboxGroupProps = {\n /** The checkboxes, each with a `value` of its own. */\n children?: ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state — the message, the boxes' error\n * colours and `aria-invalid` all follow from it.\n */\n error?: string;\n /**\n * What the group is for. Required rather than optional: a group of\n * checkboxes with no name is a set of boxes a screen reader cannot\n * introduce.\n */\n label: string;\n} & Omit<RACCheckboxGroupProps, 'children' | 'isInvalid' | 'validationBehavior'>;\n\n/**\n * A labelled set of checkboxes with one value between them. The value is\n * React Aria's: pass `value` with `onChange` to control it, or\n * `defaultValue` to let the group keep its own, and each `Checkbox` inside\n * names the entry it stands for with `value`. Disabled, read-only and the\n * error state reach every checkbox from here.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction CheckboxGroup({\n children,\n description,\n error,\n label,\n ...props\n}: CheckboxGroupProps) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACCheckboxGroup isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 xdt5ytf xzoy561\"\n }, props)}>\n {groupContent(label, children, description, error)}\n </RACCheckboxGroup>;\n}\n\n// 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. The label takes the group's render state, so\n// its colour follows disabled and invalid the way a field's follows its box.\nfunction groupContent(label: string, children: ReactNode, description: string | undefined, error: string | undefined) {\n return (state: CheckboxGroupRenderProps) => <>\n <FieldLabel state={state} className=\"xkknnkr x14zspaw x1v9cpvo x155f00i x1lz68p4\">\n {label}\n </FieldLabel>\n <div className=\"x78zum5 xdt5ytf\">{children}</div>\n <FieldMessage description={description} error={error} inset={false} />\n </>;\n}\nexport type { CheckboxGroupProps };\nexport default CheckboxGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAiDA,SAAA,gBAAA,IAAA;CAAA,MAAA,IAAA,EAAA,EAAA;CAAuB,MAAA,EAAA,UAAA,aAAA,OAAA,OAAA,GAAA,UAAA;CAOrB,MAAA,qBAA2B,2BAA2B;CAC9C,MAAA,KAAA;CAAgB,IAAA;CAAA,IAAA,EAAA,OAAA,OAAA;EAAY,KAAA,YAAY,KAAK;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAyD,MAAA,KAAA,oBAAoB,EAAA,WACtH,iCACb,GAAG,KAAK;CAAC,IAAA;CAAA,IAAA,EAAA,OAAA,YAAA,EAAA,OAAA,eAAA,EAAA,OAAA,SAAA,EAAA,OAAA,OAAA;EACJ,KAAA,aAAa,OAAO,UAAU,aAAa,KAAK;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA,EAAA,OAAA,SAAA,EAAA,OAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,oBAAA;EAH/C,KAAA,oBAAC,IAAD;GAA6B,WAAA;GAAwC;GAAkB,GAAM;GAAK,GAAM;GAG1G,UAAA;EAHmB,CAAA;EAIH,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAJd;AAIc;AAOvB,SAAS,aAAa,OAAe,UAAqB,aAAiC,OAA2B;CACpH,QAAQ,UAAoC,qBAAA,UAAA,EAAA,UAAA;EACxC,oBAAC,YAAD;GAAmB;GAAO,WAAU;GACjC,UAAA;EACS,CAAA;EACZ,oBAAC,OAAD;GAAK,WAAU;GAAmB;EAAc,CAAA;EAChD,oBAAC,cAAD;GAA2B;GAAoB;GAAO,OAAO;EAAM,CAAA;CACrE,EAAA,CAAA;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/container/index.tsx"],"sourcesContent":["import * 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 { spacing } from '../../tokens/design.tokens.stylex';\n\n// The width fourteen of this library's own story files already centre their\n// page on, which is what makes it the default rather than a number picked\n// here. A measure is a property of the content: 960px suits a page of mixed\n// components, and prose wants something nearer 58ch, which is what the story\n// files that hold prose use. Say which one you mean rather than taking this.\nconst DEFAULT_MAX_INLINE_SIZE = '960px';\n\n// A dynamic style rather than a static one, for the same reason Feed's is:\n// the measure comes from the call site and StyleX compiles its classes ahead\n// of time, so the value is written to a custom property inline instead.\n//\n// No Material Design page draws a page container; the layout pages give the\n// margins one keeps. The gutter is
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/container/index.tsx"],"sourcesContent":["import * 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 { spacing } from '../../tokens/design.tokens.stylex';\n\n// The width fourteen of this library's own story files already centre their\n// page on, which is what makes it the default rather than a number picked\n// here. A measure is a property of the content: 960px suits a page of mixed\n// components, and prose wants something nearer 58ch, which is what the story\n// files that hold prose use. Say which one you mean rather than taking this.\nconst DEFAULT_MAX_INLINE_SIZE = '960px';\n\n// One pixel of the layout pages' own breakpoint: a compact window is below\n// 600, and a medium window starts at it.\nconst MEDIUM_WINDOW = '@media (width >= 600px)';\n\n// A dynamic style rather than a static one, for the same reason Feed's is:\n// the measure comes from the call site and StyleX compiles its classes ahead\n// of time, so the value is written to a custom property inline instead.\n//\n// No Material Design page draws a page container; the layout pages give the\n// margins one keeps. The gutter is the margin those pages give a window of\n// each size — 16dp while the window is compact, 24dp from medium up — and\n// the measure is the call site's, since the pages leave a pane's width to\n// its content.\nconst _temp = {\n kB7OPa: \"x9f619\",\n kzqmXN: \"xh8yej3\",\n kUOVxO: \"xvueqy4\",\n ks0D6T: \"x13i5qev\",\n \"$$css\": true\n};\nconst styles = {\n paddingDefault: {\n kg3NbH: \"x790zyz x1njmi9r\",\n $$css: true\n },\n paddingNone: {\n kg3NbH: \"xnjsko4\",\n $$css: true\n },\n root: (maxInlineSize: string) => [_temp, {\n \"--x-maxInlineSize\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(maxInlineSize)\n }]\n};\ntype ContainerProps = RenderComponentProps<'div'> & {\n /**\n * How wide the content may run before it stops growing. The container is\n * centred in whatever space is left over.\n *\n * Worth setting. The default suits a page of mixed components; prose wants\n * a measure in `ch`, since what makes a line hard to read is how many\n * characters it holds rather than how many pixels.\n * @default '960px'\n */\n maxInlineSize?: string;\n /**\n * Inline padding, which is what keeps the content off the edge of the\n * window once it is narrower than the measure. `none` is for a container\n * nested inside one that already has it.\n * @default 'default'\n */\n padding?: 'default' | 'none';\n};\n\n/**\n * A centred measure for a page or a section of one: content grows to a width\n * and stops, with the leftover space split evenly either side.\n *\n * Layout only — it paints no surface and gives its children no container of\n * their own, which is what separates it from Card. It sets no gaps either, so\n * reach for Stack inside it for the rhythm between sections.\n *\n * `render` swaps the element, for a container that should be a `<main>` or a\n * `<section>` rather than a `<div>`.\n */\nfunction Container({\n maxInlineSize = DEFAULT_MAX_INLINE_SIZE,\n padding = 'default',\n render,\n ...props\n}: ContainerProps) {\n const padded = padding === 'none' ? styles.paddingNone : styles.paddingDefault;\n return useRender({\n defaultTagName: 'div',\n props: {\n ...props,\n ...mergeStyles(stylex.props(styles.root(maxInlineSize), padded), props)\n },\n render\n });\n}\nexport type { ContainerProps };\nexport default Container;"],"mappings":";;;;AAYA,MAAM,0BAA0B;AAehC,MAAM,QAAQ;CACZ,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;AACX;AACA,MAAM,SAAS;CACb,gBAAgB;EACd,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,OAAO;CACT;CACA,OAAO,kBAA0B,CAAC,OAAO,EACvC,uBAAsB,QAAO,OAAO,QAAQ,WAAW,MAAM,OAAO,OAAO,OAAO,MAAM,KAAA,EAAA,CAAW,aAAa,EAClH,CAAC;AACH;;;;;;;;;;;;AAgCA,SAAS,UAAU,EACjB,gBAAgB,yBAChB,UAAU,WACV,QACA,GAAG,WACc;CACjB,MAAM,SAAS,YAAY,SAAS,OAAO,cAAc,OAAO;CAChE,OAAO,UAAU;EACf,gBAAgB;EAChB,OAAO;GACL,GAAG;GACH,GAAG,YAAY,MAAa,OAAO,KAAK,aAAa,GAAG,MAAM,GAAG,OAAK;EACxE;EACA;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
import { FormProps } from "react-aria-components";
|
|
3
|
+
//#region src/components/form/index.d.ts
|
|
4
|
+
type FormProps$1 = Omit<FormProps, 'className' | 'style'> & {
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
/**
|
|
8
|
+
* How the fields inside validate. `aria` marks a field invalid and shows
|
|
9
|
+
* its message as soon as the field says so, and lets the form submit
|
|
10
|
+
* regardless. `native` hands validation to the browser: a required or
|
|
11
|
+
* malformed field blocks submission, and its message is the browser's
|
|
12
|
+
* own, shown once submission is tried.
|
|
13
|
+
* @default 'aria'
|
|
14
|
+
*/
|
|
15
|
+
validationBehavior?: 'aria' | 'native';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A form: the fields inside it and what they are told about validation. Pass
|
|
19
|
+
* `validationErrors`, an object keyed by field `name`, to show what a server
|
|
20
|
+
* sent back under each field, and `validationBehavior="native"` to let the
|
|
21
|
+
* browser's own constraint validation block submission. `onSubmit` is handed
|
|
22
|
+
* the submit event; call `preventDefault` on it to handle the submission
|
|
23
|
+
* yourself, and read the values from `new FormData(event.currentTarget)`.
|
|
24
|
+
*
|
|
25
|
+
* The call site's `className` and `style` land on the form element, which is
|
|
26
|
+
* the element a layout positions.
|
|
27
|
+
*/
|
|
28
|
+
declare function Form$1({ validationBehavior, ...props }: FormProps$1): import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { type FormProps$1 as FormProps, Form$1 as default };
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { mergeStyles } from "../../styles/merge.js";
|
|
2
|
+
import { FIELD_VALIDATION_BEHAVIOR } from "../../field/root.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Form } from "react-aria-components";
|
|
5
|
+
//#region src/components/form/index.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A form: the fields inside it and what they are told about validation. Pass
|
|
8
|
+
* `validationErrors`, an object keyed by field `name`, to show what a server
|
|
9
|
+
* sent back under each field, and `validationBehavior="native"` to let the
|
|
10
|
+
* browser's own constraint validation block submission. `onSubmit` is handed
|
|
11
|
+
* the submit event; call `preventDefault` on it to handle the submission
|
|
12
|
+
* yourself, and read the values from `new FormData(event.currentTarget)`.
|
|
13
|
+
*
|
|
14
|
+
* The call site's `className` and `style` land on the form element, which is
|
|
15
|
+
* the element a layout positions.
|
|
16
|
+
*/
|
|
17
|
+
function Form$1({ validationBehavior = FIELD_VALIDATION_BEHAVIOR, ...props }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
19
|
+
validationBehavior,
|
|
20
|
+
...props,
|
|
21
|
+
...mergeStyles({ className: "x9f619" }, props)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { Form$1 as default };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/form/index.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport type { FormProps as RACFormProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Form as RACForm } from 'react-aria-components';\nimport { FIELD_VALIDATION_BEHAVIOR } from '../../field/root';\nimport { mergeStyles } from '../../styles/merge';\n\n// No page of its own: a form is the fields inside it, and the text fields\n// page is what each of them draws — the error a form reports lands in the\n// field's supporting text, in the error role, under the box. The form\n// draws nothing, and lays nothing out either; a Stack inside it is what\n// spaces the fields.\n//\n// React Aria's `Form` is the element. It hands two things to the fields\n// inside it through context: `validationErrors`, keyed by each field's\n// `name`, which is how a server's answer reaches the fields without any of\n// them changing, and `validationBehavior`, which every field reads in place\n// of its own default. React Aria's own default for that is `native`; the\n// library's is `aria`, set here so a form and a field agree, with `native`\n// the opt-in.\n\ntype FormProps = Omit<RACFormProps, 'className' | 'style'> & {\n className?: string;\n style?: CSSProperties;\n /**\n * How the fields inside validate. `aria` marks a field invalid and shows\n * its message as soon as the field says so, and lets the form submit\n * regardless. `native` hands validation to the browser: a required or\n * malformed field blocks submission, and its message is the browser's\n * own, shown once submission is tried.\n * @default 'aria'\n */\n validationBehavior?: 'aria' | 'native';\n};\n\n/**\n * A form: the fields inside it and what they are told about validation. Pass\n * `validationErrors`, an object keyed by field `name`, to show what a server\n * sent back under each field, and `validationBehavior=\"native\"` to let the\n * browser's own constraint validation block submission. `onSubmit` is handed\n * the submit event; call `preventDefault` on it to handle the submission\n * yourself, and read the values from `new FormData(event.currentTarget)`.\n *\n * The call site's `className` and `style` land on the form element, which is\n * the element a layout positions.\n */\nfunction Form({\n validationBehavior = FIELD_VALIDATION_BEHAVIOR,\n ...props\n}: FormProps) {\n return <RACForm validationBehavior={validationBehavior} {...props} {...mergeStyles({\n className: \"x9f619\"\n }, props)} />;\n}\nexport type { FormProps };\nexport default Form;"],"mappings":";;;;;;;;;;;;;;;;AA8CA,SAAS,OAAK,EACZ,qBAAqB,2BACrB,GAAG,SACS;CACZ,OAAO,oBAAC,MAAD;EAA6B;EAAoB,GAAI;EAAO,GAAI,YAAY,EACjF,WAAW,SACb,GAAG,KAAK;CAAE,CAAA;AACZ"}
|
|
@@ -3,7 +3,7 @@ import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
|
3
3
|
import { useRipple } from "../../hooks/useRipple.js";
|
|
4
4
|
import { ariaAttributesOf, buttonRenderer, linkRenderer } from "../../render/aria.js";
|
|
5
5
|
import { jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { Button, Link } from "react-aria-components";
|
|
6
|
+
import { Button, ButtonContext, Link, useSlottedContext } from "react-aria-components";
|
|
7
7
|
//#region src/components/icon-button/index.tsx
|
|
8
8
|
const styles = {
|
|
9
9
|
base: {
|
|
@@ -108,8 +108,10 @@ const disabledStyles = {
|
|
|
108
108
|
* link with the same appearance. Every `aria-*` prop is forwarded to the
|
|
109
109
|
* element; React Aria alone would keep only the labelling ones.
|
|
110
110
|
*/
|
|
111
|
-
function IconButton({ children, disableRipple = false, href, isDisabled
|
|
112
|
-
const
|
|
111
|
+
function IconButton({ children, disableRipple = false, href, isDisabled, onClick, onContextMenu, onKeyDown, onKeyUp, onPointerCancel, onPointerDown, onPointerLeave, onPointerUp, rel, render, size = "md", target, variant = "standard", ...props$1 }) {
|
|
112
|
+
const context = useSlottedContext(ButtonContext, props$1.slot);
|
|
113
|
+
const disabled = isDisabled ?? context?.isDisabled ?? false;
|
|
114
|
+
const ripple = useRipple(!disableRipple && !disabled, {
|
|
113
115
|
onClick,
|
|
114
116
|
onContextMenu,
|
|
115
117
|
onPointerCancel,
|
|
@@ -125,7 +127,7 @@ function IconButton({ children, disableRipple = false, href, isDisabled = false,
|
|
|
125
127
|
};
|
|
126
128
|
if (href !== void 0) return /* @__PURE__ */ jsxs(Link, {
|
|
127
129
|
href,
|
|
128
|
-
isDisabled,
|
|
130
|
+
isDisabled: disabled,
|
|
129
131
|
rel,
|
|
130
132
|
render: linkRenderer(element),
|
|
131
133
|
target,
|
|
@@ -135,7 +137,7 @@ function IconButton({ children, disableRipple = false, href, isDisabled = false,
|
|
|
135
137
|
children: [children, ripple.surface]
|
|
136
138
|
});
|
|
137
139
|
return /* @__PURE__ */ jsxs(Button, {
|
|
138
|
-
isDisabled,
|
|
140
|
+
isDisabled: disabled,
|
|
139
141
|
render: buttonRenderer(element, render),
|
|
140
142
|
...ripple.handlers,
|
|
141
143
|
...props$1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/icon-button/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ClassNameOrFunction, FocusableElement, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Button as RACButton, Link as RACLink } from 'react-aria-components';\nimport type { ButtonDOMProps, ButtonState } from '../button';\nimport { useRipple } from '../../hooks/useRipple';\nimport { ariaAttributesOf, buttonRenderer, linkRenderer } from '../../render/aria';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// Each variant composites an 'on-color' over its own container at the\n// interaction state's opacity, rather than swapping in a separate hover\n// color. The pairs are the icon buttons spec page's: filled on primary,\n// tonal on secondary container, standard on surface variant over nothing. calc(<opacity> * 100%) turns the token's unitless 0-1 ratio into the\n// percentage color-mix() takes. Inlined at each property rather than factored\n// into a helper: @stylexjs/babel-plugin only statically recognizes\n// expressions written directly as property values.\n//\n// Disabled is a style of its own per variant rather than a `:disabled`\n// branch inside each property, for the reason Button's comment gives: given\n// `href` this renders as a link, which React Aria turns into a <span> while\n// disabled, and neither matches the pseudo-class. Applied last from the\n// render state, the disabled styles replace each property whole, hover and\n// pressed branches included.\n//\n// The corner softens from a circle to a rounded square while pressed, which\n// is the shape morph the icon buttons spec page gives this control, at the\n// pressed corner its size token set names: 8 for the two small sizes, 12 at\n// medium, 16 at the two large. Each size carries its own pressed radius, since\n// StyleX replaces the property whole. The two transitioned properties take\n// different curves — the colour change is linear-ish and the shape change is\n// emphasized — so the timing functions are a matching comma list rather than\n// one value.\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x3y1ksm\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kjj79g: \"xl56j7k\",\n kjBf7l: \"xrgy624\",\n kInvED: \"x1hl8ikr\",\n k3XXqK: \"x9v5kkp x1t137rt\",\n kMeerF: \"x1de99jn\",\n kmVPX3: \"x1717udv\",\n kVAEAm: \"x1n2onr6\",\n kybGjl: \"x1hl2dhg\",\n kIyJzY: \"x1iuyhda\",\n k1ekBW: \"xb5u718\",\n kAMwcw: \"x15l9jch\",\n $$css: true\n },\n disabled: {\n kaIpWk: \"x3y1ksm\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n filled: {\n kWkggS: \"xpky1to xyf7a0q xnety89\",\n kMwMTN: \"xwjo7ld\",\n $$css: true\n },\n filledDisabled: {\n kWkggS: \"xepofeg\",\n kMwMTN: \"x1xj74d8\",\n $$css: true\n },\n lg: {\n kZKoxP: \"xnnlda6\",\n kaIpWk: \"xtt5grq x3y1ksm\",\n kGuDYH: \"x1pvqxga\",\n kzqmXN: \"x15yg21f\",\n $$css: true\n },\n md: {\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x1r81nxe x3y1ksm\",\n kGuDYH: \"x1pvqxga\",\n kzqmXN: \"x100vrsf\",\n $$css: true\n },\n standard: {\n kWkggS: \"x83qkoq x1p2om7n xjbqb8w\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n standardDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x1xj74d8\",\n $$css: true\n },\n tonal: {\n kWkggS: \"xnqsvhv xlizrex x15dekr4\",\n kMwMTN: \"x1sawysd\",\n $$css: true\n },\n tonalDisabled: {\n kWkggS: \"xepofeg\",\n kMwMTN: \"x1xj74d8\",\n $$css: true\n },\n xl: {\n kZKoxP: \"xjp8j0k\",\n kaIpWk: \"x11f6t2b x3y1ksm\",\n kGuDYH: \"x1s3cmhv\",\n kzqmXN: \"x13oubkp\",\n $$css: true\n },\n xs: {\n kZKoxP: \"x10w6t97\",\n kaIpWk: \"x1r81nxe x3y1ksm\",\n kGuDYH: \"xwsyq91\",\n kzqmXN: \"x1td3qas\",\n $$css: true\n },\n xxl: {\n kZKoxP: \"xn866dk\",\n kaIpWk: \"x11f6t2b x3y1ksm\",\n kGuDYH: \"x1tgwohi\",\n kzqmXN: \"x1f2tiqu\",\n $$css: true\n }\n};\nconst disabledStyles = {\n filled: styles.filledDisabled,\n standard: styles.standardDisabled,\n tonal: styles.tonalDisabled\n};\ntype IconButtonProps = {\n /**\n * What the button does, in words. Required rather than optional: an icon\n * on its own has no accessible name, so without this the control announces\n * nothing at all.\n */\n 'aria-label': string;\n children?: ReactNode;\n /** A function may compute the class from the button's render state. */\n className?: ClassNameOrFunction<ButtonState>;\n /**\n * Disables the press ripple. The hover and pressed state layers are\n * unaffected.\n * @default false\n */\n disableRipple?: boolean;\n /**\n * Where the button leads. Given one, the button is rendered as a link —\n * an `<a>`, announced as the link it is — with the same styles and ripple.\n * `render`, `type`, and the form and pending props apply to the button\n * form only.\n */\n href?: string;\n /** The link's `rel`, when `href` is set. */\n rel?: string;\n /**\n * Control size: `xs` 32px, `md` 40px, `lg` 56px, `xl` 96px, `xxl` 136px —\n * the icon buttons spec page's XS to XL, and the same heights `Button`\n * uses, so the two line up beside each other in a row. The icon is 20px,\n * 24px, 24px, 32px and 40px in turn.\n * @default 'md'\n */\n size?: 'lg' | 'md' | 'xl' | 'xs' | 'xxl';\n /** A function may compute the style from the button's render state. */\n style?: StyleOrFunction<ButtonState>;\n /** The link's `target`, when `href` is set. */\n target?: string;\n /**\n * `standard` is transparent and tints what it sits on; `filled` and `tonal`\n * carry a container of their own.\n * @default 'standard'\n */\n variant?: 'filled' | 'standard' | 'tonal';\n} & ButtonDOMProps;\n\n/**\n * A button that is an icon, at five control heights. Given `href` it is a\n * link with the same appearance. Every `aria-*` prop is forwarded to the\n * element; React Aria alone would keep only the labelling ones.\n */\nfunction IconButton({\n children,\n disableRipple = false,\n href,\n isDisabled = false,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n rel,\n render,\n size = 'md',\n target,\n variant = 'standard',\n ...props\n}: IconButtonProps) {\n // `props` (className/style, etc.) is spread separately: `className` and\n // `style` there may be functions of render state, which ripple's own\n // handler-only merge doesn't need to know about. It is also why the styles\n // below merge through mergeStatefulStyles rather than the plain\n // mergeStyles. The ripple is off while disabled, as in Button.\n const ripple = useRipple<FocusableElement>(!disableRipple && !isDisabled, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n });\n const styleProps = mergeStatefulStyles((state: ButtonState) => stylex.props(styles.base, styles[variant], styles[size], state.isDisabled && styles.disabled, state.isDisabled && disabledStyles[variant]), props);\n const element = {\n aria: ariaAttributesOf(props),\n onKeyDown,\n onKeyUp\n };\n if (href !== undefined) {\n return <RACLink href={href} isDisabled={isDisabled} rel={rel} render={linkRenderer(element)} target={target} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACLink>;\n }\n return <RACButton isDisabled={isDisabled} render={buttonRenderer(element, render)} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACButton>;\n}\nexport type { IconButtonProps };\nexport default IconButton;"],"mappings":";;;;;;;AAkCA,MAAM,SAAS;CACb,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,QAAQ;EACN,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,gBAAgB;EACd,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,IAAI;EACF,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,IAAI;EACF,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,kBAAkB;EAChB,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,eAAe;EACb,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,IAAI;EACF,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,IAAI;EACF,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,KAAK;EACH,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF;AACA,MAAM,iBAAiB;CACrB,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,OAAO,OAAO;AAChB;;;;;;AAmDA,SAAS,WAAW,EAClB,UACA,gBAAgB,OAChB,MACA,aAAa,OACb,SACA,eACA,WACA,SACA,iBACA,eACA,gBACA,aACA,KACA,QACA,OAAO,MACP,QACA,UAAU,YACV,GAAG,WACe;CAMlB,MAAM,SAAS,UAA4B,CAAC,iBAAiB,CAAC,YAAY;EACxE;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,aAAa,qBAAqB,UAAuB,MAAa,OAAO,MAAM,OAAO,UAAU,OAAO,OAAO,MAAM,cAAc,OAAO,UAAU,MAAM,cAAc,eAAe,QAAQ,GAAG,OAAK;CAChN,MAAM,UAAU;EACd,MAAM,iBAAiB,OAAK;EAC5B;EACA;CACF;CACA,IAAI,SAAS,KAAA,GACX,OAAO,qBAAC,MAAD;EAAe;EAAkB;EAAiB;EAAK,QAAQ,aAAa,OAAO;EAAW;EAAQ,GAAI,OAAO;EAAU,GAAI;EAAO,GAAI;EAA1I,UAAA,CACF,UACA,OAAO,OACD;;CAEb,OAAO,qBAAC,QAAD;EAAuB;EAAY,QAAQ,eAAe,SAAS,MAAM;EAAG,GAAI,OAAO;EAAU,GAAI;EAAO,GAAI;EAAhH,UAAA,CACF,UACA,OAAO,OACC;;AACf"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/icon-button/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ClassNameOrFunction, FocusableElement, StyleOrFunction } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ButtonContext, Button as RACButton, Link as RACLink, useSlottedContext } from 'react-aria-components';\nimport type { ButtonDOMProps, ButtonState } from '../button';\nimport { useRipple } from '../../hooks/useRipple';\nimport { ariaAttributesOf, buttonRenderer, linkRenderer } from '../../render/aria';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// Each variant composites an 'on-color' over its own container at the\n// interaction state's opacity, rather than swapping in a separate hover\n// color. The pairs are the icon buttons spec page's: filled on primary,\n// tonal on secondary container, standard on surface variant over nothing. calc(<opacity> * 100%) turns the token's unitless 0-1 ratio into the\n// percentage color-mix() takes. Inlined at each property rather than factored\n// into a helper: @stylexjs/babel-plugin only statically recognizes\n// expressions written directly as property values.\n//\n// Disabled is a style of its own per variant rather than a `:disabled`\n// branch inside each property, for the reason Button's comment gives: given\n// `href` this renders as a link, which React Aria turns into a <span> while\n// disabled, and neither matches the pseudo-class. Applied last from the\n// render state, the disabled styles replace each property whole, hover and\n// pressed branches included.\n//\n// The corner softens from a circle to a rounded square while pressed, which\n// is the shape morph the icon buttons spec page gives this control, at the\n// pressed corner its size token set names: 8 for the two small sizes, 12 at\n// medium, 16 at the two large. Each size carries its own pressed radius, since\n// StyleX replaces the property whole. The two transitioned properties take\n// different curves — the colour change is linear-ish and the shape change is\n// emphasized — so the timing functions are a matching comma list rather than\n// one value.\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x3y1ksm\",\n kMzoRj: \"xc342km\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n kmuXW: \"x2lah0s\",\n kjj79g: \"xl56j7k\",\n kjBf7l: \"xrgy624\",\n kInvED: \"x1hl8ikr\",\n k3XXqK: \"x9v5kkp x1t137rt\",\n kMeerF: \"x1de99jn\",\n kmVPX3: \"x1717udv\",\n kVAEAm: \"x1n2onr6\",\n kybGjl: \"x1hl2dhg\",\n kIyJzY: \"x1iuyhda\",\n k1ekBW: \"xb5u718\",\n kAMwcw: \"x15l9jch\",\n $$css: true\n },\n disabled: {\n kaIpWk: \"x3y1ksm\",\n kkrTdU: \"x1h6gzvc\",\n $$css: true\n },\n filled: {\n kWkggS: \"xpky1to xyf7a0q xnety89\",\n kMwMTN: \"xwjo7ld\",\n $$css: true\n },\n filledDisabled: {\n kWkggS: \"xepofeg\",\n kMwMTN: \"x1xj74d8\",\n $$css: true\n },\n lg: {\n kZKoxP: \"xnnlda6\",\n kaIpWk: \"xtt5grq x3y1ksm\",\n kGuDYH: \"x1pvqxga\",\n kzqmXN: \"x15yg21f\",\n $$css: true\n },\n md: {\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x1r81nxe x3y1ksm\",\n kGuDYH: \"x1pvqxga\",\n kzqmXN: \"x100vrsf\",\n $$css: true\n },\n standard: {\n kWkggS: \"x83qkoq x1p2om7n xjbqb8w\",\n kMwMTN: \"x1w5n3ug\",\n $$css: true\n },\n standardDisabled: {\n kWkggS: \"xjbqb8w\",\n kMwMTN: \"x1xj74d8\",\n $$css: true\n },\n tonal: {\n kWkggS: \"xnqsvhv xlizrex x15dekr4\",\n kMwMTN: \"x1sawysd\",\n $$css: true\n },\n tonalDisabled: {\n kWkggS: \"xepofeg\",\n kMwMTN: \"x1xj74d8\",\n $$css: true\n },\n xl: {\n kZKoxP: \"xjp8j0k\",\n kaIpWk: \"x11f6t2b x3y1ksm\",\n kGuDYH: \"x1s3cmhv\",\n kzqmXN: \"x13oubkp\",\n $$css: true\n },\n xs: {\n kZKoxP: \"x10w6t97\",\n kaIpWk: \"x1r81nxe x3y1ksm\",\n kGuDYH: \"xwsyq91\",\n kzqmXN: \"x1td3qas\",\n $$css: true\n },\n xxl: {\n kZKoxP: \"xn866dk\",\n kaIpWk: \"x11f6t2b x3y1ksm\",\n kGuDYH: \"x1tgwohi\",\n kzqmXN: \"x1f2tiqu\",\n $$css: true\n }\n};\nconst disabledStyles = {\n filled: styles.filledDisabled,\n standard: styles.standardDisabled,\n tonal: styles.tonalDisabled\n};\ntype IconButtonProps = {\n /**\n * What the button does, in words. Required rather than optional: an icon\n * on its own has no accessible name, so without this the control announces\n * nothing at all.\n */\n 'aria-label': string;\n children?: ReactNode;\n /** A function may compute the class from the button's render state. */\n className?: ClassNameOrFunction<ButtonState>;\n /**\n * Disables the press ripple. The hover and pressed state layers are\n * unaffected.\n * @default false\n */\n disableRipple?: boolean;\n /**\n * Where the button leads. Given one, the button is rendered as a link —\n * an `<a>`, announced as the link it is — with the same styles and ripple.\n * `render`, `type`, and the form and pending props apply to the button\n * form only.\n */\n href?: string;\n /** The link's `rel`, when `href` is set. */\n rel?: string;\n /**\n * Control size: `xs` 32px, `md` 40px, `lg` 56px, `xl` 96px, `xxl` 136px —\n * the icon buttons spec page's XS to XL, and the same heights `Button`\n * uses, so the two line up beside each other in a row. The icon is 20px,\n * 24px, 24px, 32px and 40px in turn.\n * @default 'md'\n */\n size?: 'lg' | 'md' | 'xl' | 'xs' | 'xxl';\n /** A function may compute the style from the button's render state. */\n style?: StyleOrFunction<ButtonState>;\n /** The link's `target`, when `href` is set. */\n target?: string;\n /**\n * `standard` is transparent and tints what it sits on; `filled` and `tonal`\n * carry a container of their own.\n * @default 'standard'\n */\n variant?: 'filled' | 'standard' | 'tonal';\n} & ButtonDOMProps;\n\n/**\n * A button that is an icon, at five control heights. Given `href` it is a\n * link with the same appearance. Every `aria-*` prop is forwarded to the\n * element; React Aria alone would keep only the labelling ones.\n */\nfunction IconButton({\n children,\n disableRipple = false,\n href,\n isDisabled,\n onClick,\n onContextMenu,\n onKeyDown,\n onKeyUp,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n rel,\n render,\n size = 'md',\n target,\n variant = 'standard',\n ...props\n}: IconButtonProps) {\n // A field's context may disable the button — a number field's stepper at\n // the end of its range, a search field's clear button with the field — and\n // React Aria takes a prop over its context, so a default of `false` here\n // would keep every one of them enabled. The call site's own prop still\n // wins where it is given; the context is read for the ripple, which has\n // to know before the render state does.\n const context = useSlottedContext(ButtonContext, props.slot);\n const disabled = isDisabled ?? context?.isDisabled ?? false;\n\n // `props` (className/style, etc.) is spread separately: `className` and\n // `style` there may be functions of render state, which ripple's own\n // handler-only merge doesn't need to know about. It is also why the styles\n // below merge through mergeStatefulStyles rather than the plain\n // mergeStyles. The ripple is off while disabled, as in Button.\n const ripple = useRipple<FocusableElement>(!disableRipple && !disabled, {\n onClick,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n });\n const styleProps = mergeStatefulStyles((state: ButtonState) => stylex.props(styles.base, styles[variant], styles[size], state.isDisabled && styles.disabled, state.isDisabled && disabledStyles[variant]), props);\n const element = {\n aria: ariaAttributesOf(props),\n onKeyDown,\n onKeyUp\n };\n if (href !== undefined) {\n return <RACLink href={href} isDisabled={disabled} rel={rel} render={linkRenderer(element)} target={target} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACLink>;\n }\n return <RACButton isDisabled={disabled} render={buttonRenderer(element, render)} {...ripple.handlers} {...props} {...styleProps}>\n {children}\n {ripple.surface}\n </RACButton>;\n}\nexport type { IconButtonProps };\nexport default IconButton;"],"mappings":";;;;;;;AAkCA,MAAM,SAAS;CACb,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,QAAQ;EACN,QAAQ;EACR,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AiB,OAAK;EAC5B;EACA;CACF;CACA,IAAI,SAAS,KAAA,GACX,OAAO,qBAAC,MAAD;EAAe;EAAM,YAAY;EAAe;EAAK,QAAQ,aAAa,OAAO;EAAW;EAAQ,GAAI,OAAO;EAAU,GAAI;EAAO,GAAI;EAAxI,UAAA,CACF,UACA,OAAO,OACD;;CAEb,OAAO,qBAAC,QAAD;EAAW,YAAY;EAAU,QAAQ,eAAe,SAAS,MAAM;EAAG,GAAI,OAAO;EAAU,GAAI;EAAO,GAAI;EAA9G,UAAA,CACF,UACA,OAAO,OACC;;AACf"}
|
|
@@ -10,14 +10,17 @@ import Container, { ContainerProps } from "./container/index.js";
|
|
|
10
10
|
import CopyField, { CopyFieldProps } from "./copy-field/index.js";
|
|
11
11
|
import Currency, { CurrencyProps } from "./currency/index.js";
|
|
12
12
|
import Feed, { FeedProps } from "./feed/index.js";
|
|
13
|
+
import Form, { FormProps } from "./form/index.js";
|
|
13
14
|
import IconButton, { IconButtonProps } from "./icon-button/index.js";
|
|
14
15
|
import Keycap, { KeycapProps } from "./keycap/index.js";
|
|
15
16
|
import Link, { LinkProps } from "./link/index.js";
|
|
16
17
|
import ListDetail, { ListDetailProps } from "./list-detail/index.js";
|
|
17
18
|
import ListItem, { ListItemProps } from "./list-item/index.js";
|
|
19
|
+
import NumberField, { NumberFieldProps } from "./number-field/index.js";
|
|
18
20
|
import Popover, { PopoverProps } from "./popover/index.js";
|
|
19
21
|
import ProductIcon, { ProductIconProps } from "./product-icon/index.js";
|
|
20
22
|
import RadioGroup, { Radio, RadioGroupProps, RadioProps } from "./radio-group/index.js";
|
|
23
|
+
import SearchField, { SearchFieldProps } from "./search-field/index.js";
|
|
21
24
|
import Separator, { SeparatorProps } from "./separator/index.js";
|
|
22
25
|
import Sheet, { SheetProps } from "./sheet/index.js";
|
|
23
26
|
import Slider, { SliderProps } from "./slider/index.js";
|
|
@@ -27,5 +30,6 @@ import Switch, { SwitchProps } from "./switch/index.js";
|
|
|
27
30
|
import Tabs, { TabsProps } from "./tabs/index.js";
|
|
28
31
|
import Tag, { TagProps } from "./tag/index.js";
|
|
29
32
|
import Text, { TextProps } from "./text/index.js";
|
|
33
|
+
import TextArea, { TextAreaProps } from "./text-area/index.js";
|
|
30
34
|
import TextField, { TextFieldProps } from "./text-field/index.js";
|
|
31
|
-
export { AppBar, type AppBarProps, Avatar, type AvatarProps, Button, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, Chip, type ChipProps, Code, type CodeProps, Container, type ContainerProps, CopyField, type CopyFieldProps, Currency, type CurrencyProps, Feed, type FeedProps, IconButton, type IconButtonProps, Keycap, type KeycapProps, Link, type LinkProps, ListDetail, type ListDetailProps, ListItem, type ListItemProps, Popover, type PopoverProps, ProductIcon, type ProductIconProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, Separator, type SeparatorProps, Sheet, type SheetProps, Slider, type SliderProps, Stack, type StackAlign, type StackGap, type StackJustify, type StackProps, SupportingPane, type SupportingPaneProps, Switch, type SwitchProps, Tabs, type TabsProps, Tag, type TagProps, Text, TextField, type TextFieldProps, type TextProps };
|
|
35
|
+
export { AppBar, type AppBarProps, Avatar, type AvatarProps, Button, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, Chip, type ChipProps, Code, type CodeProps, Container, type ContainerProps, CopyField, type CopyFieldProps, Currency, type CurrencyProps, Feed, type FeedProps, Form, type FormProps, IconButton, type IconButtonProps, Keycap, type KeycapProps, Link, type LinkProps, ListDetail, type ListDetailProps, ListItem, type ListItemProps, NumberField, type NumberFieldProps, Popover, type PopoverProps, ProductIcon, type ProductIconProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, SearchField, type SearchFieldProps, Separator, type SeparatorProps, Sheet, type SheetProps, Slider, type SliderProps, Stack, type StackAlign, type StackGap, type StackJustify, type StackProps, SupportingPane, type SupportingPaneProps, Switch, type SwitchProps, Tabs, type TabsProps, Tag, type TagProps, Text, TextArea, type TextAreaProps, TextField, type TextFieldProps, type TextProps };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { FieldVariant } from "../../field/index.js";
|
|
2
|
+
import { NumberFieldProps } from "react-aria-components";
|
|
3
|
+
//#region src/components/number-field/index.d.ts
|
|
4
|
+
type NumberFieldProps$1 = {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the stepper that lowers the value, for a screen reader.
|
|
7
|
+
* @default 'Decrease'
|
|
8
|
+
*/
|
|
9
|
+
decrementLabel?: string;
|
|
10
|
+
/**
|
|
11
|
+
* A hint shown under the field. Replaced by `error` when there is one, so
|
|
12
|
+
* the two never stack.
|
|
13
|
+
*/
|
|
14
|
+
description?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The problem with the current value, in words. Its presence is what puts
|
|
17
|
+
* the field in its error state — the message, the red underline, and
|
|
18
|
+
* `aria-invalid` all follow from it.
|
|
19
|
+
*/
|
|
20
|
+
error?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the label sits in the empty box and floats to the top once the
|
|
23
|
+
* field is focused or holds a value, as the text fields page draws it.
|
|
24
|
+
* `false` keeps it small at the top in every state.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
floatingLabel?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The name of the stepper that raises the value, for a screen reader.
|
|
30
|
+
* @default 'Increase'
|
|
31
|
+
*/
|
|
32
|
+
incrementLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* What the field is for. Required rather than optional: a field with no
|
|
35
|
+
* label is a box a screen reader cannot name.
|
|
36
|
+
*/
|
|
37
|
+
label: string;
|
|
38
|
+
/**
|
|
39
|
+
* Renders the value in the mono face with tabular figures, for amounts and
|
|
40
|
+
* other numbers meant to be compared down a column. On by default, since a
|
|
41
|
+
* number field holds nothing else.
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
numeric?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* How the two steppers sit at the end of the box: stacked, the plus over
|
|
47
|
+
* the minus, flush with the box's edge, or side by side as extra-small
|
|
48
|
+
* icon buttons.
|
|
49
|
+
* @default 'vertical'
|
|
50
|
+
*/
|
|
51
|
+
steppers?: 'horizontal' | 'vertical';
|
|
52
|
+
/**
|
|
53
|
+
* The filled box, or the outlined one: no fill, an outline that thickens
|
|
54
|
+
* and takes the primary role while focused, and the label cutting it once
|
|
55
|
+
* it floats — the text fields page's two fields.
|
|
56
|
+
* @default 'filled'
|
|
57
|
+
*/
|
|
58
|
+
variant?: FieldVariant;
|
|
59
|
+
} & Omit<NumberFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;
|
|
60
|
+
/**
|
|
61
|
+
* A labelled number input with steppers. Its value is React Aria's: pass
|
|
62
|
+
* `value` with `onChange` to control it, or `defaultValue` to let it keep
|
|
63
|
+
* its own — and `onChange` is handed the number, `NaN` while the field is
|
|
64
|
+
* empty. `minValue`, `maxValue` and `step` shape it, and `formatOptions`
|
|
65
|
+
* says how it reads, in the locale the page is in: a currency, a percentage,
|
|
66
|
+
* a unit. Arrow keys step the value, and Page Up and Page Down by ten steps.
|
|
67
|
+
*
|
|
68
|
+
* The call site's `className` and `style` land on the field as a whole,
|
|
69
|
+
* which is the element a layout positions. The box, label, input and message
|
|
70
|
+
* are the field chrome in `src/field`, shared with every other field.
|
|
71
|
+
*/
|
|
72
|
+
declare function NumberField$1({ decrementLabel, description, error, floatingLabel, incrementLabel, isDisabled, label, numeric, steppers, variant, ...props }: NumberFieldProps$1): import("react").JSX.Element;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { type NumberFieldProps$1 as NumberFieldProps, NumberField$1 as default };
|
|
75
|
+
//# sourceMappingURL=index.d.ts.map
|