@kanso-labs/kanso-ui 0.20.0 → 0.22.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/calendar/index.js +80 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/calendar/months.js +14 -0
- package/dist/calendar/months.js.map +1 -0
- package/dist/calendar/styles.js +150 -0
- package/dist/calendar/styles.js.map +1 -0
- package/dist/components/calendar/index.d.ts +32 -0
- package/dist/components/calendar/index.js +97 -0
- package/dist/components/calendar/index.js.map +1 -0
- package/dist/components/color-area/index.d.ts +50 -0
- package/dist/components/color-area/index.js +63 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +41 -0
- package/dist/components/color-slider/index.js +70 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +37 -0
- package/dist/components/color-swatch/index.js +88 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +49 -0
- package/dist/components/color-swatch-picker/index.js +99 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +54 -0
- package/dist/components/date-field/index.js +58 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +57 -0
- package/dist/components/date-picker/index.js +75 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +69 -0
- package/dist/components/date-range-picker/index.js +95 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/disclosure/index.js +3 -3
- package/dist/components/disclosure/index.js.map +1 -1
- package/dist/components/drop-zone/index.d.ts +60 -0
- package/dist/components/drop-zone/index.js +118 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/drop-zone/styles.js +61 -0
- package/dist/components/drop-zone/styles.js.map +1 -0
- package/dist/components/icon-button/index.d.ts +4 -3
- package/dist/components/icon-button/index.js +48 -2
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/index.d.ts +15 -1
- package/dist/components/list/index.js +3 -3
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.js +3 -3
- package/dist/components/list-box/index.js.map +1 -1
- package/dist/components/list-item/index.d.ts +16 -6
- package/dist/components/list-item/index.js +16 -8
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +94 -0
- package/dist/components/navigation-tree/index.js +266 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/range-calendar/index.d.ts +39 -0
- package/dist/components/range-calendar/index.js +105 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/separator/index.d.ts +17 -4
- package/dist/components/separator/index.js +38 -20
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/table/index.d.ts +197 -0
- package/dist/components/table/index.js +327 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +53 -0
- package/dist/components/time-field/index.js +57 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +116 -0
- package/dist/components/tree/index.js +245 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/date.d.ts +1 -0
- package/dist/date.js +1 -0
- package/dist/drag/hooks.d.ts +25 -0
- package/dist/drag/hooks.js +55 -0
- package/dist/drag/hooks.js.map +1 -0
- package/dist/drag/index.js +28 -0
- package/dist/drag/index.js.map +1 -0
- package/dist/drag/styles.js +46 -0
- package/dist/drag/styles.js.map +1 -0
- package/dist/glyphs/index.js +64 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.js +18 -2
- package/dist/layout.d.ts +40 -0
- package/dist/layout.js +41 -0
- package/dist/layout.js.map +1 -0
- package/dist/react-aria.d.ts +3 -2
- package/dist/react-aria.js +3 -2
- package/dist/row/index.js +25 -13
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +34 -0
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/index.js +22 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +42 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/styles/chequer.js +14 -0
- package/dist/styles/chequer.js.map +1 -0
- package/dist/styles/color.js +17 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/picker.js +61 -0
- package/dist/styles/picker.js.map +1 -0
- package/dist/styles.css +263 -3
- package/dist/tokens/design.tokens.stylex.js +61 -1
- package/dist/tokens/design.tokens.stylex.js.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
|
+
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
3
|
+
import { FieldLabel } from "../../field/index.js";
|
|
4
|
+
import { thumbClassName } from "../../styles/color.js";
|
|
5
|
+
import { chequer } from "../../styles/chequer.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ColorSlider, ColorThumb, SliderOutput, SliderTrack } from "react-aria-components";
|
|
8
|
+
//#region src/components/color-slider/index.tsx
|
|
9
|
+
const styles = {
|
|
10
|
+
trackGround: {
|
|
11
|
+
kZKoxP: "xlup9mm",
|
|
12
|
+
kaIpWk: "x1xdvaa9",
|
|
13
|
+
kB7OPa: "x9f619",
|
|
14
|
+
kzqmXN: "xh8yej3",
|
|
15
|
+
kqGvvJ: "x2k5q2m",
|
|
16
|
+
$$css: true
|
|
17
|
+
},
|
|
18
|
+
trackGroundDisabled: {
|
|
19
|
+
kSiTet: "x1ppv7y9",
|
|
20
|
+
$$css: true
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A slider over one channel of a colour — hue, saturation, lightness, alpha
|
|
25
|
+
* and the rest. The value is React Aria's: pass `value` with `onChange` to
|
|
26
|
+
* control it, or `defaultValue`, as a CSS colour string or a `Color` from
|
|
27
|
+
* `parseColor`, which this package re-exports.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <ColorSlider channel="hue" defaultValue="hsl(200, 100%, 50%)" label="Label" />
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* **`channel` has to name a channel the value's own space has.** A hex or
|
|
34
|
+
* `rgb()` value parses as RGB, which has no hue, so `channel="hue"` against
|
|
35
|
+
* one throws rather than converting — pass `colorSpace="hsl"` to convert it,
|
|
36
|
+
* or give the value in the space you mean to slide.
|
|
37
|
+
*
|
|
38
|
+
* React Aria paints the gradient and names the value — "200°, cyan blue" —
|
|
39
|
+
* so the readout beside the label is what it announces.
|
|
40
|
+
*
|
|
41
|
+
* The call site's `className` and `style` land on the slider as a whole,
|
|
42
|
+
* which is the element a layout positions.
|
|
43
|
+
*/
|
|
44
|
+
function ColorSlider$1({ isDisabled = false, label, showValue = true, ...props$1 }) {
|
|
45
|
+
return /* @__PURE__ */ jsxs(ColorSlider, {
|
|
46
|
+
isDisabled,
|
|
47
|
+
...props$1,
|
|
48
|
+
...mergeStatefulStyles({ className: "x9f619 x78zum5 xdt5ytf xzoy561 xh8yej3" }, props$1),
|
|
49
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: "x1pha0wt x78zum5 x126z3so",
|
|
51
|
+
children: [label === void 0 ? null : /* @__PURE__ */ jsx(FieldLabel, {
|
|
52
|
+
className: "xkknnkr x14zspaw x1v9cpvo x155f00i x1lz68p4",
|
|
53
|
+
children: label
|
|
54
|
+
}), showValue ? /* @__PURE__ */ jsx(SliderOutput, { className: "x1w5n3ug x1yicsit x1b35g6e xwth0xh xybisxh xvc5jky" }) : null]
|
|
55
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
56
|
+
...props(chequer.ground, styles.trackGround, isDisabled && styles.trackGroundDisabled),
|
|
57
|
+
children: /* @__PURE__ */ jsx(SliderTrack, {
|
|
58
|
+
...{
|
|
59
|
+
0: { className: "x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6" },
|
|
60
|
+
1: { className: "x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1h6gzvc" }
|
|
61
|
+
}[!!isDisabled << 0],
|
|
62
|
+
children: /* @__PURE__ */ jsx(ColorThumb, { className: thumbClassName })
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ColorSlider$1 as default };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/color-slider/index.tsx"],"sourcesContent":["import type { ColorSliderProps as RACColorSliderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSlider as RACColorSlider, ColorThumb as RACColorThumb, SliderOutput as RACSliderOutput, SliderTrack as RACSliderTrack } from 'react-aria-components';\nimport { FieldLabel } from '../../field';\nimport { chequer } from '../../styles/chequer';\nimport { thumbClassName } from '../../styles/color';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity, typography } from '../../tokens/design.tokens.stylex';\n\n// The sliders page's track, carrying one channel of a colour instead of an\n// active and an inactive part: the page's 16dp strip with its 8dp corner,\n// centred in the 44dp a handle takes, and the same label-large label above\n// it. React Aria paints the gradient itself, on the track's own inline\n// `background`, so what runs along the strip is the channel rather than\n// anything chosen here.\n//\n// Three things depart from the page, each because a colour slider shows a\n// value the page's slider does not have.\n//\n// **The handle is a circle carrying the colour, not the page's 4dp bar.**\n// The page's handle is a mark on a track whose colour it already knows; this\n// one has to show the value it sits on, and 4dp of a colour is not a colour\n// anyone can read. It keeps the page's 44dp of height as the target it is\n// centred in.\n//\n// **The handle is ringed rather than filled with primary.** Its fill is the\n// value, so the ring is what has to read against it — and against every\n// other colour the track runs through. It is a surface-coloured ring with a\n// hairline outside it, which reads on a light track and a dark one alike.\n//\n// **There is no stop at the inactive end.** The page puts one 6dp from the\n// end of the inactive part; a channel has no inactive part, so there is no\n// end for it to mark.\n//\n// The alpha channel is the one that needs a chequer, for the reason\n// `src/styles/chequer.ts` gives: a track fading to transparent over a light\n// surface and one fading to white are the same pixels without it.\n\nconst styles = {\n trackGround: {\n kZKoxP: \"xlup9mm\",\n kaIpWk: \"x1xdvaa9\",\n kB7OPa: \"x9f619\",\n kzqmXN: \"xh8yej3\",\n kqGvvJ: \"x2k5q2m\",\n $$css: true\n },\n trackGroundDisabled: {\n kSiTet: \"x1ppv7y9\",\n $$css: true\n }\n};\ntype ColorSliderProps = Omit<RACColorSliderProps, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the slider's render state. */\n className?: RACColorSliderProps['className'];\n /** What the slider is for. Always rendered; React Aria names the channel otherwise. */\n label?: string;\n /**\n * Whether the value React Aria announces is also shown, at the end of the\n * label's line.\n * @default true\n */\n showValue?: boolean;\n /** A function may compute the style from the slider's render state. */\n style?: RACColorSliderProps['style'];\n};\n\n/**\n * A slider over one channel of a colour — hue, saturation, lightness, alpha\n * and the rest. The value is React Aria's: pass `value` with `onChange` to\n * control it, or `defaultValue`, as a CSS colour string or a `Color` from\n * `parseColor`, which this package re-exports.\n *\n * ```tsx\n * <ColorSlider channel=\"hue\" defaultValue=\"hsl(200, 100%, 50%)\" label=\"Label\" />\n * ```\n *\n * **`channel` has to name a channel the value's own space has.** A hex or\n * `rgb()` value parses as RGB, which has no hue, so `channel=\"hue\"` against\n * one throws rather than converting — pass `colorSpace=\"hsl\"` to convert it,\n * or give the value in the space you mean to slide.\n *\n * React Aria paints the gradient and names the value — \"200°, cyan blue\" —\n * so the readout beside the label is what it announces.\n *\n * The call site's `className` and `style` land on the slider as a whole,\n * which is the element a layout positions.\n */\nfunction ColorSlider({\n isDisabled = false,\n label,\n showValue = true,\n ...props\n}: ColorSliderProps) {\n return <RACColorSlider isDisabled={isDisabled} {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 xdt5ytf xzoy561 xh8yej3\"\n }, props)}>\n <div className=\"x1pha0wt x78zum5 x126z3so\">\n {label === undefined ? null : <FieldLabel className=\"xkknnkr x14zspaw x1v9cpvo x155f00i x1lz68p4\">{label}</FieldLabel>}\n {showValue ? <RACSliderOutput className=\"x1w5n3ug x1yicsit x1b35g6e xwth0xh xybisxh xvc5jky\" /> : null}\n </div>\n <div {...stylex.props(chequer.ground, styles.trackGround, isDisabled && styles.trackGroundDisabled)}>\n <RACSliderTrack {...{\n 0: {\n className: \"x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6\"\n },\n 1: {\n className: \"x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1h6gzvc\"\n }\n }[!!isDisabled << 0]}>\n <RACColorThumb className={thumbClassName} />\n </RACSliderTrack>\n </div>\n </RACColorSlider>;\n}\nexport type { ColorSliderProps };\nexport default ColorSlider;"],"mappings":";;;;;;;;AAuCA,MAAM,SAAS;CACb,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,qBAAqB;EACnB,QAAQ;EACR,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,cAAY,EACnB,aAAa,OACb,OACA,YAAY,MACZ,GAAG,WACgB;CACnB,OAAO,qBAAC,aAAD;EAA4B;EAAY,GAAI;EAAO,GAAI,oBAAoB,EAChF,WAAW,yCACb,GAAG,OAAK;EAFD,UAAA,CAGH,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,UAAU,KAAA,IAAY,OAAO,oBAAC,YAAD;IAAY,WAAU;IAA+C,UAAA;GAAkB,CAAA,GACpH,YAAY,oBAAC,cAAD,EAAiB,WAAU,qDAAoD,CAAA,IAAM,IAC/F;EACL,CAAA,GAAA,oBAAC,OAAD;GAAK,GAAI,MAAa,QAAQ,QAAQ,OAAO,aAAa,cAAc,OAAO,mBAAmB;GAChG,UAAA,oBAAC,aAAD;IAAgB,GAAI;KACpB,GAAG,EACD,WAAW,8EACb;KACA,GAAG,EACD,WAAW,8EACb;IACF,EAAE,CAAC,CAAC,cAAc;IACd,UAAA,oBAAC,YAAD,EAAe,WAAW,eAAe,CAAA;GAC3B,CAAA;EACb,CAAA,CACS;;AACpB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
import { ColorSwatchProps } from "react-aria-components";
|
|
3
|
+
//#region src/components/color-swatch/index.d.ts
|
|
4
|
+
type ColorSwatchProps$1 = Omit<ColorSwatchProps, 'className' | 'style'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Lands on the square around the swatch, which is the element a layout
|
|
7
|
+
* positions and the one that carries its size.
|
|
8
|
+
*/
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Lands on the square around the swatch, as `className` does. */
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A colour shown as a value: a square of it, with a chequer behind so
|
|
15
|
+
* transparency reads as transparency. The colour is React Aria's — a CSS
|
|
16
|
+
* string, or a `Color` from `parseColor`, which this package re-exports.
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { parseColor } from '@kanso-labs/kanso-ui'
|
|
20
|
+
*
|
|
21
|
+
* <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* React Aria names it from the colour itself — "light vibrant cyan blue, 60%
|
|
25
|
+
* transparent" — so it needs no label. Pass `colorName` to say something
|
|
26
|
+
* else instead.
|
|
27
|
+
*
|
|
28
|
+
* The call site's `className` and `style` land on the square around the
|
|
29
|
+
* swatch rather than on the swatch itself, which is what makes setting a
|
|
30
|
+
* size from outside work — the colour fills whatever square it is given.
|
|
31
|
+
* React Aria's function forms are not taken here, since a swatch has no
|
|
32
|
+
* interactive state for one to read.
|
|
33
|
+
*/
|
|
34
|
+
declare function ColorSwatch$1({ className, style, ...props }: ColorSwatchProps$1): import("react").JSX.Element;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { type ColorSwatchProps$1 as ColorSwatchProps, ColorSwatch$1 as default };
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
|
+
import { mergeStyles } from "../../styles/merge.js";
|
|
3
|
+
import { chequer } from "../../styles/chequer.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { ColorSwatch } from "react-aria-components";
|
|
7
|
+
//#region src/components/color-swatch/index.tsx
|
|
8
|
+
const styles = { ground: {
|
|
9
|
+
kZKoxP: "x1vqgdyp",
|
|
10
|
+
kaIpWk: "x1tfhd1",
|
|
11
|
+
kB7OPa: "x9f619",
|
|
12
|
+
k1xSpc: "x1rg5ohu",
|
|
13
|
+
kzqmXN: "x100vrsf",
|
|
14
|
+
kVQacm: "xb3r6kr",
|
|
15
|
+
$$css: true
|
|
16
|
+
} };
|
|
17
|
+
/**
|
|
18
|
+
* A colour shown as a value: a square of it, with a chequer behind so
|
|
19
|
+
* transparency reads as transparency. The colour is React Aria's — a CSS
|
|
20
|
+
* string, or a `Color` from `parseColor`, which this package re-exports.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { parseColor } from '@kanso-labs/kanso-ui'
|
|
24
|
+
*
|
|
25
|
+
* <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* React Aria names it from the colour itself — "light vibrant cyan blue, 60%
|
|
29
|
+
* transparent" — so it needs no label. Pass `colorName` to say something
|
|
30
|
+
* else instead.
|
|
31
|
+
*
|
|
32
|
+
* The call site's `className` and `style` land on the square around the
|
|
33
|
+
* swatch rather than on the swatch itself, which is what makes setting a
|
|
34
|
+
* size from outside work — the colour fills whatever square it is given.
|
|
35
|
+
* React Aria's function forms are not taken here, since a swatch has no
|
|
36
|
+
* interactive state for one to read.
|
|
37
|
+
*/
|
|
38
|
+
function ColorSwatch$1(t0) {
|
|
39
|
+
const $ = c(12);
|
|
40
|
+
let className;
|
|
41
|
+
let props$1;
|
|
42
|
+
let style;
|
|
43
|
+
if ($[0] !== t0) {
|
|
44
|
+
({className, style, ...props$1} = t0);
|
|
45
|
+
$[0] = t0;
|
|
46
|
+
$[1] = className;
|
|
47
|
+
$[2] = props$1;
|
|
48
|
+
$[3] = style;
|
|
49
|
+
} else {
|
|
50
|
+
className = $[1];
|
|
51
|
+
props$1 = $[2];
|
|
52
|
+
style = $[3];
|
|
53
|
+
}
|
|
54
|
+
let t1;
|
|
55
|
+
if ($[4] !== className || $[5] !== style) {
|
|
56
|
+
t1 = mergeStyles(props(chequer.ground, styles.ground), {
|
|
57
|
+
className,
|
|
58
|
+
style
|
|
59
|
+
});
|
|
60
|
+
$[4] = className;
|
|
61
|
+
$[5] = style;
|
|
62
|
+
$[6] = t1;
|
|
63
|
+
} else t1 = $[6];
|
|
64
|
+
let t2;
|
|
65
|
+
if ($[7] !== props$1) {
|
|
66
|
+
t2 = /* @__PURE__ */ jsx(ColorSwatch, {
|
|
67
|
+
...props$1,
|
|
68
|
+
className: "x5yr21d x1tfhd1 xbd69nm x9f619 x1lliihq xh8yej3"
|
|
69
|
+
});
|
|
70
|
+
$[7] = props$1;
|
|
71
|
+
$[8] = t2;
|
|
72
|
+
} else t2 = $[8];
|
|
73
|
+
let t3;
|
|
74
|
+
if ($[9] !== t1 || $[10] !== t2) {
|
|
75
|
+
t3 = /* @__PURE__ */ jsx("span", {
|
|
76
|
+
...t1,
|
|
77
|
+
children: t2
|
|
78
|
+
});
|
|
79
|
+
$[9] = t1;
|
|
80
|
+
$[10] = t2;
|
|
81
|
+
$[11] = t3;
|
|
82
|
+
} else t3 = $[11];
|
|
83
|
+
return t3;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ColorSwatch$1 as default };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/color-swatch/index.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport type { ColorSwatchProps as RACColorSwatchProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatch as RACColorSwatch } from 'react-aria-components';\nimport { chequer } from '../../styles/chequer';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii } from '../../tokens/design.tokens.stylex';\n\n// A single colour, drawn as a square. The design carries no page for this —\n// its colour guidance is about the roles a component takes, not about\n// showing a colour as a value — so the shape here is the library's own,\n// built from what the rest of it already uses.\n//\n// Three things follow from that, and each is a choice rather than a reading.\n//\n// **A swatch is outlined.** Its own colour is the content, so it cannot\n// carry a contrasting one — and a white swatch on a light surface, or a\n// near-black one in dark mode, would otherwise have no edge at all. The\n// outline is the same hairline a field's box takes.\n//\n// **Transparency is drawn against a chequer rather than against the page.**\n// A half-transparent red over a white surface and an opaque pink are the\n// same pixels; the chequer is what tells them apart. It is built from two\n// surface tokens, so it follows the theme rather than being a fixed grey.\n//\n// **The chequer is a layer behind the swatch, not a background on it.**\n// React Aria sets the colour through the element's own inline\n// `background-color`, and CSS paints a background image over a background\n// colour rather than under it — so a chequer on the same element would\n// cover the colour it is there to reveal.\n\nconst SQUARE = '40px';\nconst styles = {\n ground: {\n kZKoxP: \"x1vqgdyp\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x1rg5ohu\",\n kzqmXN: \"x100vrsf\",\n kVQacm: \"xb3r6kr\",\n $$css: true\n }\n};\ntype ColorSwatchProps = Omit<RACColorSwatchProps, 'className' | 'style'> & {\n /**\n * Lands on the square around the swatch, which is the element a layout\n * positions and the one that carries its size.\n */\n className?: string;\n /** Lands on the square around the swatch, as `className` does. */\n style?: CSSProperties;\n};\n\n/**\n * A colour shown as a value: a square of it, with a chequer behind so\n * transparency reads as transparency. The colour is React Aria's — a CSS\n * string, or a `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * import { parseColor } from '@kanso-labs/kanso-ui'\n *\n * <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />\n * ```\n *\n * React Aria names it from the colour itself — \"light vibrant cyan blue, 60%\n * transparent\" — so it needs no label. Pass `colorName` to say something\n * else instead.\n *\n * The call site's `className` and `style` land on the square around the\n * swatch rather than on the swatch itself, which is what makes setting a\n * size from outside work — the colour fills whatever square it is given.\n * React Aria's function forms are not taken here, since a swatch has no\n * interactive state for one to read.\n */\nfunction ColorSwatch({\n className,\n style,\n ...props\n}: ColorSwatchProps) {\n return <span {...mergeStyles(stylex.props(chequer.ground, styles.ground), {\n className,\n style\n })}>\n <RACColorSwatch {...props} className=\"x5yr21d x1tfhd1 xbd69nm x9f619 x1lliihq xh8yej3\" />\n </span>;\n}\nexport type { ColorSwatchProps };\nexport default ColorSwatch;"],"mappings":";;;;;;;AAiCA,MAAM,SAAS,EACb,QAAQ;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;AACT,EACF;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAA,cAAA,IAAA;CAAA,MAAA,IAAA,EAAA,EAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,IAAA;EAAqB,CAAA,CAAA,WAAA,OAAA,GAAA,WAAA;EAIF,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA;EAAA,YAAA,EAAA;EAAA,UAAA,EAAA;EAAA,QAAA,EAAA;CAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,aAAA,EAAA,OAAA,OAAA;EACA,KAAA,YAAY,MAAa,QAAO,QAAS,OAAM,MAAO,GAAG;GAAA;GAAA;EAG1E,CAAC;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA;EACE,KAAA,oBAAC,aAAD;GAAe,GAAK;GAAiB,WAAA;EAAiD,CAAA;EAAG,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA,EAAA,QAAA,IAAA;EAJtF,KAAA,oBAAA,QAAA;GAKE,GALQ;GAIb,UAAA;EACK,CAAA;EAAA,EAAA,KAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OALF;AAKE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ColorSwatchPickerItemProps, ColorSwatchPickerProps } from "react-aria-components";
|
|
3
|
+
//#region src/components/color-swatch-picker/index.d.ts
|
|
4
|
+
type ColorSwatchPickerItemProps$1 = Omit<ColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {
|
|
5
|
+
/** What the item draws. A `ColorSwatch` with no `color` of its own by default. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** A function may compute the class from the item's render state. */
|
|
8
|
+
className?: ColorSwatchPickerItemProps['className'];
|
|
9
|
+
/** A function may compute the style from the item's render state. */
|
|
10
|
+
style?: ColorSwatchPickerItemProps['style'];
|
|
11
|
+
};
|
|
12
|
+
type ColorSwatchPickerProps$1 = Omit<ColorSwatchPickerProps, 'className' | 'style'> & {
|
|
13
|
+
/** A function may compute the class from the picker's render state. */
|
|
14
|
+
className?: ColorSwatchPickerProps['className'];
|
|
15
|
+
/** A function may compute the style from the picker's render state. */
|
|
16
|
+
style?: ColorSwatchPickerProps['style'];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A row of colours to choose one from, drawn as swatches. The value is React
|
|
20
|
+
* Aria's — pass `value` with `onChange` to control it, or `defaultValue` —
|
|
21
|
+
* as a CSS colour string or a `Color` from `parseColor`, which this package
|
|
22
|
+
* re-exports.
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <ColorSwatchPicker defaultValue="#6750A4">
|
|
26
|
+
* <ColorSwatchPicker.Item color="#6750A4" />
|
|
27
|
+
* <ColorSwatchPicker.Item color="#625B71" />
|
|
28
|
+
* </ColorSwatchPicker>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* It is a listbox, so arrow keys move between colours and the chosen one
|
|
32
|
+
* carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria
|
|
33
|
+
* calls it "Color swatches" otherwise.
|
|
34
|
+
*
|
|
35
|
+
* The call site's `className` and `style` land on the picker, which is the
|
|
36
|
+
* element a layout positions.
|
|
37
|
+
*/
|
|
38
|
+
declare function ColorSwatchPicker$1(props: ColorSwatchPickerProps$1): import("react").JSX.Element;
|
|
39
|
+
declare namespace ColorSwatchPicker$1 {
|
|
40
|
+
var Item: typeof ColorSwatchPickerItem$1;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its
|
|
44
|
+
* own `color` unless given different children.
|
|
45
|
+
*/
|
|
46
|
+
declare function ColorSwatchPickerItem$1({ children, ...props }: ColorSwatchPickerItemProps$1): import("react").JSX.Element;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { type ColorSwatchPickerItemProps$1 as ColorSwatchPickerItemProps, type ColorSwatchPickerProps$1 as ColorSwatchPickerProps, ColorSwatchPicker$1 as default };
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
2
|
+
import ColorSwatch$1 from "../color-swatch/index.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { ColorSwatchPicker, ColorSwatchPickerItem } from "react-aria-components";
|
|
6
|
+
//#region src/components/color-swatch-picker/index.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A row of colours to choose one from, drawn as swatches. The value is React
|
|
9
|
+
* Aria's — pass `value` with `onChange` to control it, or `defaultValue` —
|
|
10
|
+
* as a CSS colour string or a `Color` from `parseColor`, which this package
|
|
11
|
+
* re-exports.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <ColorSwatchPicker defaultValue="#6750A4">
|
|
15
|
+
* <ColorSwatchPicker.Item color="#6750A4" />
|
|
16
|
+
* <ColorSwatchPicker.Item color="#625B71" />
|
|
17
|
+
* </ColorSwatchPicker>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* It is a listbox, so arrow keys move between colours and the chosen one
|
|
21
|
+
* carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria
|
|
22
|
+
* calls it "Color swatches" otherwise.
|
|
23
|
+
*
|
|
24
|
+
* The call site's `className` and `style` land on the picker, which is the
|
|
25
|
+
* element a layout positions.
|
|
26
|
+
*/
|
|
27
|
+
function ColorSwatchPicker$1(props) {
|
|
28
|
+
const $ = c(5);
|
|
29
|
+
let t0;
|
|
30
|
+
if ($[0] !== props) {
|
|
31
|
+
t0 = mergeStatefulStyles({ className: "x9f619 x78zum5 x1a02dak x126z3so x1t137rt" }, props);
|
|
32
|
+
$[0] = props;
|
|
33
|
+
$[1] = t0;
|
|
34
|
+
} else t0 = $[1];
|
|
35
|
+
let t1;
|
|
36
|
+
if ($[2] !== props || $[3] !== t0) {
|
|
37
|
+
t1 = /* @__PURE__ */ jsx(ColorSwatchPicker, {
|
|
38
|
+
...props,
|
|
39
|
+
...t0
|
|
40
|
+
});
|
|
41
|
+
$[2] = props;
|
|
42
|
+
$[3] = t0;
|
|
43
|
+
$[4] = t1;
|
|
44
|
+
} else t1 = $[4];
|
|
45
|
+
return t1;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its
|
|
49
|
+
* own `color` unless given different children.
|
|
50
|
+
*/
|
|
51
|
+
function ColorSwatchPickerItem$1(t0) {
|
|
52
|
+
const $ = c(8);
|
|
53
|
+
let children;
|
|
54
|
+
let props;
|
|
55
|
+
if ($[0] !== t0) {
|
|
56
|
+
({children, ...props} = t0);
|
|
57
|
+
$[0] = t0;
|
|
58
|
+
$[1] = children;
|
|
59
|
+
$[2] = props;
|
|
60
|
+
} else {
|
|
61
|
+
children = $[1];
|
|
62
|
+
props = $[2];
|
|
63
|
+
}
|
|
64
|
+
let t1;
|
|
65
|
+
if ($[3] !== children) {
|
|
66
|
+
t1 = children ?? /* @__PURE__ */ jsx(ColorSwatch$1, {});
|
|
67
|
+
$[3] = children;
|
|
68
|
+
$[4] = t1;
|
|
69
|
+
} else t1 = $[4];
|
|
70
|
+
let t2;
|
|
71
|
+
if ($[5] !== props || $[6] !== t1) {
|
|
72
|
+
t2 = /* @__PURE__ */ jsx(ColorSwatchPickerItem, {
|
|
73
|
+
...props,
|
|
74
|
+
className: itemClassName,
|
|
75
|
+
children: t1
|
|
76
|
+
});
|
|
77
|
+
$[5] = props;
|
|
78
|
+
$[6] = t1;
|
|
79
|
+
$[7] = t2;
|
|
80
|
+
} else t2 = $[7];
|
|
81
|
+
return t2;
|
|
82
|
+
}
|
|
83
|
+
function itemClassName(state) {
|
|
84
|
+
return {
|
|
85
|
+
0: { className: "x1tfhd1 x9f619 x1ypdohk x3nfvp2 xrgy624 x1hl8ikr x1t137rt x1de99jn" },
|
|
86
|
+
4: { className: "x1tfhd1 x9f619 x1ypdohk x3nfvp2 xrgy624 x1de99jn x1hl8ikr xaatb59" },
|
|
87
|
+
2: { className: "x1tfhd1 x9f619 x1ypdohk x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59" },
|
|
88
|
+
6: { className: "x1tfhd1 x9f619 x1ypdohk x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59" },
|
|
89
|
+
1: { className: "x1tfhd1 x9f619 x3nfvp2 xrgy624 x1hl8ikr x1t137rt x1de99jn xt0e3qv x1ppv7y9" },
|
|
90
|
+
5: { className: "x1tfhd1 x9f619 x3nfvp2 xrgy624 x1de99jn x1hl8ikr xaatb59 xt0e3qv x1ppv7y9" },
|
|
91
|
+
3: { className: "x1tfhd1 x9f619 x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59 xt0e3qv x1ppv7y9" },
|
|
92
|
+
7: { className: "x1tfhd1 x9f619 x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59 xt0e3qv x1ppv7y9" }
|
|
93
|
+
}[!!state.isSelected << 2 | !!state.isFocusVisible << 1 | !!state.isDisabled << 0].className ?? "";
|
|
94
|
+
}
|
|
95
|
+
ColorSwatchPicker$1.Item = ColorSwatchPickerItem$1;
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ColorSwatchPicker$1 as default };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["itemClassName"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is the primary role, and offset.** It is the same weight and\n// colour the focus ring takes elsewhere, one step out from the swatch so the\n// colour stays whole — a ring drawn on the swatch would eat two pixels of\n// the thing being chosen.\n//\n// **Focus and selection are drawn at different offsets.** A focused\n// selected swatch would otherwise paint one ring over the other and lose\n// whichever came second, so the focus ring sits outside the selection one.\n\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps) {\n return <RACColorSwatchPickerItem {...props} className={itemClassName}>\n {children ?? <ColorSwatch />}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's classes, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters. `focused` is applied after `selected`, and StyleX\n// replaces a property whole, so a swatch that is both takes the focus ring's\n// outer offset — which is what keeps the two rings from landing on each\n// other. `disabled` is last, so it takes the cursor with it.\nfunction itemClassName(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isSelected: boolean;\n}) {\n return {\n 0: {\n className: \"x1tfhd1 x9f619 x1ypdohk x3nfvp2 xrgy624 x1hl8ikr x1t137rt x1de99jn\"\n },\n 4: {\n className: \"x1tfhd1 x9f619 x1ypdohk x3nfvp2 xrgy624 x1de99jn x1hl8ikr xaatb59\"\n },\n 2: {\n className: \"x1tfhd1 x9f619 x1ypdohk x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59\"\n },\n 6: {\n className: \"x1tfhd1 x9f619 x1ypdohk x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59\"\n },\n 1: {\n className: \"x1tfhd1 x9f619 x3nfvp2 xrgy624 x1hl8ikr x1t137rt x1de99jn xt0e3qv x1ppv7y9\"\n },\n 5: {\n className: \"x1tfhd1 x9f619 x3nfvp2 xrgy624 x1de99jn x1hl8ikr xaatb59 xt0e3qv x1ppv7y9\"\n },\n 3: {\n className: \"x1tfhd1 x9f619 x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59 xt0e3qv x1ppv7y9\"\n },\n 7: {\n className: \"x1tfhd1 x9f619 x3nfvp2 x1de99jn xrgy624 x8wkva7 xaatb59 xt0e3qv x1ppv7y9\"\n }\n }[!!state.isSelected << 2 | !!state.isFocusVisible << 1 | !!state.isDisabled << 0].className ?? '';\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, ColorSwatchPickerProps };\nexport default ColorSwatchPicker;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAA,oBAAA,OAAA;CAAA,MAAA,IAAA,EAAA,CAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,OAAA;EAC8C,KAAA,oBAAoB,EAAA,WACnD,4CACb,GAAG,KAAK;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA,EAAA,OAAA,IAAA;EAFF,KAAA,oBAAC,mBAAD;GAAqB,GAAK;GAAK,GAAM;EAEnC,CAAA;EAAI,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAFN;AAEM;;;;;AAOf,SAAA,wBAAA,IAAA;CAAA,MAAA,IAAA,EAAA,CAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,IAAA;EAA+B,CAAA,CAAA,UAAA,GAAA,SAAA;EAGF,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA;EAAA,WAAA,EAAA;EAAA,QAAA,EAAA;CAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,UAAA;EAEtB,KAAA,YAAY,oBAAC,eAAD,CAAY,CAAA;EAAG,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA,EAAA,OAAA,IAAA;EADzB,KAAA,oBAAC,uBAAD;GAAyB,GAAK;GAAkBA,WAAA;GAClD,UAAA;EAD2B,CAAA;EAEH,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAFtB;AAEsB;AAW/B,SAAS,cAAc,OAIpB;CACD,OAAO;EACL,GAAG,EACD,WAAW,qEACb;EACA,GAAG,EACD,WAAW,oEACb;EACA,GAAG,EACD,WAAW,mEACb;EACA,GAAG,EACD,WAAW,mEACb;EACA,GAAG,EACD,WAAW,6EACb;EACA,GAAG,EACD,WAAW,4EACb;EACA,GAAG,EACD,WAAW,2EACb;EACA,GAAG,EACD,WAAW,2EACb;CACF,EAAE,CAAC,CAAC,MAAM,cAAc,IAAI,CAAC,CAAC,MAAM,kBAAkB,IAAI,CAAC,CAAC,MAAM,cAAc,EAAE,CAAC,aAAa;AAClG;AACA,oBAAkB,OAAO"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { DateFieldProps, DateValue } from "react-aria-components";
|
|
3
|
+
//#region src/components/date-field/index.d.ts
|
|
4
|
+
type DateFieldProps$1<T extends DateValue> = Omit<DateFieldProps<T>, 'children' | 'className' | 'style'> & {
|
|
5
|
+
/** A function may compute the class from the field's render state. */
|
|
6
|
+
className?: DateFieldProps<T>['className'];
|
|
7
|
+
/** Supporting text under the field. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** The message shown instead of the description, which also marks the field invalid. */
|
|
10
|
+
error?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the label floats into the box's top once the field holds a
|
|
13
|
+
* value, rather than sitting above it.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
floatingLabel?: boolean;
|
|
17
|
+
/** What the field is for. Always rendered; never a placeholder. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** An icon at the box's leading end. */
|
|
20
|
+
leadingIcon?: ReactNode;
|
|
21
|
+
/** A function may compute the style from the field's render state. */
|
|
22
|
+
style?: DateFieldProps<T>['style'];
|
|
23
|
+
/** An icon at the box's trailing end. */
|
|
24
|
+
trailingIcon?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Which of the text fields page's two boxes to draw.
|
|
27
|
+
* @default 'filled'
|
|
28
|
+
*/
|
|
29
|
+
variant?: 'filled' | 'outlined';
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A date typed rather than picked: one segment per part, each its own focus
|
|
33
|
+
* stop. The value is React Aria's — pass `value` with `onChange` to control
|
|
34
|
+
* it, or `defaultValue` — as an `@internationalized/date` value from this
|
|
35
|
+
* package's `./date` subpath.
|
|
36
|
+
*
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import { CalendarDate } from '@kanso-labs/kanso-ui/date'
|
|
39
|
+
*
|
|
40
|
+
* <DateField defaultValue={new CalendarDate(2026, 9, 15)} label="Label" />
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* How many segments there are and what order they come in is the reader's
|
|
44
|
+
* locale, through React Aria's `I18nProvider` — `granularity` adds time
|
|
45
|
+
* segments, and `minValue` and `maxValue` bound what may be typed.
|
|
46
|
+
*
|
|
47
|
+
* The box, label and message are the field chrome in `src/field`, shared
|
|
48
|
+
* with every other field. The call site's `className` and `style` land on
|
|
49
|
+
* the field as a whole, which is the element a layout positions.
|
|
50
|
+
*/
|
|
51
|
+
declare function DateField$1<T extends DateValue>({ description, error, floatingLabel, isDisabled, label, leadingIcon, trailingIcon, variant, ...props }: DateFieldProps$1<T>): import("react").JSX.Element;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { type DateFieldProps$1 as DateFieldProps, DateField$1 as default };
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
|
+
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
3
|
+
import { fieldStyles, invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
|
|
4
|
+
import { FieldBox, FieldMessage, FieldValue } from "../../field/index.js";
|
|
5
|
+
import { segmentStyles } from "../../segments/styles.js";
|
|
6
|
+
import { renderSegment } from "../../segments/index.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { DateField, DateInput } from "react-aria-components";
|
|
9
|
+
//#region src/components/date-field/index.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A date typed rather than picked: one segment per part, each its own focus
|
|
12
|
+
* stop. The value is React Aria's — pass `value` with `onChange` to control
|
|
13
|
+
* it, or `defaultValue` — as an `@internationalized/date` value from this
|
|
14
|
+
* package's `./date` subpath.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { CalendarDate } from '@kanso-labs/kanso-ui/date'
|
|
18
|
+
*
|
|
19
|
+
* <DateField defaultValue={new CalendarDate(2026, 9, 15)} label="Label" />
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* How many segments there are and what order they come in is the reader's
|
|
23
|
+
* locale, through React Aria's `I18nProvider` — `granularity` adds time
|
|
24
|
+
* segments, and `minValue` and `maxValue` bound what may be typed.
|
|
25
|
+
*
|
|
26
|
+
* The box, label and message are the field chrome in `src/field`, shared
|
|
27
|
+
* with every other field. The call site's `className` and `style` land on
|
|
28
|
+
* the field as a whole, which is the element a layout positions.
|
|
29
|
+
*/
|
|
30
|
+
function DateField$1({ description, error, floatingLabel = true, isDisabled = false, label, leadingIcon, trailingIcon, variant = "filled", ...props$1 }) {
|
|
31
|
+
const validationBehavior = useFieldValidationBehavior();
|
|
32
|
+
return /* @__PURE__ */ jsxs(DateField, {
|
|
33
|
+
isDisabled,
|
|
34
|
+
isInvalid: invalidFrom(error),
|
|
35
|
+
validationBehavior,
|
|
36
|
+
...props$1,
|
|
37
|
+
...mergeStatefulStyles(props(fieldStyles.root), props$1),
|
|
38
|
+
children: [/* @__PURE__ */ jsx(FieldBox, {
|
|
39
|
+
floatingLabel,
|
|
40
|
+
isPopulated: true,
|
|
41
|
+
label,
|
|
42
|
+
leading: leadingIcon,
|
|
43
|
+
trailing: trailingIcon,
|
|
44
|
+
variant,
|
|
45
|
+
children: /* @__PURE__ */ jsx(FieldValue, { children: /* @__PURE__ */ jsx(DateInput, {
|
|
46
|
+
...props(segmentStyles.input),
|
|
47
|
+
children: renderSegment
|
|
48
|
+
}) })
|
|
49
|
+
}), /* @__PURE__ */ jsx(FieldMessage, {
|
|
50
|
+
description,
|
|
51
|
+
error
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { DateField$1 as default };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/date-field/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { DateValue, DateFieldProps as RACDateFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { DateField as RACDateField, DateInput as RACDateInput } from 'react-aria-components';\nimport { FieldBox, FieldMessage, FieldValue } from '../../field';\nimport { fieldStyles, invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { renderSegment } from '../../segments';\nimport { segmentStyles } from '../../segments/styles';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// A date typed a segment at a time, rather than picked from a calendar. The\n// box, label and message are the field chrome in `src/field`, shared with\n// every other field, so a date field on a form is the same box as the text\n// field beside it — which is what the date pickers page means by a date in a\n// text field.\n//\n// Three things are this component's own.\n//\n// **Each segment is its own focus stop, and React Aria decides how many.**\n// The order and the count come from the locale rather than from here: a\n// reader under `I18nProvider` with a British locale gets day before month,\n// and `granularity` of `minute` adds two more. So the segments are rendered\n// from what React Aria hands the input, never written out.\n//\n// **A segment not yet filled is muted, and the field still counts as\n// empty.** The placeholder text is the segment's own — `mm`, `dd`, `yyyy` —\n// and it takes the muted role so a half-typed date reads as half-typed. The\n// floating label stays down until a segment holds a real value.\n//\n// **A focused segment is a filled shape rather than a ring.** A caret cannot\n// show which of three spinbuttons has focus, since React Aria hides it — the\n// segment is what has to say so, and it does it the way a selected row does.\n\ntype DateFieldProps<T extends DateValue> = Omit<RACDateFieldProps<T>, 'children' | 'className' | 'style'> & {\n /** A function may compute the class from the field's render state. */\n className?: RACDateFieldProps<T>['className'];\n /** Supporting text under the field. */\n description?: string;\n /** The message shown instead of the description, which also marks the field invalid. */\n error?: string;\n /**\n * Whether the label floats into the box's top once the field holds a\n * value, rather than sitting above it.\n * @default true\n */\n floatingLabel?: boolean;\n /** What the field is for. Always rendered; never a placeholder. */\n label: string;\n /** An icon at the box's leading end. */\n leadingIcon?: ReactNode;\n /** A function may compute the style from the field's render state. */\n style?: RACDateFieldProps<T>['style'];\n /** An icon at the box's trailing end. */\n trailingIcon?: ReactNode;\n /**\n * Which of the text fields page's two boxes to draw.\n * @default 'filled'\n */\n variant?: 'filled' | 'outlined';\n};\n\n/**\n * A date typed rather than picked: one segment per part, each its own focus\n * stop. The value is React Aria's — pass `value` with `onChange` to control\n * it, or `defaultValue` — as an `@internationalized/date` value from this\n * package's `./date` subpath.\n *\n * ```tsx\n * import { CalendarDate } from '@kanso-labs/kanso-ui/date'\n *\n * <DateField defaultValue={new CalendarDate(2026, 9, 15)} label=\"Label\" />\n * ```\n *\n * How many segments there are and what order they come in is the reader's\n * locale, through React Aria's `I18nProvider` — `granularity` adds time\n * segments, and `minValue` and `maxValue` bound what may be typed.\n *\n * The box, label and message are the field chrome in `src/field`, shared\n * with every other field. The call site's `className` and `style` land on\n * the field as a whole, which is the element a layout positions.\n */\nfunction DateField<T extends DateValue>({\n description,\n error,\n floatingLabel = true,\n isDisabled = false,\n label,\n leadingIcon,\n trailingIcon,\n variant = 'filled',\n ...props\n}: DateFieldProps<T>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACDateField<T> isDisabled={isDisabled} isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(fieldStyles.root), props)}>\n <FieldBox floatingLabel={floatingLabel}\n // Always populated, which buys the outlined notch. The box decides\n // populated twice over — in CSS for the label's type, and in React\n // for the notch, since CSS cannot cut an outline to a width it has\n // no way to measure. React Aria renders a hidden\n // `<input type=\"date\">` carrying no placeholder, so the CSS half\n // reads as populated on its own; the React half reads React Aria's\n // input context, which a date field does not provide. Without this\n // the notch stays shut across segments already showing `mm/dd/yyyy`.\n isPopulated label={label} leading={leadingIcon} trailing={trailingIcon} variant={variant}>\n <FieldValue>\n <RACDateInput {...stylex.props(segmentStyles.input)}>\n {renderSegment}\n </RACDateInput>\n </FieldValue>\n </FieldBox>\n <FieldMessage description={description} error={error} />\n </RACDateField>;\n}\nexport type { DateFieldProps };\nexport default DateField;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,SAAS,YAA+B,EACtC,aACA,OACA,gBAAgB,MAChB,aAAa,OACb,OACA,aACA,cACA,UAAU,UACV,GAAG,WACiB;CACpB,MAAM,qBAAqB,2BAA2B;CACtD,OAAO,qBAAC,WAAD;EAA6B;EAAY,WAAW,YAAY,KAAK;EAAuB;EAAoB,GAAI;EAAO,GAAI,oBAAoB,MAAa,YAAY,IAAI,GAAG,OAAK;EAAxL,UAAA,CACH,oBAAC,UAAD;GAAyB;GAS3B,aAAA;GAAmB;GAAO,SAAS;GAAa,UAAU;GAAuB;GAC7E,UAAA,oBAAC,YAAD,EAAA,UACE,oBAAC,WAAD;IAAc,GAAI,MAAa,cAAc,KAAK;IAC/C,UAAA;GACW,CAAA,EACJ,CAAA;EACJ,CAAA,GACV,oBAAC,cAAD;GAA2B;GAAoB;EAAM,CAAA,CACzC;;AAClB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { DatePickerProps, DateValue } from "react-aria-components";
|
|
3
|
+
//#region src/components/date-picker/index.d.ts
|
|
4
|
+
type DatePickerProps$1<T extends DateValue> = Omit<DatePickerProps<T>, 'children' | 'className' | 'style'> & {
|
|
5
|
+
/** A function may compute the class from the picker's render state. */
|
|
6
|
+
className?: DatePickerProps<T>['className'];
|
|
7
|
+
/** Supporting text under the field. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** The message shown instead of the description, which also marks the field invalid. */
|
|
10
|
+
error?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the label floats into the box's top once the field holds a
|
|
13
|
+
* value, rather than sitting above it.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
floatingLabel?: boolean;
|
|
17
|
+
/** What the field is for. Always rendered; never a placeholder. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** An icon at the box's leading end. */
|
|
20
|
+
leadingIcon?: ReactNode;
|
|
21
|
+
/** A function may compute the style from the picker's render state. */
|
|
22
|
+
style?: DatePickerProps<T>['style'];
|
|
23
|
+
/**
|
|
24
|
+
* What the button that opens the calendar is called, for a screen reader.
|
|
25
|
+
* @default 'Choose a date'
|
|
26
|
+
*/
|
|
27
|
+
triggerLabel?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Which of the text fields page's two boxes to draw.
|
|
30
|
+
* @default 'filled'
|
|
31
|
+
*/
|
|
32
|
+
variant?: 'filled' | 'outlined';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A date typed into a field, or picked from a calendar behind a button. The
|
|
36
|
+
* value is React Aria's — pass `value` with `onChange` to control it, or
|
|
37
|
+
* `defaultValue` — as an `@internationalized/date` value from this package's
|
|
38
|
+
* `./date` subpath.
|
|
39
|
+
*
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { CalendarDate } from '@kanso-labs/kanso-ui/date'
|
|
42
|
+
*
|
|
43
|
+
* <DatePicker defaultValue={new CalendarDate(2026, 9, 15)} label="Label" />
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* The segments are `DateField`'s and the calendar is `Calendar`, so
|
|
47
|
+
* `granularity`, `minValue`, `maxValue` and `isDateUnavailable` all behave
|
|
48
|
+
* as they do there. Above the medium breakpoint the calendar is docked to
|
|
49
|
+
* the field; below it, it opens centred, which is the page's modal picker.
|
|
50
|
+
*
|
|
51
|
+
* The call site's `className` and `style` land on the picker as a whole,
|
|
52
|
+
* which is the element a layout positions.
|
|
53
|
+
*/
|
|
54
|
+
declare function DatePicker$1<T extends DateValue>({ description, error, floatingLabel, isDisabled, label, leadingIcon, triggerLabel, variant, ...props }: DatePickerProps$1<T>): import("react").JSX.Element;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { type DatePickerProps$1 as DatePickerProps, DatePicker$1 as default };
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
|
|
2
|
+
import { mergeStatefulStyles } from "../../styles/merge.js";
|
|
3
|
+
import { CalendarGlyph } from "../../glyphs/index.js";
|
|
4
|
+
import Calendar$1 from "../calendar/index.js";
|
|
5
|
+
import { fieldStyles, invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
|
|
6
|
+
import { FieldBox, FieldMessage, FieldValue } from "../../field/index.js";
|
|
7
|
+
import { overlay } from "../../styles/overlay.js";
|
|
8
|
+
import { segmentStyles } from "../../segments/styles.js";
|
|
9
|
+
import { renderSegment } from "../../segments/index.js";
|
|
10
|
+
import { picker, triggerClassName } from "../../styles/picker.js";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Button, DateInput, DatePicker, Dialog, Group, Popover } from "react-aria-components";
|
|
13
|
+
//#region src/components/date-picker/index.tsx
|
|
14
|
+
/**
|
|
15
|
+
* A date typed into a field, or picked from a calendar behind a button. The
|
|
16
|
+
* value is React Aria's — pass `value` with `onChange` to control it, or
|
|
17
|
+
* `defaultValue` — as an `@internationalized/date` value from this package's
|
|
18
|
+
* `./date` subpath.
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { CalendarDate } from '@kanso-labs/kanso-ui/date'
|
|
22
|
+
*
|
|
23
|
+
* <DatePicker defaultValue={new CalendarDate(2026, 9, 15)} label="Label" />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The segments are `DateField`'s and the calendar is `Calendar`, so
|
|
27
|
+
* `granularity`, `minValue`, `maxValue` and `isDateUnavailable` all behave
|
|
28
|
+
* as they do there. Above the medium breakpoint the calendar is docked to
|
|
29
|
+
* the field; below it, it opens centred, which is the page's modal picker.
|
|
30
|
+
*
|
|
31
|
+
* The call site's `className` and `style` land on the picker as a whole,
|
|
32
|
+
* which is the element a layout positions.
|
|
33
|
+
*/
|
|
34
|
+
function DatePicker$1({ description, error, floatingLabel = true, isDisabled = false, label, leadingIcon, triggerLabel = "Choose a date", variant = "filled", ...props$1 }) {
|
|
35
|
+
const validationBehavior = useFieldValidationBehavior();
|
|
36
|
+
return /* @__PURE__ */ jsxs(DatePicker, {
|
|
37
|
+
isDisabled,
|
|
38
|
+
isInvalid: invalidFrom(error),
|
|
39
|
+
validationBehavior,
|
|
40
|
+
...props$1,
|
|
41
|
+
...mergeStatefulStyles(props(fieldStyles.root), props$1),
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsx(FieldBox, {
|
|
44
|
+
floatingLabel,
|
|
45
|
+
isPopulated: true,
|
|
46
|
+
label,
|
|
47
|
+
leading: leadingIcon,
|
|
48
|
+
variant,
|
|
49
|
+
children: /* @__PURE__ */ jsx(FieldValue, { children: /* @__PURE__ */ jsxs(Group, {
|
|
50
|
+
...props(picker.group),
|
|
51
|
+
children: [/* @__PURE__ */ jsx(DateInput, {
|
|
52
|
+
...props(segmentStyles.input),
|
|
53
|
+
children: renderSegment
|
|
54
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
55
|
+
"aria-label": triggerLabel,
|
|
56
|
+
className: triggerClassName,
|
|
57
|
+
children: /* @__PURE__ */ jsx(CalendarGlyph, { ...props(picker.triggerGlyph) })
|
|
58
|
+
})]
|
|
59
|
+
}) })
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
62
|
+
description,
|
|
63
|
+
error
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ jsx(Popover, {
|
|
66
|
+
...props(overlay.popup, picker.popover),
|
|
67
|
+
children: /* @__PURE__ */ jsx(Dialog, { children: /* @__PURE__ */ jsx(Calendar$1, { "aria-label": label }) })
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { DatePicker$1 as default };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=index.js.map
|