@kanso-labs/kanso-ui 0.40.9 → 0.41.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/color-scheme.d.ts +6 -0
- package/dist/color-scheme.js +9 -2
- package/dist/color-scheme.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +11 -2
- package/dist/components/app-bar/index.js +53 -46
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/card/index.d.ts +12 -1
- package/dist/components/card/index.js +136 -66
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/dialog/index.js +3 -2
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/popover/index.js +3 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +3 -0
- package/dist/components/segmented-button/index.js +131 -65
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/separator/index.js +2 -2
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.js +17 -16
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +10 -3
- package/dist/components/snackbar/index.js +32 -12
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/switch/index.js +12 -3
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +3 -2
- package/dist/components/toolbar/index.js +3 -2
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/field/index.js +75 -48
- package/dist/field/index.js.map +1 -1
- package/dist/overlay/index.js +24 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/styles/scheme.js +19 -0
- package/dist/styles/scheme.js.map +1 -0
- package/dist/styles.css +86 -26
- package/dist/theme-scope.d.ts +5 -2
- package/dist/theme-scope.js +2 -1
- package/dist/theme-scope.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","MouseEvent","ReactMouseEvent","ReactNode","PointerEvent","ReactPointerEvent","RefAttributes","SwitchFieldProps","RACSwitchFieldProps","SwitchButtonRenderProps","stylex","useCallback","useRef","useState","SwitchButton","SwitchField","AccessibleName","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","radii","stateLayerOpacity","FORCED_COLORS","_temp","kLqNvP","styles","control","kgeoSG","kGOzcv","kpsdNU","kEoFBp","kGNEyG","kZKoxP","kB7OPa","kkrTdU","k1xSpc","kmuXW","kzqmXN","kjj79g","kVAEAm","$$css","handle","k6CgDc","kWkggS","kaIpWk","kMwMTN","kIyJzY","k1ekBW","kAMwcw","handleActive","handleDisabled","handleOn","handleOnActive","handleOnDisabled","handlePressed","layer","kpwlN0","seat","k87sOh","seatAt","offset","val","undefined","seatDraggable","kFalU9","seatDragging","seatOn","track","kVAM5u","ksu8eU","kMzoRj","trackDisabled","trackOn","trackOnDisabled","hoverLayers","off","on","focusLayers","pressedLayers","TRAVEL","DRAG_SLOP","Drag","ReturnType","useHandleDrag","Ripple","HTMLSpanElement","SwitchProps","children","description","error","icon","Omit","buttonContent","ripple","drag","state","interactive","isDisabled","isReadOnly","isSelected","dragging","active","isHovered","isPressed","isFocusVisible","props","controlReadOnly","controlDisabled","ringVisible","handlers","surface","Switch","t0","$","t1","validationBehavior","T0","t2","t3","field","t4","t5","t6","Symbol","for","messages","t7","t8","setOffset","origin","settled","cancelClick","current","onPointerCancel","event","preventDefault","stopPropagation","onClickCapture","event_0","from","along","rtl","x","clientX","Math","abs","next","min","max","base","onPointerMove","event_1","from_0","stopped","currentTarget","dispatchEvent","bubbles","pointerId","pointerType","input","closest","querySelector","click","onPointerUp","onPointerDown","event_2","button","getComputedStyle","direction","setPointerCapture","stylex.props","_c","props"],"sources":["../../../src/components/switch/index.tsx"],"sourcesContent":["'use client';\n\n// React's event types are aliased because `useHandleDrag` also constructs a\n// DOM `PointerEvent`. Imported unaliased, the name shadows that constructor:\n// TypeScript still resolves the call to the global, since a type-only import\n// takes no value name, but a reader and a static analyser alike read it as\n// React's type, which has no runtime value behind it at all.\nimport type { MouseEvent as ReactMouseEvent, ReactNode, PointerEvent as ReactPointerEvent, RefAttributes } from 'react';\nimport type { SwitchFieldProps as RACSwitchFieldProps, SwitchButtonRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useRef, useState } from 'react';\nimport { SwitchButton, SwitchField } from 'react-aria-components';\nimport type { AccessibleName } from '../../render/name';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The switch page: a 52 by 32dp track with a 2dp outline and a full corner,\n// a handle that is 16dp off, 24dp on and 28dp while pressed, a 16dp icon in\n// the handle when asked for, a 40dp state layer around the handle and a 48dp\n// target. Off, the track is surface container highest inside an outline\n// rule and the handle is outline, turning on surface variant while hovered,\n// pressed or focused; on, the track is primary and the handle on primary,\n// turning primary container in the same states, with the icon in on primary\n// container. Disabled, the track and its rule are on surface at the\n// disabled container opacity and the handle on surface at the disabled\n// content opacity, or surface when on. The state layer is on surface off and\n// primary on.\n//\n// React Aria's `SwitchField` is the root, a div holding the description and\n// error slots; its `SwitchButton` is the label around a visually hidden\n// input, and everything drawn is that label's children, chosen from the\n// render state React Aria hands them. The field is the two-column grid the\n// checkbox uses, with the label `display: contents`, so the description and\n// error line up under the text.\n//\n// The handle travels between the two ends of the track and grows between\n// its three sizes on the same transition, `motion.durationShort2` with the\n// standard easing; the state layer and the ripple sit on a 40dp disc centred\n// on the handle, so they move with it. The adjacent label is body-large on\n// surface, which the page keeps the same whichever way the switch is.\n//\n// The page's pressed handle follows the pointer: it grows, travels with the\n// drag, and the switch flips when it is released past the middle of the\n// track or springs back when it is not. React Aria's `SwitchButton` has no\n// drag of its own, so the travel is this component's — see `useHandleDrag`.\n//\n// Under forced colours the switch names system colours for its fills. That\n// mode paints an author's fill in the page's own `Canvas`, so the handle\n// vanished and on and off drew the same empty pill; a system colour is kept\n// rather than repainted. Off is a `ButtonText` handle in an empty track with\n// a `ButtonText` rule. On is a `HighlightText` handle in a track filled with\n// `Highlight`, the pair the mode gives whatever is chosen, with the check in\n// `Highlight` over the handle. Disabled, the same shapes are `GrayText`, and\n// the handle of a switch that is on is emptied to `Canvas` so it still shows\n// against its track. Every style that sets a fill repeats its branch, since\n// one written without the query replaces the property whole, branch and all.\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 _temp = {\n kLqNvP: \"x1lxsm33\",\n \"$$css\": true\n};\nconst styles = {\n control: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"x1fb0czk\",\n kpsdNU: \"xm4btww\",\n kEoFBp: \"x1hmns74\",\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"x1vqgdyp\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvni27\",\n kjj79g: \"xl56j7k\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n handle: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xp2scj5 x1tt9vl1\",\n kZKoxP: \"xlup9mm\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xscdzaa x6jt684\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"x1kky2od\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x7okvu4\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n handleActive: {\n kWkggS: \"x1ccu2yh x1tt9vl1\",\n $$css: true\n },\n handleDisabled: {\n kWkggS: \"x1crcgwy x1o55y2u\",\n $$css: true\n },\n handleOn: {\n kWkggS: \"x1ntwmx2 x1sir5s4\",\n kZKoxP: \"xxk0z11\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n handleOnActive: {\n kWkggS: \"xp89om9 x1sir5s4\",\n $$css: true\n },\n handleOnDisabled: {\n kWkggS: \"x14s9m32 x9yvj25\",\n kMwMTN: \"x1gpw424 x1bhcspo\",\n $$css: true\n },\n handlePressed: {\n kZKoxP: \"x1fgtraw\",\n kzqmXN: \"xgd8bvy\",\n $$css: true\n },\n layer: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kzqmXN: \"x100vrsf\",\n kpwlN0: \"x1qx2jxi\",\n kVAEAm: \"x10l6tqk\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x15406qy\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n seat: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"x1fgtraw\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"xgd8bvy\",\n k87sOh: \"x13vifvy\",\n kLqNvP: \"x1o0tod\",\n kjj79g: \"xl56j7k\",\n kVAEAm: \"x10l6tqk\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x2hifos\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n seatAt: (offset: number) => [_temp, {\n \"--x-insetInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(`${offset}px`)\n }],\n seatDraggable: {\n kFalU9: \"x5ve5x3\",\n $$css: true\n },\n seatDragging: {\n kIyJzY: \"x1mq3mr6\",\n $$css: true\n },\n seatOn: {\n kLqNvP: \"x1n8ud3w\",\n $$css: true\n },\n track: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"x1rrhr5q x9yvj25\",\n kZKoxP: \"x10w6t97\",\n kVAM5u: \"x1fwvt7v x1ylmb6m\",\n kaIpWk: \"x1dkaolv\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvni27\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n trackDisabled: {\n kWkggS: \"x1trd85j x9yvj25\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n $$css: true\n },\n trackOn: {\n kWkggS: \"xnety89 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n $$css: true\n },\n trackOnDisabled: {\n kWkggS: \"x19v6zzp x1o55y2u\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n $$css: true\n }\n};\n\n// The state layer over the handle: on surface while the switch is off and\n// primary while it is on, at the hover or the pressed opacity.\nconst hoverLayers = {\n off: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n on: {\n kWkggS: \"x659ado\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n off: {\n kWkggS: \"xwqhyid\",\n $$css: true\n },\n on: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n }\n};\nconst pressedLayers = {\n off: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n on: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\n\n// How far the seat travels: the track's 48dp inside its 2dp rule, less the\n// seat's own 28dp.\nconst TRAVEL = 20;\n\n// How far a press has to move before it is a drag: a quarter of the travel.\n// A finger, a mouse and a pen all move a pixel or two between pressing and\n// lifting, and a press inside this is still a tap, which flips the switch.\nconst DRAG_SLOP = TRAVEL / 4;\ntype Drag = ReturnType<typeof useHandleDrag>;\ntype Ripple = ReturnType<typeof useRipple<HTMLSpanElement>>;\ntype SwitchProps = {\n /**\n * The label, beside the switch. A switch that a row labels some other way\n * leaves it out and passes `aria-label` or `aria-labelledby` instead — one\n * of the three is required, since a switch with none is announced as an\n * unnamed switch.\n *\n * A link or a button in it acts on its own, as in a native label, and\n * leaves the switch as it was. A press anywhere else in the label toggles\n * it.\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 switch in its error state — the message and `aria-invalid` follow\n * from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * Draws the check in the handle while the switch is on, the page's\n * \"icon on selected switch\" form.\n * @default false\n */\n icon?: boolean;\n} & AccessibleName & Omit<RACSwitchFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\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// state layer while the switch can change, and are left off while it\n// cannot, since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, icon: boolean, ripple: Ripple, drag: Drag) {\n return (state: SwitchButtonRenderProps) => {\n const interactive = !state.isDisabled && !state.isReadOnly;\n const on = state.isSelected;\n const dragging = interactive && drag.offset !== null;\n const active = interactive && (state.isHovered || state.isPressed || state.isFocusVisible);\n return <>\n <span {...stylex.props(styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled)}>\n <span {...stylex.props(styles.track, on && styles.trackOn, state.isDisabled && (on ? styles.trackOnDisabled : styles.trackDisabled), state.isFocusVisible && focus.ringVisible)}>\n <span {...interactive ? drag.handlers(on) : {}} {...stylex.props(styles.seat, on && styles.seatOn, interactive && styles.seatDraggable, dragging && styles.seatDragging, dragging && styles.seatAt(drag.offset ?? 0))}>\n <span {...interactive ? ripple.handlers : {}} {...stylex.props(styles.layer, interactive && state.isHovered && hoverLayers[on ? 'on' : 'off'], interactive && state.isFocusVisible && focusLayers[on ? 'on' : 'off'], interactive && state.isPressed && pressedLayers[on ? 'on' : 'off'])}>\n {interactive ? ripple.surface : null}\n </span>\n <span {...stylex.props(styles.handle, on && styles.handleOn, active && (on ? styles.handleOnActive : styles.handleActive), (dragging || interactive && state.isPressed) && styles.handlePressed, state.isDisabled && (on ? styles.handleOnDisabled : styles.handleDisabled))}>\n {icon && on ? <CheckGlyph className=\"xlup9mm x1lliihq x1kky2od\" /> : null}\n </span>\n </span>\n </span>\n </span>\n <ControlLabel state={state}>{children}</ControlLabel>\n </>;\n };\n}\n\n/**\n * A switch that turns a setting on or off, with its label and optionally a\n * description or an error under it. Its state is React Aria's: pass\n * `isSelected` with `onChange` to control it, or `defaultSelected` to let it\n * keep its own. A switch takes effect as it is flipped, which is what sets\n * it apart from a checkbox in a form.\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 Switch({\n children,\n description,\n error,\n icon = false,\n ...props\n}: RefAttributes<HTMLDivElement> & SwitchProps) {\n const ripple = useRipple<HTMLSpanElement>();\n const drag = useHandleDrag();\n const validationBehavior = useFieldValidationBehavior();\n return <SwitchField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n <SwitchButton className=\"xjp7ctv\">\n {buttonContent(children, icon, ripple, drag)}\n </SwitchButton>\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </SwitchField>;\n}\n\n/**\n * The handle following a pointer across the track, as the switch page draws\n * a pressed switch. The seat's inset comes from the drag while one is under\n * way, and the switch settles from where the handle was let go: on past the\n * middle of the track, off before it.\n *\n * What flips the switch on an ordinary tap is React Aria's own press, which\n * ends on the pointer being released and pays no attention to where the\n * handle was dragged to — so a drag has to end that press before releasing,\n * which is what the pointer cancel is for, and settle the switch itself.\n * Settling means clicking the field's own input, the same element a tap\n * reaches in the end: the change goes through React Aria, and a controlled\n * switch stays controlled, since nothing here calls `onChange` or holds any\n * state of the switch's own. The click the pointer's release sends after\n * that is cancelled too, so nothing flips the switch a second time.\n *\n * A press that moves no further than the slop is left alone entirely, so a\n * tap flips the switch however still the pointer was — a drag starts only\n * once the pointer passes it, and from then on the handle follows every move.\n *\n * The guard for the click after a drag is cleared by the next press, not by\n * that click, since the click may never come: a touch dragged past the\n * browser's own slop sends none, and a guard left armed swallowed the next\n * tap instead.\n */\nfunction useHandleDrag() {\n const [offset, setOffset] = useState<null | number>(null);\n const origin = useRef<null | {\n base: number;\n on: boolean;\n rtl: boolean;\n x: number;\n }>(null);\n const settled = useRef<null | number>(null);\n const cancelClick = useRef(false);\n const onPointerCancel = useCallback(() => {\n origin.current = null;\n settled.current = null;\n setOffset(null);\n }, []);\n const onClickCapture = useCallback((event: ReactMouseEvent<HTMLSpanElement>) => {\n if (!cancelClick.current) {\n return;\n }\n cancelClick.current = false;\n // The label's activation is the browser's own, so this is what stops the\n // input being flipped by a drag that settled where it began.\n event.preventDefault();\n event.stopPropagation();\n }, []);\n const onPointerMove = useCallback((event: ReactPointerEvent<HTMLSpanElement>) => {\n const from = origin.current;\n if (from === null) {\n return;\n }\n const along = from.rtl ? from.x - event.clientX : event.clientX - from.x;\n if (settled.current === null && Math.abs(along) <= DRAG_SLOP) {\n return;\n }\n const next = Math.min(TRAVEL, Math.max(0, from.base + along));\n settled.current = next;\n setOffset(next);\n }, []);\n const onPointerUp = useCallback((event: ReactPointerEvent<HTMLSpanElement>) => {\n const from = origin.current;\n const stopped = settled.current;\n const seat = event.currentTarget;\n origin.current = null;\n settled.current = null;\n setOffset(null);\n // A press that never moved is a tap, which React Aria flips on its own.\n if (from === null || stopped === null) {\n return;\n }\n // React Aria's press is about to flip the switch from wherever it\n // started, so it is cancelled first — a pointer cancel is what ends a\n // press without firing it — and the drag settles the switch instead.\n seat.dispatchEvent(new PointerEvent('pointercancel', {\n bubbles: true,\n pointerId: event.pointerId,\n pointerType: event.pointerType\n }));\n // The pointer's own click follows this, by which time the switch has\n // already settled.\n cancelClick.current = true;\n if (stopped > TRAVEL / 2 === from.on) {\n return;\n }\n const input = seat.closest('label')?.querySelector('input');\n input?.click();\n }, []);\n const handlers = useCallback((on: boolean) => ({\n onClickCapture,\n onPointerCancel,\n onPointerDown: (event: ReactPointerEvent<HTMLSpanElement>) => {\n cancelClick.current = false;\n if (event.pointerType === 'mouse' && event.button !== 0) {\n return;\n }\n origin.current = {\n base: on ? TRAVEL : 0,\n on,\n rtl: getComputedStyle(event.currentTarget).direction === 'rtl',\n x: event.clientX\n };\n settled.current = null;\n try {\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {\n // A pointer the browser is not tracking has no capture to take —\n // a synthetic event in a test, where the moves are dispatched on\n // this element anyway.\n }\n },\n onPointerMove,\n onPointerUp\n }), [onClickCapture, onPointerCancel, onPointerMove, onPointerUp]);\n return {\n handlers,\n offset\n };\n}\nexport type { SwitchProps };\nexport default Switch;"],"mappings":";;;;;;;;;;;;;;;AAsEA,MAAMgC,QAAQ;CACZC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,SAAS;CACbC,SAAS;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,QAAQ;EACNC,QAAQ;EACRX,QAAQ;EACRY,QAAQ;EACRX,QAAQ;EACRY,QAAQ;EACRX,QAAQ;EACRY,QAA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,GAAA;EACsBJ,MAAA5C,QAAkB;GAAA6D;GAAAJ;GAAA+B,gBAG9BC,YAAA;IACblC,YAAWC,UAAW;IACtB,IAAIE,QAAKwB,gBAAiB,WAAWxB,QAAKgC,WAAY,GAAC;IAGvDrC,OAAMG,UAAW;KAAAiB,MACTzE,KAAAG,SAAA;KAAeH;KAAAiE,KAEhB0B,iBAAiBjC,QAAKoB,aAAc,CAAC,CAAAc,cAAe;KAAK1B,GAC3DR,QAAKS;IACV;IACAb,QAAOE,UAAW;IAClB,IAAA;KACEE,QAAKoB,cAAce,kBAAmBnC,QAAKuB,SAAU;IAAC,QAAA,CAAA;GAKvD;GACFP;GAAAa;EAGH;EAAElD,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAzBF,MAAAJ,WAAiBW;CAyBkD,IAAAC;CAAA,IAAAR,EAAA,OAAArD,QAAA;EAC5D6D,KAAA;GAAAZ;GAAAjD;EAGP;EAACqD,EAAA,KAAArD;EAAAqD,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAHMQ;AAGN"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","MouseEvent","ReactMouseEvent","ReactNode","PointerEvent","ReactPointerEvent","RefAttributes","SwitchFieldProps","RACSwitchFieldProps","SwitchButtonRenderProps","stylex","useCallback","useRef","useState","SwitchButton","SwitchField","AccessibleName","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","radii","stateLayerOpacity","FORCED_COLORS","_temp","kLqNvP","styles","control","kgeoSG","kGOzcv","kpsdNU","kEoFBp","kGNEyG","kZKoxP","kB7OPa","kkrTdU","k1xSpc","kmuXW","kzqmXN","kjj79g","kVAEAm","$$css","handle","k6CgDc","kWkggS","kaIpWk","kMwMTN","kIyJzY","k1ekBW","kAMwcw","handleActive","handleDisabled","handleOn","handleOnActive","handleOnDisabled","handlePressed","layer","kpwlN0","seat","k87sOh","seatAt","offset","val","undefined","seatDraggable","kFalU9","seatDragging","seatOn","track","kVAM5u","ksu8eU","kMzoRj","trackDisabled","trackOn","trackOnDisabled","hoverLayers","off","on","focusLayers","pressedLayers","TRAVEL","MOUSE_SLOP","TOUCH_SLOP","Drag","ReturnType","useHandleDrag","Ripple","HTMLSpanElement","SwitchProps","children","description","error","icon","Omit","buttonContent","ripple","drag","state","interactive","isDisabled","isReadOnly","isSelected","dragging","active","isHovered","isPressed","isFocusVisible","props","controlReadOnly","controlDisabled","ringVisible","handlers","surface","Switch","t0","$","t1","validationBehavior","T0","t2","t3","field","t4","t5","t6","Symbol","for","messages","t7","t8","setOffset","origin","settled","cancelClick","current","onPointerCancel","event","preventDefault","stopPropagation","onClickCapture","event_0","from","along","rtl","x","clientX","Math","abs","slop","next","min","max","base","onPointerMove","event_1","from_0","stopped","currentTarget","dispatchEvent","bubbles","pointerId","pointerType","input","closest","querySelector","focuses","preventScroll","click","onPointerUp","onPointerDown","event_2","button","touch","getComputedStyle","direction","setPointerCapture","stylex.props","_c","props"],"sources":["../../../src/components/switch/index.tsx"],"sourcesContent":["'use client';\n\n// React's event types are aliased because `useHandleDrag` also constructs a\n// DOM `PointerEvent`. Imported unaliased, the name shadows that constructor:\n// TypeScript still resolves the call to the global, since a type-only import\n// takes no value name, but a reader and a static analyser alike read it as\n// React's type, which has no runtime value behind it at all.\nimport type { MouseEvent as ReactMouseEvent, ReactNode, PointerEvent as ReactPointerEvent, RefAttributes } from 'react';\nimport type { SwitchFieldProps as RACSwitchFieldProps, SwitchButtonRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useRef, useState } from 'react';\nimport { SwitchButton, SwitchField } from 'react-aria-components';\nimport type { AccessibleName } from '../../render/name';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, radii, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The switch page: a 52 by 32dp track with a 2dp outline and a full corner,\n// a handle that is 16dp off, 24dp on and 28dp while pressed, a 16dp icon in\n// the handle when asked for, a 40dp state layer around the handle and a 48dp\n// target. Off, the track is surface container highest inside an outline\n// rule and the handle is outline, turning on surface variant while hovered,\n// pressed or focused; on, the track is primary and the handle on primary,\n// turning primary container in the same states, with the icon in on primary\n// container. Disabled, the track and its rule are on surface at the\n// disabled container opacity and the handle on surface at the disabled\n// content opacity, or surface when on. The state layer is on surface off and\n// primary on.\n//\n// React Aria's `SwitchField` is the root, a div holding the description and\n// error slots; its `SwitchButton` is the label around a visually hidden\n// input, and everything drawn is that label's children, chosen from the\n// render state React Aria hands them. The field is the two-column grid the\n// checkbox uses, with the label `display: contents`, so the description and\n// error line up under the text.\n//\n// The handle travels between the two ends of the track and grows between\n// its three sizes on the same transition, `motion.durationShort2` with the\n// standard easing; the state layer and the ripple sit on a 40dp disc centred\n// on the handle, so they move with it. The adjacent label is body-large on\n// surface, which the page keeps the same whichever way the switch is.\n//\n// The page's pressed handle follows the pointer: it grows, travels with the\n// drag, and the switch flips when it is released past the middle of the\n// track or springs back when it is not. React Aria's `SwitchButton` has no\n// drag of its own, so the travel is this component's — see `useHandleDrag`.\n//\n// Under forced colours the switch names system colours for its fills. That\n// mode paints an author's fill in the page's own `Canvas`, so the handle\n// vanished and on and off drew the same empty pill; a system colour is kept\n// rather than repainted. Off is a `ButtonText` handle in an empty track with\n// a `ButtonText` rule. On is a `HighlightText` handle in a track filled with\n// `Highlight`, the pair the mode gives whatever is chosen, with the check in\n// `Highlight` over the handle. Disabled, the same shapes are `GrayText`, and\n// the handle of a switch that is on is emptied to `Canvas` so it still shows\n// against its track. Every style that sets a fill repeats its branch, since\n// one written without the query replaces the property whole, branch and all.\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 _temp = {\n kLqNvP: \"x1lxsm33\",\n \"$$css\": true\n};\nconst styles = {\n control: {\n kgeoSG: \"x1cpjm7i\",\n kGOzcv: \"x1fb0czk\",\n kpsdNU: \"xm4btww\",\n kEoFBp: \"x1hmns74\",\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"x1vqgdyp\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x78zum5\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvni27\",\n kjj79g: \"xl56j7k\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n handle: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kWkggS: \"xp2scj5 x1tt9vl1\",\n kZKoxP: \"xlup9mm\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xscdzaa x6jt684\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"x1kky2od\",\n kjj79g: \"xl56j7k\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x7okvu4\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n handleActive: {\n kWkggS: \"x1ccu2yh x1tt9vl1\",\n $$css: true\n },\n handleDisabled: {\n kWkggS: \"x1crcgwy x1o55y2u\",\n $$css: true\n },\n handleOn: {\n kWkggS: \"x1ntwmx2 x1sir5s4\",\n kZKoxP: \"xxk0z11\",\n kzqmXN: \"xvy4d1p\",\n $$css: true\n },\n handleOnActive: {\n kWkggS: \"xp89om9 x1sir5s4\",\n $$css: true\n },\n handleOnDisabled: {\n kWkggS: \"x14s9m32 x9yvj25\",\n kMwMTN: \"x1gpw424 x1bhcspo\",\n $$css: true\n },\n handlePressed: {\n kZKoxP: \"x1fgtraw\",\n kzqmXN: \"xgd8bvy\",\n $$css: true\n },\n layer: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x16fbrrb\",\n kB7OPa: \"x9f619\",\n kzqmXN: \"x100vrsf\",\n kpwlN0: \"x1qx2jxi\",\n kVAEAm: \"x10l6tqk\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x15406qy\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n seat: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\n kZKoxP: \"x1fgtraw\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kzqmXN: \"xgd8bvy\",\n k87sOh: \"x13vifvy\",\n kLqNvP: \"x1o0tod\",\n kjj79g: \"xl56j7k\",\n kVAEAm: \"x10l6tqk\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"x2hifos\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n seatAt: (offset: number) => [_temp, {\n \"--x-insetInlineStart\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(`${offset}px`)\n }],\n seatDraggable: {\n kFalU9: \"x5ve5x3\",\n $$css: true\n },\n seatDragging: {\n kIyJzY: \"x1mq3mr6\",\n $$css: true\n },\n seatOn: {\n kLqNvP: \"x1n8ud3w\",\n $$css: true\n },\n track: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"x1rrhr5q x9yvj25\",\n kZKoxP: \"x10w6t97\",\n kVAM5u: \"x1fwvt7v x1ylmb6m\",\n kaIpWk: \"x1dkaolv\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kmuXW: \"x2lah0s\",\n kzqmXN: \"xvni27\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n trackDisabled: {\n kWkggS: \"x1trd85j x9yvj25\",\n kVAM5u: \"xrh88j3 xmnqt3w\",\n $$css: true\n },\n trackOn: {\n kWkggS: \"xnety89 x1jzqe4\",\n kVAM5u: \"x1uajy3w x1n2ykn\",\n $$css: true\n },\n trackOnDisabled: {\n kWkggS: \"x19v6zzp x1o55y2u\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n $$css: true\n }\n};\n\n// The state layer over the handle: on surface while the switch is off and\n// primary while it is on, at the hover or the pressed opacity.\nconst hoverLayers = {\n off: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n },\n on: {\n kWkggS: \"x659ado\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n off: {\n kWkggS: \"xwqhyid\",\n $$css: true\n },\n on: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n }\n};\nconst pressedLayers = {\n off: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n on: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\n\n// How far the seat travels: the track's 48dp inside its 2dp rule, less the\n// seat's own 28dp.\nconst TRAVEL = 20;\n\n// How far a press has to move before it is a drag, by the pointer making it.\n// Anything moves a little between pressing and lifting, and a press inside\n// this is still a tap, which flips the switch. A mouse moves a pixel or two,\n// so a quarter of the travel is room enough. A finger drifts further on an\n// ordinary tap — 6 to 10px was common — and under that same 5px the tap was\n// read as a drag let go before the middle, which settled where it began and\n// dropped the tap without a sign. A finger and a pen take half the travel,\n// the platforms' own touch slop; a drag past it is past the middle too.\nconst MOUSE_SLOP = TRAVEL / 4;\nconst TOUCH_SLOP = TRAVEL / 2;\ntype Drag = ReturnType<typeof useHandleDrag>;\ntype Ripple = ReturnType<typeof useRipple<HTMLSpanElement>>;\ntype SwitchProps = {\n /**\n * The label, beside the switch. A switch that a row labels some other way\n * leaves it out and passes `aria-label` or `aria-labelledby` instead — one\n * of the three is required, since a switch with none is announced as an\n * unnamed switch.\n *\n * A link or a button in it acts on its own, as in a native label, and\n * leaves the switch as it was. A press anywhere else in the label toggles\n * it.\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 switch in its error state — the message and `aria-invalid` follow\n * from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * Draws the check in the handle while the switch is on, the page's\n * \"icon on selected switch\" form.\n * @default false\n */\n icon?: boolean;\n} & AccessibleName & Omit<RACSwitchFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\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// state layer while the switch can change, and are left off while it\n// cannot, since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, icon: boolean, ripple: Ripple, drag: Drag) {\n return (state: SwitchButtonRenderProps) => {\n const interactive = !state.isDisabled && !state.isReadOnly;\n const on = state.isSelected;\n const dragging = interactive && drag.offset !== null;\n const active = interactive && (state.isHovered || state.isPressed || state.isFocusVisible);\n return <>\n <span {...stylex.props(styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled)}>\n <span {...stylex.props(styles.track, on && styles.trackOn, state.isDisabled && (on ? styles.trackOnDisabled : styles.trackDisabled), state.isFocusVisible && focus.ringVisible)}>\n <span {...interactive ? drag.handlers(on) : {}} {...stylex.props(styles.seat, on && styles.seatOn, interactive && styles.seatDraggable, dragging && styles.seatDragging, dragging && styles.seatAt(drag.offset ?? 0))}>\n <span {...interactive ? ripple.handlers : {}} {...stylex.props(styles.layer, interactive && state.isHovered && hoverLayers[on ? 'on' : 'off'], interactive && state.isFocusVisible && focusLayers[on ? 'on' : 'off'], interactive && state.isPressed && pressedLayers[on ? 'on' : 'off'])}>\n {interactive ? ripple.surface : null}\n </span>\n <span {...stylex.props(styles.handle, on && styles.handleOn, active && (on ? styles.handleOnActive : styles.handleActive), (dragging || interactive && state.isPressed) && styles.handlePressed, state.isDisabled && (on ? styles.handleOnDisabled : styles.handleDisabled))}>\n {icon && on ? <CheckGlyph className=\"xlup9mm x1lliihq x1kky2od\" /> : null}\n </span>\n </span>\n </span>\n </span>\n <ControlLabel state={state}>{children}</ControlLabel>\n </>;\n };\n}\n\n/**\n * A switch that turns a setting on or off, with its label and optionally a\n * description or an error under it. Its state is React Aria's: pass\n * `isSelected` with `onChange` to control it, or `defaultSelected` to let it\n * keep its own. A switch takes effect as it is flipped, which is what sets\n * it apart from a checkbox in a form.\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 Switch({\n children,\n description,\n error,\n icon = false,\n ...props\n}: RefAttributes<HTMLDivElement> & SwitchProps) {\n const ripple = useRipple<HTMLSpanElement>();\n const drag = useHandleDrag();\n const validationBehavior = useFieldValidationBehavior();\n return <SwitchField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n <SwitchButton className=\"xjp7ctv\">\n {buttonContent(children, icon, ripple, drag)}\n </SwitchButton>\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </SwitchField>;\n}\n\n/**\n * The handle following a pointer across the track, as the switch page draws\n * a pressed switch. The seat's inset comes from the drag while one is under\n * way, and the switch settles from where the handle was let go: on past the\n * middle of the track, off before it.\n *\n * What flips the switch on an ordinary tap is React Aria's own press, which\n * ends on the pointer being released and pays no attention to where the\n * handle was dragged to — so a drag has to end that press before releasing,\n * which is what the pointer cancel is for, and settle the switch itself.\n * Settling means clicking the field's own input, the same element a tap\n * reaches in the end: the change goes through React Aria, and a controlled\n * switch stays controlled, since nothing here calls `onChange` or holds any\n * state of the switch's own. The click the pointer's release sends after\n * that is cancelled too, so nothing flips the switch a second time.\n *\n * A press that moves no further than the slop is left alone entirely, so a\n * tap flips the switch however still the pointer was — a drag starts only\n * once the pointer passes it, and from then on the handle follows every move.\n * The slop is the pointer's own: a finger and a pen drift further on a tap\n * than a mouse does. A mouse or pen drag then focuses the input, as a tap\n * does.\n *\n * The guard for the click after a drag is cleared by the next press, not by\n * that click, since the click may never come: a touch dragged past the\n * browser's own slop sends none, and a guard left armed swallowed the next\n * tap instead.\n */\nfunction useHandleDrag() {\n const [offset, setOffset] = useState<null | number>(null);\n const origin = useRef<null | {\n base: number;\n focuses: boolean;\n on: boolean;\n rtl: boolean;\n slop: number;\n x: number;\n }>(null);\n const settled = useRef<null | number>(null);\n const cancelClick = useRef(false);\n const onPointerCancel = useCallback(() => {\n origin.current = null;\n settled.current = null;\n setOffset(null);\n }, []);\n const onClickCapture = useCallback((event: ReactMouseEvent<HTMLSpanElement>) => {\n if (!cancelClick.current) {\n return;\n }\n cancelClick.current = false;\n // The label's activation is the browser's own, so this is what stops the\n // input being flipped by a drag that settled where it began.\n event.preventDefault();\n event.stopPropagation();\n }, []);\n const onPointerMove = useCallback((event: ReactPointerEvent<HTMLSpanElement>) => {\n const from = origin.current;\n if (from === null) {\n return;\n }\n const along = from.rtl ? from.x - event.clientX : event.clientX - from.x;\n if (settled.current === null && Math.abs(along) <= from.slop) {\n return;\n }\n const next = Math.min(TRAVEL, Math.max(0, from.base + along));\n settled.current = next;\n setOffset(next);\n }, []);\n const onPointerUp = useCallback((event: ReactPointerEvent<HTMLSpanElement>) => {\n const from = origin.current;\n const stopped = settled.current;\n const seat = event.currentTarget;\n origin.current = null;\n settled.current = null;\n setOffset(null);\n // A press that never moved is a tap, which React Aria flips on its own.\n if (from === null || stopped === null) {\n return;\n }\n // React Aria's press is about to flip the switch from wherever it\n // started, so it is cancelled first — a pointer cancel is what ends a\n // press without firing it — and the drag settles the switch instead.\n seat.dispatchEvent(new PointerEvent('pointercancel', {\n bubbles: true,\n pointerId: event.pointerId,\n pointerType: event.pointerType\n }));\n // The pointer's own click follows this, by which time the switch has\n // already settled.\n cancelClick.current = true;\n const input = seat.closest('label')?.querySelector('input');\n // Where a tap leaves focus, a drag leaves it too, whichever side it\n // settles on. A tap reaches the input through the label, which focuses\n // it; the click below is programmatic and moves nothing, and React\n // Aria's press, which would, was cancelled above — so a mouse drag left\n // focus on the page, and a Space after it did nothing. A touch is left\n // alone, as a touch tap leaves no ring to find.\n if (from.focuses) {\n input?.focus({\n preventScroll: true\n });\n }\n if (stopped > TRAVEL / 2 === from.on) {\n return;\n }\n input?.click();\n }, []);\n const handlers = useCallback((on: boolean) => ({\n onClickCapture,\n onPointerCancel,\n onPointerDown: (event: ReactPointerEvent<HTMLSpanElement>) => {\n cancelClick.current = false;\n if (event.pointerType === 'mouse' && event.button !== 0) {\n return;\n }\n const touch = event.pointerType === 'touch';\n origin.current = {\n base: on ? TRAVEL : 0,\n focuses: !touch,\n on,\n rtl: getComputedStyle(event.currentTarget).direction === 'rtl',\n slop: touch || event.pointerType === 'pen' ? TOUCH_SLOP : MOUSE_SLOP,\n x: event.clientX\n };\n settled.current = null;\n try {\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {\n // A pointer the browser is not tracking has no capture to take —\n // a synthetic event in a test, where the moves are dispatched on\n // this element anyway.\n }\n },\n onPointerMove,\n onPointerUp\n }), [onClickCapture, onPointerCancel, onPointerMove, onPointerUp]);\n return {\n handlers,\n offset\n };\n}\nexport type { SwitchProps };\nexport default Switch;"],"mappings":";;;;;;;;;;;;;;;AAsEA,MAAMgC,QAAQ;CACZC,QAAQ;CACR,SAAS;AACX;AACA,MAAMC,SAAS;CACbC,SAAS;EACPC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,QAA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IwB,SACNH,OAAKjJ,MAAQ,EAAAqJ,eACI,KACjB,CAAC;GAEH,IAAIV,UAAU5E,SAAS,MAAM6D,OAAIhE,IAAG;GAGpCqF,OAAKK,MAAQ;EAAC;EACfpD,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAtCD,MAAAqD,cAAoBhD;CAsCb,IAAAE;CAAA,IAAAP,EAAA,OAAAU,OAAAC,IAAA,2BAAA,GAAA;EACsBJ,MAAA7C,QAAkB;GAAA8D;GAAAJ;GAAAkC,gBAG9BC,YAAA;IACbrC,YAAWC,UAAW;IACtB,IAAIE,QAAKyB,gBAAiB,WAAWzB,QAAKmC,WAAY,GAAC;IAGvD,MAAAC,QAAcpC,QAAKyB,gBAAiB;IACpC9B,OAAMG,UAAW;KAAAkB,MACT3E,KAAAG,SAAA;KAAeqF,SACZ,CAACO;KAAK/F;KAAAkE,KAEV8B,iBAAiBrC,QAAKqB,aAAc,CAAC,CAAAiB,cAAe;KAAK1B,MACxDwB,SAASpC,QAAKyB,gBAAiB,QAA/B/E,aAAAD;KAA8D+D,GACjER,QAAKS;IACV;IACAb,QAAOE,UAAW;IAClB,IAAA;KACEE,QAAKqB,cAAckB,kBAAmBvC,QAAKwB,SAAU;IAAC,QAAA,CAAA;GAKvD;GACFP;GAAAe;EAGH;EAAErD,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CA5BF,MAAAJ,WAAiBW;CA4BkD,IAAAC;CAAA,IAAAR,EAAA,OAAAtD,QAAA;EAC5D8D,KAAA;GAAAZ;GAAAlD;EAGP;EAACsD,EAAA,KAAAtD;EAAAsD,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAHMQ;AAGN"}
|
|
@@ -40,8 +40,9 @@ type ToolbarTone = 'neutral' | 'vibrant';
|
|
|
40
40
|
* you, and a toolbar with no name is a group a screen reader cannot announce.
|
|
41
41
|
*
|
|
42
42
|
* `orientation` is React Aria's, and it decides both which arrows move and
|
|
43
|
-
* which way the bar runs. A `Separator`
|
|
44
|
-
* without being told
|
|
43
|
+
* which way the bar runs. A `Separator` among its controls draws across that
|
|
44
|
+
* direction without being told; one inside an overlay opened from the bar
|
|
45
|
+
* draws as it would anywhere else.
|
|
45
46
|
*
|
|
46
47
|
* The call site's `className` and `style` land on the container, which is
|
|
47
48
|
* the element a layout positions.
|
|
@@ -64,8 +64,9 @@ const styles = {
|
|
|
64
64
|
* you, and a toolbar with no name is a group a screen reader cannot announce.
|
|
65
65
|
*
|
|
66
66
|
* `orientation` is React Aria's, and it decides both which arrows move and
|
|
67
|
-
* which way the bar runs. A `Separator`
|
|
68
|
-
* without being told
|
|
67
|
+
* which way the bar runs. A `Separator` among its controls draws across that
|
|
68
|
+
* direction without being told; one inside an overlay opened from the bar
|
|
69
|
+
* draws as it would anywhere else.
|
|
69
70
|
*
|
|
70
71
|
* The call site's `className` and `style` land on the container, which is
|
|
71
72
|
* the element a layout positions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","ToolbarProps","RACToolbarProps","SeparatorProps","stylex","useMemo","Toolbar","RACToolbar","SeparatorContext","mergeStatefulStyles","colors","radii","spacing","styles","base","kGNEyG","kaIpWk","kB7OPa","kMwMTN","k1xSpc","kOIVth","kjj79g","k3XXqK","$$css","horizontal","kXwgrk","kAzted","k8WAf4","kg3NbH","neutral","kWkggS","vertical","k7Eaqz","vibrant","Omit","children","className","style","tone","ToolbarTone","t0","$","T0","T1","t1","t2","t3","t4","orientation","t5","t6","props","undefined","t7","t8","separator","Toolbar","_c","props","RACToolbar","stylex.props"],"sources":["../../../src/components/toolbar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ToolbarProps as RACToolbarProps, SeparatorProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useMemo } from 'react';\nimport { Toolbar as RACToolbar, SeparatorContext } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing } from '../../tokens/design.tokens.stylex';\n\n// The toolbars page's container: a row of frequently used controls, on a\n// surface of its own, with the arrow keys moving between them rather than\n// Tab. The page calls it \"a container with configurable slots\", so nothing\n// here says what goes in one — an icon button, a button, a field or a rule\n// are all the call site's to place.\n//\n// The measurements are the page's, stated there in words: 64dp tall,\n// centred, 8dp between items and 16dp of padding outside them. The two\n// colour schemes are its own too — standard on surface container, vibrant on\n// primary container — and both put the muted content role on what they hold.\n// `tone` spells the standard one `neutral` rather than by the page's name,\n// since that is the word every `tone` in the library uses for its neutral\n// role.\n//\n// Two things are this component's own.\n//\n// **A rule inside it runs across the row, not along it.** React Aria's\n// `Toolbar` sets its orientation on itself and nowhere else, so a\n// `Separator` written among the controls would draw the way it does anywhere\n// else — along the row, where it is invisible. This provides React Aria's\n// separator context with the perpendicular orientation, and `Separator`\n// reads it, so a rule between two controls is correct without the call site\n// saying which way it runs.\n//\n// **Arrow-key navigation is React Aria's and is not wrapped.** The arrows\n// move between the controls, and — worth knowing, since the pattern usually\n// implies otherwise — React Aria leaves every control tabbable rather than\n// giving the bar a roving tabindex, so Tab still steps through them one by\n// one. What the bar adds is the toolbar role, which tells a screen reader\n// the controls belong together, and a second way to move between them.\n//\n// One departure, and it is about the shape. The page gives the container's\n// corner as a token its widget draws rather than writes, so there is no\n// value to read: what it states in words is the height, the alignment and\n// the padding, and nothing else. The fully rounded corner here, and the\n// inline box that goes with it, are the library's own choice for a bar that\n// floats over a page rather than docking to its edge — a docked one spans\n// its container and squares its corner, both from the call site.\n\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x1dkaolv\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n k1xSpc: \"x3nfvp2\",\n kOIVth: \"x126z3so\",\n kjj79g: \"xl56j7k\",\n k3XXqK: \"x1t137rt\",\n $$css: true\n },\n horizontal: {\n kXwgrk: \"x1q0g3np\",\n kAzted: \"x8nclml\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n neutral: {\n kWkggS: \"x1mjdul6\",\n $$css: true\n },\n vertical: {\n kXwgrk: \"xdt5ytf\",\n k7Eaqz: \"x4m7ku4\",\n k8WAf4: \"xp6hjv6\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n vibrant: {\n kWkggS: \"xp89om9\",\n kMwMTN: \"xscdzaa\",\n $$css: true\n }\n};\ntype ToolbarProps = Omit<RACToolbarProps, 'children' | 'className' | 'style'> & {\n /** The controls, and any rule between them. */\n children?: ReactNode;\n /** A function may compute the class from the toolbar's render state. */\n className?: RACToolbarProps['className'];\n /** A function may compute the style from the toolbar's render state. */\n style?: RACToolbarProps['style'];\n /**\n * Which of the page's two colour schemes the bar takes. `neutral` is the\n * page's standard scheme, the surface container it draws by default;\n * `vibrant` moves it to primary container, for a bar meant to carry the\n * page's accent.\n * @default 'neutral'\n */\n tone?: ToolbarTone;\n};\ntype ToolbarTone = 'neutral' | 'vibrant';\n\n/**\n * A container for a set of controls, announced as a toolbar so a screen\n * reader reads them as one group, with the arrow keys moving between them.\n * Tab still steps through each control: React Aria's toolbar adds the arrows\n * rather than replacing what Tab does.\n *\n * ```tsx\n * <Toolbar aria-label=\"Label\">\n * <IconButton aria-label=\"First item\">\n * <FirstIcon />\n * </IconButton>\n * <Separator />\n * <IconButton aria-label=\"Second item\">\n * <SecondIcon />\n * </IconButton>\n * </Toolbar>\n * ```\n *\n * Name it with `aria-label` or `aria-labelledby` — nothing here labels it for\n * you, and a toolbar with no name is a group a screen reader cannot announce.\n *\n * `orientation` is React Aria's, and it decides both which arrows move and\n * which way the bar runs. A `Separator`
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","ToolbarProps","RACToolbarProps","SeparatorProps","stylex","useMemo","Toolbar","RACToolbar","SeparatorContext","mergeStatefulStyles","colors","radii","spacing","styles","base","kGNEyG","kaIpWk","kB7OPa","kMwMTN","k1xSpc","kOIVth","kjj79g","k3XXqK","$$css","horizontal","kXwgrk","kAzted","k8WAf4","kg3NbH","neutral","kWkggS","vertical","k7Eaqz","vibrant","Omit","children","className","style","tone","ToolbarTone","t0","$","T0","T1","t1","t2","t3","t4","orientation","t5","t6","props","undefined","t7","t8","separator","Toolbar","_c","props","RACToolbar","stylex.props"],"sources":["../../../src/components/toolbar/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ToolbarProps as RACToolbarProps, SeparatorProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useMemo } from 'react';\nimport { Toolbar as RACToolbar, SeparatorContext } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing } from '../../tokens/design.tokens.stylex';\n\n// The toolbars page's container: a row of frequently used controls, on a\n// surface of its own, with the arrow keys moving between them rather than\n// Tab. The page calls it \"a container with configurable slots\", so nothing\n// here says what goes in one — an icon button, a button, a field or a rule\n// are all the call site's to place.\n//\n// The measurements are the page's, stated there in words: 64dp tall,\n// centred, 8dp between items and 16dp of padding outside them. The two\n// colour schemes are its own too — standard on surface container, vibrant on\n// primary container — and both put the muted content role on what they hold.\n// `tone` spells the standard one `neutral` rather than by the page's name,\n// since that is the word every `tone` in the library uses for its neutral\n// role.\n//\n// Two things are this component's own.\n//\n// **A rule inside it runs across the row, not along it.** React Aria's\n// `Toolbar` sets its orientation on itself and nowhere else, so a\n// `Separator` written among the controls would draw the way it does anywhere\n// else — along the row, where it is invisible. This provides React Aria's\n// separator context with the perpendicular orientation, and `Separator`\n// reads it, so a rule between two controls is correct without the call site\n// saying which way it runs. The context reaches the bar's own controls and\n// stops at an overlay opened from one: React context crosses the portal a\n// popover, sheet or dialog renders through, so their content parts clear it\n// — see `src/overlay` — and a rule inside one runs across the overlay as it\n// does anywhere else.\n//\n// **Arrow-key navigation is React Aria's and is not wrapped.** The arrows\n// move between the controls, and — worth knowing, since the pattern usually\n// implies otherwise — React Aria leaves every control tabbable rather than\n// giving the bar a roving tabindex, so Tab still steps through them one by\n// one. What the bar adds is the toolbar role, which tells a screen reader\n// the controls belong together, and a second way to move between them.\n//\n// One departure, and it is about the shape. The page gives the container's\n// corner as a token its widget draws rather than writes, so there is no\n// value to read: what it states in words is the height, the alignment and\n// the padding, and nothing else. The fully rounded corner here, and the\n// inline box that goes with it, are the library's own choice for a bar that\n// floats over a page rather than docking to its edge — a docked one spans\n// its container and squares its corner, both from the call site.\n\nconst styles = {\n base: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x1dkaolv\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"x1w5n3ug\",\n k1xSpc: \"x3nfvp2\",\n kOIVth: \"x126z3so\",\n kjj79g: \"xl56j7k\",\n k3XXqK: \"x1t137rt\",\n $$css: true\n },\n horizontal: {\n kXwgrk: \"x1q0g3np\",\n kAzted: \"x8nclml\",\n k8WAf4: \"x1cmllll\",\n kg3NbH: \"x790zyz\",\n $$css: true\n },\n neutral: {\n kWkggS: \"x1mjdul6\",\n $$css: true\n },\n vertical: {\n kXwgrk: \"xdt5ytf\",\n k7Eaqz: \"x4m7ku4\",\n k8WAf4: \"xp6hjv6\",\n kg3NbH: \"xn60lsn\",\n $$css: true\n },\n vibrant: {\n kWkggS: \"xp89om9\",\n kMwMTN: \"xscdzaa\",\n $$css: true\n }\n};\ntype ToolbarProps = Omit<RACToolbarProps, 'children' | 'className' | 'style'> & {\n /** The controls, and any rule between them. */\n children?: ReactNode;\n /** A function may compute the class from the toolbar's render state. */\n className?: RACToolbarProps['className'];\n /** A function may compute the style from the toolbar's render state. */\n style?: RACToolbarProps['style'];\n /**\n * Which of the page's two colour schemes the bar takes. `neutral` is the\n * page's standard scheme, the surface container it draws by default;\n * `vibrant` moves it to primary container, for a bar meant to carry the\n * page's accent.\n * @default 'neutral'\n */\n tone?: ToolbarTone;\n};\ntype ToolbarTone = 'neutral' | 'vibrant';\n\n/**\n * A container for a set of controls, announced as a toolbar so a screen\n * reader reads them as one group, with the arrow keys moving between them.\n * Tab still steps through each control: React Aria's toolbar adds the arrows\n * rather than replacing what Tab does.\n *\n * ```tsx\n * <Toolbar aria-label=\"Label\">\n * <IconButton aria-label=\"First item\">\n * <FirstIcon />\n * </IconButton>\n * <Separator />\n * <IconButton aria-label=\"Second item\">\n * <SecondIcon />\n * </IconButton>\n * </Toolbar>\n * ```\n *\n * Name it with `aria-label` or `aria-labelledby` — nothing here labels it for\n * you, and a toolbar with no name is a group a screen reader cannot announce.\n *\n * `orientation` is React Aria's, and it decides both which arrows move and\n * which way the bar runs. A `Separator` among its controls draws across that\n * direction without being told; one inside an overlay opened from the bar\n * draws as it would anywhere else.\n *\n * The call site's `className` and `style` land on the container, which is\n * the element a layout positions.\n */\nfunction Toolbar({\n orientation = 'horizontal',\n tone = 'neutral',\n ...props\n}: RefAttributes<HTMLDivElement> & ToolbarProps) {\n // The rule runs across the toolbar rather than along it. Memoised because\n // a fresh object here would be a new context value on every render, which\n // is what react-perf's no-new-object-as-prop is after.\n const separator = useMemo<SeparatorProps>(() => ({\n orientation: orientation === 'horizontal' ? 'vertical' : 'horizontal'\n }), [orientation]);\n return <SeparatorContext value={separator}>\n <RACToolbar orientation={orientation} {...props} {...mergeStatefulStyles(stylex.props(styles.base, styles[orientation], styles[tone]), props)} />\n </SeparatorContext>;\n}\nexport type { ToolbarProps, ToolbarTone };\nexport default Toolbar;"],"mappings":";;;;;;;;AAsDA,MAAMgB,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,YAAY;EACVC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRL,OAAO;CACT;CACAM,SAAS;EACPC,QAAQ;EACR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OAAAC,MAAAD,EAAA,QAAAG,MAAAH,EAAA,QAAAI,MAAAJ,EAAA,QAAAK,IAAA;EAA7IG,KAAA,oBAAC,IAAD;GAAyBD,aAAAA;GAAW,GAAMG;GAAK,GAAML;EAAwF,CAAA;EAAIL,EAAA,KAAAC;EAAAD,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAS;CAAA,IAAAT,EAAA,QAAAE,MAAAF,EAAA,QAAAM,MAAAN,EAAA,QAAAQ,IAAA;EAD9IC,KAAA,oBAAC,IAAD;GAAyBK,OAAAA;GAC5BN,UAAAA;EADoB,CAAA;EAEHR,EAAA,MAAAE;EAAAF,EAAA,MAAAM;EAAAN,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,OAFdS;AAEc"}
|
package/dist/field/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { focusesControl } from "./press.js";
|
|
|
6
6
|
import { useInsideForm } from "./root.js";
|
|
7
7
|
import { fieldChromeStyles, groupStyles } from "./styles.js";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
9
|
-
import { createContext, useContext } from "react";
|
|
9
|
+
import { createContext, useContext, useId } from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { Button, FieldError, FieldErrorContext, Group, Input, InputContext, Label, SelectStateContext, Text, TextArea, TextAreaContext, TextContext, VisuallyHidden, useLocale, useSlottedContext } from "react-aria-components";
|
|
12
12
|
//#region src/field/index.tsx
|
|
@@ -335,16 +335,25 @@ function FieldBox(t0) {
|
|
|
335
335
|
* populated control from an empty one: its own where it was given one, a
|
|
336
336
|
* blank otherwise. Outside a box it has no label over it and shows the
|
|
337
337
|
* placeholder it was given in every state.
|
|
338
|
+
*
|
|
339
|
+
* A prefix or a suffix describes the control, ahead of its description and
|
|
340
|
+
* error, so a reader hears the unit or currency the value is read against —
|
|
341
|
+
* as a sighted one sees it beside the value. As bare text beside the input
|
|
342
|
+
* it was in no name and no description, and a reader heard the label alone.
|
|
338
343
|
*/
|
|
339
344
|
function FieldInput(t0) {
|
|
340
|
-
const $ = c(
|
|
341
|
-
const { numeric: t1, placeholder, prefix, suffix, ...props$
|
|
345
|
+
const $ = c(23);
|
|
346
|
+
const { numeric: t1, placeholder, prefix, suffix, ...props$1 } = t0;
|
|
342
347
|
const numeric = t1 === void 0 ? false : t1;
|
|
343
348
|
const box = useContext(BoxContext);
|
|
344
349
|
const validation = useContext(FieldErrorContext);
|
|
350
|
+
const prefixId = useId();
|
|
351
|
+
const suffixId = useId();
|
|
352
|
+
const field = useSlottedContext(InputContext);
|
|
353
|
+
const describedBy = idsOf(prefix === void 0 ? void 0 : prefixId, suffix === void 0 ? void 0 : suffixId, field?.["aria-describedby"], props$1["aria-describedby"]);
|
|
345
354
|
const T0 = Input;
|
|
346
355
|
const t2 = placeholder ?? (box.label === "floating" ? " " : void 0);
|
|
347
|
-
const t3 = commitWhileInvalid(validation?.isInvalid ?? false, props$
|
|
356
|
+
const t3 = commitWhileInvalid(validation?.isInvalid ?? false, props$1.onInput);
|
|
348
357
|
let t4;
|
|
349
358
|
if ($[0] !== box || $[1] !== numeric) {
|
|
350
359
|
t4 = (state) => props(fieldChromeStyles.input, box.underLabel && fieldChromeStyles.inputUnderLabel, box.label === "floating" && fieldChromeStyles.inputUnderFloatingLabel, numeric && fieldChromeStyles.numeric, state.isDisabled && fieldChromeStyles.inputDisabled);
|
|
@@ -352,51 +361,57 @@ function FieldInput(t0) {
|
|
|
352
361
|
$[1] = numeric;
|
|
353
362
|
$[2] = t4;
|
|
354
363
|
} else t4 = $[2];
|
|
355
|
-
const t5 = mergeStatefulStyles(t4, props$
|
|
364
|
+
const t5 = mergeStatefulStyles(t4, props$1);
|
|
356
365
|
let t6;
|
|
357
|
-
if ($[3] !== T0 || $[4] !== props$
|
|
366
|
+
if ($[3] !== T0 || $[4] !== describedBy || $[5] !== props$1 || $[6] !== t2 || $[7] !== t3 || $[8] !== t5) {
|
|
358
367
|
t6 = /* @__PURE__ */ jsx(T0, {
|
|
359
368
|
placeholder: t2,
|
|
360
|
-
...props$
|
|
369
|
+
...props$1,
|
|
370
|
+
"aria-describedby": describedBy,
|
|
361
371
|
onInput: t3,
|
|
362
372
|
...t5
|
|
363
373
|
});
|
|
364
374
|
$[3] = T0;
|
|
365
|
-
$[4] =
|
|
366
|
-
$[5] =
|
|
367
|
-
$[6] =
|
|
368
|
-
$[7] =
|
|
369
|
-
$[8] =
|
|
370
|
-
|
|
375
|
+
$[4] = describedBy;
|
|
376
|
+
$[5] = props$1;
|
|
377
|
+
$[6] = t2;
|
|
378
|
+
$[7] = t3;
|
|
379
|
+
$[8] = t5;
|
|
380
|
+
$[9] = t6;
|
|
381
|
+
} else t6 = $[9];
|
|
371
382
|
const control = t6;
|
|
372
383
|
if (prefix === void 0 && suffix === void 0) return control;
|
|
373
384
|
let t7;
|
|
374
|
-
if ($[
|
|
385
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
375
386
|
t7 = props(fieldChromeStyles.affixLine);
|
|
376
|
-
$[
|
|
377
|
-
} else t7 = $[
|
|
387
|
+
$[10] = t7;
|
|
388
|
+
} else t7 = $[10];
|
|
378
389
|
let t8;
|
|
379
|
-
if ($[
|
|
390
|
+
if ($[11] !== box || $[12] !== prefix || $[13] !== prefixId) {
|
|
380
391
|
t8 = prefix === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
392
|
+
id: prefixId,
|
|
381
393
|
...props(fieldChromeStyles.affix, box.underLabel && fieldChromeStyles.inputUnderLabel),
|
|
382
394
|
children: prefix
|
|
383
395
|
});
|
|
384
|
-
$[
|
|
385
|
-
$[
|
|
386
|
-
$[
|
|
387
|
-
|
|
396
|
+
$[11] = box;
|
|
397
|
+
$[12] = prefix;
|
|
398
|
+
$[13] = prefixId;
|
|
399
|
+
$[14] = t8;
|
|
400
|
+
} else t8 = $[14];
|
|
388
401
|
let t9;
|
|
389
|
-
if ($[
|
|
402
|
+
if ($[15] !== box || $[16] !== suffix || $[17] !== suffixId) {
|
|
390
403
|
t9 = suffix === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
404
|
+
id: suffixId,
|
|
391
405
|
...props(fieldChromeStyles.affix, box.underLabel && fieldChromeStyles.inputUnderLabel),
|
|
392
406
|
children: suffix
|
|
393
407
|
});
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
|
|
408
|
+
$[15] = box;
|
|
409
|
+
$[16] = suffix;
|
|
410
|
+
$[17] = suffixId;
|
|
411
|
+
$[18] = t9;
|
|
412
|
+
} else t9 = $[18];
|
|
398
413
|
let t10;
|
|
399
|
-
if ($[
|
|
414
|
+
if ($[19] !== control || $[20] !== t8 || $[21] !== t9) {
|
|
400
415
|
t10 = /* @__PURE__ */ jsxs("span", {
|
|
401
416
|
...t7,
|
|
402
417
|
children: [
|
|
@@ -405,11 +420,11 @@ function FieldInput(t0) {
|
|
|
405
420
|
t9
|
|
406
421
|
]
|
|
407
422
|
});
|
|
408
|
-
$[
|
|
409
|
-
$[
|
|
410
|
-
$[
|
|
411
|
-
$[
|
|
412
|
-
} else t10 = $[
|
|
423
|
+
$[19] = control;
|
|
424
|
+
$[20] = t8;
|
|
425
|
+
$[21] = t9;
|
|
426
|
+
$[22] = t10;
|
|
427
|
+
} else t10 = $[22];
|
|
413
428
|
return t10;
|
|
414
429
|
}
|
|
415
430
|
/**
|
|
@@ -462,7 +477,7 @@ function FieldSegments(t0) {
|
|
|
462
477
|
*/
|
|
463
478
|
function FieldTextArea(t0) {
|
|
464
479
|
const $ = c(18);
|
|
465
|
-
const { autosize: t1, placeholder, ...props$
|
|
480
|
+
const { autosize: t1, placeholder, ...props$2 } = t0;
|
|
466
481
|
const autosize = t1 === void 0 ? false : t1;
|
|
467
482
|
const box = useContext(BoxContext);
|
|
468
483
|
const context = useSlottedContext(TextAreaContext);
|
|
@@ -470,7 +485,7 @@ function FieldTextArea(t0) {
|
|
|
470
485
|
const value = typeof context?.value === "string" ? context.value : "";
|
|
471
486
|
const T0 = TextArea;
|
|
472
487
|
const t2 = placeholder ?? (box.label === "floating" ? " " : void 0);
|
|
473
|
-
const t3 = commitWhileInvalid(validation?.isInvalid ?? false, props$
|
|
488
|
+
const t3 = commitWhileInvalid(validation?.isInvalid ?? false, props$2.onInput);
|
|
474
489
|
let t4;
|
|
475
490
|
if ($[0] !== autosize || $[1] !== box) {
|
|
476
491
|
t4 = (state) => props(fieldChromeStyles.input, box.underLabel && fieldChromeStyles.inputUnderLabel, box.label === "floating" && fieldChromeStyles.inputUnderFloatingLabel, fieldChromeStyles.textArea, autosize && fieldChromeStyles.textAreaAutosize, autosize && fieldChromeStyles.autosizeCell, state.isDisabled && fieldChromeStyles.inputDisabled);
|
|
@@ -478,17 +493,17 @@ function FieldTextArea(t0) {
|
|
|
478
493
|
$[1] = box;
|
|
479
494
|
$[2] = t4;
|
|
480
495
|
} else t4 = $[2];
|
|
481
|
-
const t5 = mergeStatefulStyles(t4, props$
|
|
496
|
+
const t5 = mergeStatefulStyles(t4, props$2);
|
|
482
497
|
let t6;
|
|
483
|
-
if ($[3] !== T0 || $[4] !== props$
|
|
498
|
+
if ($[3] !== T0 || $[4] !== props$2 || $[5] !== t2 || $[6] !== t3 || $[7] !== t5) {
|
|
484
499
|
t6 = /* @__PURE__ */ jsx(T0, {
|
|
485
500
|
placeholder: t2,
|
|
486
|
-
...props$
|
|
501
|
+
...props$2,
|
|
487
502
|
onInput: t3,
|
|
488
503
|
...t5
|
|
489
504
|
});
|
|
490
505
|
$[3] = T0;
|
|
491
|
-
$[4] = props$
|
|
506
|
+
$[4] = props$2;
|
|
492
507
|
$[5] = t2;
|
|
493
508
|
$[6] = t3;
|
|
494
509
|
$[7] = t5;
|
|
@@ -540,21 +555,21 @@ function FieldTextArea(t0) {
|
|
|
540
555
|
* the fill, the underline and the focus indicator, and it lights up while
|
|
541
556
|
* this has focus because the indicator follows focus within.
|
|
542
557
|
*/
|
|
543
|
-
function FieldTrigger(props$
|
|
558
|
+
function FieldTrigger(props$5) {
|
|
544
559
|
const $ = c(5);
|
|
545
560
|
let t0;
|
|
546
|
-
if ($[0] !== props$
|
|
547
|
-
t0 = mergeStatefulStyles(props(fieldChromeStyles.trigger), props$
|
|
548
|
-
$[0] = props$
|
|
561
|
+
if ($[0] !== props$5) {
|
|
562
|
+
t0 = mergeStatefulStyles(props(fieldChromeStyles.trigger), props$5);
|
|
563
|
+
$[0] = props$5;
|
|
549
564
|
$[1] = t0;
|
|
550
565
|
} else t0 = $[1];
|
|
551
566
|
let t1;
|
|
552
|
-
if ($[2] !== props$
|
|
567
|
+
if ($[2] !== props$5 || $[3] !== t0) {
|
|
553
568
|
t1 = /* @__PURE__ */ jsx(Button, {
|
|
554
|
-
...props$
|
|
569
|
+
...props$5,
|
|
555
570
|
...t0
|
|
556
571
|
});
|
|
557
|
-
$[2] = props$
|
|
572
|
+
$[2] = props$5;
|
|
558
573
|
$[3] = t0;
|
|
559
574
|
$[4] = t1;
|
|
560
575
|
} else t1 = $[4];
|
|
@@ -600,6 +615,18 @@ function focusedStyle(outlined, invalid) {
|
|
|
600
615
|
if (outlined) return invalid ? fieldChromeStyles.boxOutlinedErrorFocused : fieldChromeStyles.boxOutlinedFocused;
|
|
601
616
|
return invalid ? fieldChromeStyles.boxErrorFocused : fieldChromeStyles.boxFocused;
|
|
602
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* Element ids as one `aria-describedby`, in the order given, leaving out any
|
|
620
|
+
* that are missing or already named — a list of several ids is split, since
|
|
621
|
+
* the same one can arrive from the field and from the call site both — and
|
|
622
|
+
* undefined when none are left, so the attribute is dropped rather than
|
|
623
|
+
* written empty.
|
|
624
|
+
*/
|
|
625
|
+
function idsOf(...lists) {
|
|
626
|
+
const ids = new Set(lists.flatMap((list) => list?.split(" ") ?? []));
|
|
627
|
+
ids.delete("");
|
|
628
|
+
return ids.size === 0 ? void 0 : [...ids].join(" ");
|
|
629
|
+
}
|
|
603
630
|
function returnToStart(event) {
|
|
604
631
|
if (!event.currentTarget.contains(event.relatedTarget)) event.currentTarget.scrollLeft = 0;
|
|
605
632
|
}
|
|
@@ -641,7 +668,7 @@ function FieldLabel(t0) {
|
|
|
641
668
|
let t1;
|
|
642
669
|
let t2;
|
|
643
670
|
if ($[0] !== t0) {
|
|
644
|
-
const { children: t3, isRequired: t4, state: t5, variant: t6, ...props$
|
|
671
|
+
const { children: t3, isRequired: t4, state: t5, variant: t6, ...props$3 } = t0;
|
|
645
672
|
children = t3;
|
|
646
673
|
isRequired = t4 === void 0 ? false : t4;
|
|
647
674
|
const state = t5 === void 0 ? NO_STATE : t5;
|
|
@@ -651,8 +678,8 @@ function FieldLabel(t0) {
|
|
|
651
678
|
const isFocusWithin = t8 === void 0 ? false : t8;
|
|
652
679
|
const isInvalid = t9 === void 0 ? false : t9;
|
|
653
680
|
T0 = Label;
|
|
654
|
-
t1 = props$
|
|
655
|
-
t2 = mergeStyles(props(fieldChromeStyles.label, variant === "group" && groupStyles.label, isDisabled && fieldChromeStyles.labelDisabled, isInvalid && fieldChromeStyles.labelError, !isDisabled && !isInvalid && isFocusWithin && fieldChromeStyles.labelFocused), props$
|
|
681
|
+
t1 = props$3;
|
|
682
|
+
t2 = mergeStyles(props(fieldChromeStyles.label, variant === "group" && groupStyles.label, isDisabled && fieldChromeStyles.labelDisabled, isInvalid && fieldChromeStyles.labelError, !isDisabled && !isInvalid && isFocusWithin && fieldChromeStyles.labelFocused), props$3);
|
|
656
683
|
$[0] = t0;
|
|
657
684
|
$[1] = T0;
|
|
658
685
|
$[2] = children;
|