@panneau/ui 5.0.0-alpha.6 → 5.0.0-alpha.7
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/README.md +24 -1
- package/dist/alert/Alert.js +108 -40
- package/dist/alert/Alert.js.map +1 -1
- package/dist/alert/tokens.js.map +1 -1
- package/dist/badge/Badge.js +34 -6
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/tokens.js.map +1 -1
- package/dist/button/Button.js +111 -17
- package/dist/button/Button.js.map +1 -1
- package/dist/button/tokens.js.map +1 -1
- package/dist/card/Card.js +76 -23
- package/dist/card/Card.js.map +1 -1
- package/dist/card/tokens.js.map +1 -1
- package/dist/checkbox/Checkbox.js +86 -25
- package/dist/checkbox/Checkbox.js.map +1 -1
- package/dist/checkbox/ChoiceChrome.js +82 -21
- package/dist/checkbox/ChoiceChrome.js.map +1 -1
- package/dist/checkbox/tokens.js.map +1 -1
- package/dist/combo-box/ComboBox.js +291 -79
- package/dist/combo-box/ComboBox.js.map +1 -1
- package/dist/command-palette/CommandPalette.js +463 -160
- package/dist/command-palette/CommandPalette.js.map +1 -1
- package/dist/command-palette/match.js.map +1 -1
- package/dist/command-palette/tokens.js.map +1 -1
- package/dist/command-palette/useCommandShortcut.js +31 -12
- package/dist/command-palette/useCommandShortcut.js.map +1 -1
- package/dist/container/Container.js +48 -5
- package/dist/container/Container.js.map +1 -1
- package/dist/container/tokens.js.map +1 -1
- package/dist/date-picker/DatePicker.js +234 -73
- package/dist/date-picker/DatePicker.js.map +1 -1
- package/dist/date-picker/calendarTokens.js.map +1 -1
- package/dist/dialog/Dialog.js +161 -45
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/tokens.js.map +1 -1
- package/dist/disclosure/Disclosure.js +132 -28
- package/dist/disclosure/Disclosure.js.map +1 -1
- package/dist/disclosure/tokens.js.map +1 -1
- package/dist/divider/Divider.js +55 -11
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/tokens.js.map +1 -1
- package/dist/field/FieldParts.js +69 -15
- package/dist/field/FieldParts.js.map +1 -1
- package/dist/field/Fieldset.js +99 -32
- package/dist/field/Fieldset.js.map +1 -1
- package/dist/field/inputTokens.js.map +1 -1
- package/dist/field/tokens.js.map +1 -1
- package/dist/grid/Grid.js +123 -14
- package/dist/grid/Grid.js.map +1 -1
- package/dist/grid/tokens.js.map +1 -1
- package/dist/heading/Heading.js +41 -6
- package/dist/heading/Heading.js.map +1 -1
- package/dist/heading/tokens.js.map +1 -1
- package/dist/icon/Icon.js +36 -11
- package/dist/icon/Icon.js.map +1 -1
- package/dist/icon/lucideIconLoader.js.map +1 -1
- package/dist/icon/namedIcons.js +87 -26
- package/dist/icon/namedIcons.js.map +1 -1
- package/dist/icon-button/IconButton.js +70 -13
- package/dist/icon-button/IconButton.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/inline/Inline.js +65 -7
- package/dist/inline/Inline.js.map +1 -1
- package/dist/inline/tokens.js.map +1 -1
- package/dist/intl/usePanneauIntl.js.map +1 -1
- package/dist/layout/responsive.js.map +1 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/menu/Menu.js +170 -44
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/tokens.js.map +1 -1
- package/dist/number-input/NumberInput.js +232 -60
- package/dist/number-input/NumberInput.js.map +1 -1
- package/dist/number-input/tokens.js.map +1 -1
- package/dist/pill-trigger/PillTrigger.js +76 -20
- package/dist/pill-trigger/PillTrigger.js.map +1 -1
- package/dist/pill-trigger/tokens.js.map +1 -1
- package/dist/popover/Popover.js +109 -18
- package/dist/popover/Popover.js.map +1 -1
- package/dist/popover/tokens.js.map +1 -1
- package/dist/prose/Prose.js +36 -5
- package/dist/prose/Prose.js.map +1 -1
- package/dist/prose/tokens.js.map +1 -1
- package/dist/radio-group/RadioGroup.js +211 -61
- package/dist/radio-group/RadioGroup.js.map +1 -1
- package/dist/radio-group/tokens.js.map +1 -1
- package/dist/root/PanneauRoot.js +197 -49
- package/dist/root/PanneauRoot.js.map +1 -1
- package/dist/root/ThemeScope.js +107 -26
- package/dist/root/ThemeScope.js.map +1 -1
- package/dist/segmented-control/SegmentedControl.js +120 -22
- package/dist/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/segmented-control/tokens.js.map +1 -1
- package/dist/select/Select.js +298 -92
- package/dist/select/Select.js.map +1 -1
- package/dist/select/listBoxTokens.js.map +1 -1
- package/dist/skeleton/LoadingRegion.d.ts +16 -0
- package/dist/skeleton/LoadingRegion.d.ts.map +1 -0
- package/dist/skeleton/LoadingRegion.js +65 -0
- package/dist/skeleton/LoadingRegion.js.map +1 -0
- package/dist/skeleton/Skeleton.css +62 -0
- package/dist/skeleton/Skeleton.d.ts +25 -0
- package/dist/skeleton/Skeleton.d.ts.map +1 -0
- package/dist/skeleton/Skeleton.js +106 -0
- package/dist/skeleton/Skeleton.js.map +1 -0
- package/dist/skeleton/Skeleton.module.js +22 -0
- package/dist/skeleton/Skeleton.module.js.map +1 -0
- package/dist/skeleton/tokens.d.ts +3 -0
- package/dist/skeleton/tokens.d.ts.map +1 -0
- package/dist/skeleton/tokens.js +15 -0
- package/dist/skeleton/tokens.js.map +1 -0
- package/dist/slider/Slider.js +222 -44
- package/dist/slider/Slider.js.map +1 -1
- package/dist/spinner/Spinner.js +49 -9
- package/dist/spinner/Spinner.js.map +1 -1
- package/dist/spinner/tokens.js.map +1 -1
- package/dist/stack/Stack.js +60 -7
- package/dist/stack/Stack.js.map +1 -1
- package/dist/stack/tokens.js.map +1 -1
- package/dist/switch/Switch.js +68 -11
- package/dist/switch/Switch.js.map +1 -1
- package/dist/switch/tokens.js.map +1 -1
- package/dist/tabs/Tabs.js +1 -1
- package/dist/tabs/Tabs.js.map +1 -1
- package/dist/tabs/tokens.js.map +1 -1
- package/dist/tags-input/TagsInput.js +277 -121
- package/dist/tags-input/TagsInput.js.map +1 -1
- package/dist/text/Text.js +70 -5
- package/dist/text/Text.js.map +1 -1
- package/dist/text/tokens.js.map +1 -1
- package/dist/text-area/TextArea.js +135 -28
- package/dist/text-area/TextArea.js.map +1 -1
- package/dist/text-input/TextInput.js +164 -49
- package/dist/text-input/TextInput.js.map +1 -1
- package/dist/theme/bootstrap.js.map +1 -1
- package/dist/theme/chartColors.js.map +1 -1
- package/dist/theme/checkTheme.js.map +1 -1
- package/dist/theme/cli.js.map +1 -1
- package/dist/theme/color.js.map +1 -1
- package/dist/theme/colorVision.js.map +1 -1
- package/dist/theme/componentTokens.js.map +1 -1
- package/dist/theme/components.d.ts +1 -0
- package/dist/theme/components.d.ts.map +1 -1
- package/dist/theme/components.js +2 -0
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/defineTheme.js.map +1 -1
- package/dist/theme/fonts.js.map +1 -1
- package/dist/theme/semanticTokens.js.map +1 -1
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/toneClass.js.map +1 -1
- package/dist/theme/tones.js.map +1 -1
- package/dist/time-input/TimeInput.js +138 -31
- package/dist/time-input/TimeInput.js.map +1 -1
- package/dist/toast/Toast.js +1 -1
- package/dist/toast/Toast.js.map +1 -1
- package/dist/toast/tokens.js.map +1 -1
- package/dist/tooltip/Tooltip.js +38 -8
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/tokens.js.map +1 -1
- package/dist/utils/cx.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,38 +2,145 @@ import { cx } from "../utils/cx.js";
|
|
|
2
2
|
import Field_module_default from "../field/Field.module.js";
|
|
3
3
|
import { FieldDescription, FieldErrors, FieldLabel } from "../field/FieldParts.js";
|
|
4
4
|
import TextArea_module_default from "./TextArea.module.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
5
6
|
import { TextArea, TextField } from "react-aria-components";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region src/text-area/TextArea.tsx
|
|
8
9
|
/** A multi-line text input with its label, description and errors. */
|
|
9
|
-
function TextArea$1(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]
|
|
36
|
-
|
|
10
|
+
function TextArea$1(t0) {
|
|
11
|
+
const $ = c(42);
|
|
12
|
+
let className;
|
|
13
|
+
let description;
|
|
14
|
+
let descriptionClassName;
|
|
15
|
+
let errorsClassName;
|
|
16
|
+
let isRequired;
|
|
17
|
+
let label;
|
|
18
|
+
let labelClassName;
|
|
19
|
+
let placeholder;
|
|
20
|
+
let props;
|
|
21
|
+
let t1;
|
|
22
|
+
let t2;
|
|
23
|
+
let textAreaClassName;
|
|
24
|
+
if ($[0] !== t0) {
|
|
25
|
+
({label, description, errors: t1, placeholder, rows: t2, className, labelClassName, descriptionClassName, errorsClassName, textAreaClassName, isRequired, ...props} = t0);
|
|
26
|
+
$[0] = t0;
|
|
27
|
+
$[1] = className;
|
|
28
|
+
$[2] = description;
|
|
29
|
+
$[3] = descriptionClassName;
|
|
30
|
+
$[4] = errorsClassName;
|
|
31
|
+
$[5] = isRequired;
|
|
32
|
+
$[6] = label;
|
|
33
|
+
$[7] = labelClassName;
|
|
34
|
+
$[8] = placeholder;
|
|
35
|
+
$[9] = props;
|
|
36
|
+
$[10] = t1;
|
|
37
|
+
$[11] = t2;
|
|
38
|
+
$[12] = textAreaClassName;
|
|
39
|
+
} else {
|
|
40
|
+
className = $[1];
|
|
41
|
+
description = $[2];
|
|
42
|
+
descriptionClassName = $[3];
|
|
43
|
+
errorsClassName = $[4];
|
|
44
|
+
isRequired = $[5];
|
|
45
|
+
label = $[6];
|
|
46
|
+
labelClassName = $[7];
|
|
47
|
+
placeholder = $[8];
|
|
48
|
+
props = $[9];
|
|
49
|
+
t1 = $[10];
|
|
50
|
+
t2 = $[11];
|
|
51
|
+
textAreaClassName = $[12];
|
|
52
|
+
}
|
|
53
|
+
let t3;
|
|
54
|
+
if ($[13] !== t1) {
|
|
55
|
+
t3 = t1 === void 0 ? [] : t1;
|
|
56
|
+
$[13] = t1;
|
|
57
|
+
$[14] = t3;
|
|
58
|
+
} else t3 = $[14];
|
|
59
|
+
const errors = t3;
|
|
60
|
+
const rows = t2 === void 0 ? 4 : t2;
|
|
61
|
+
const t4 = errors.length > 0;
|
|
62
|
+
let t5;
|
|
63
|
+
if ($[15] !== className) {
|
|
64
|
+
t5 = cx("panneau-text-area", Field_module_default.field, className);
|
|
65
|
+
$[15] = className;
|
|
66
|
+
$[16] = t5;
|
|
67
|
+
} else t5 = $[16];
|
|
68
|
+
let t6;
|
|
69
|
+
if ($[17] !== isRequired || $[18] !== label || $[19] !== labelClassName) {
|
|
70
|
+
t6 = /* @__PURE__ */ jsx(FieldLabel, {
|
|
71
|
+
isRequired,
|
|
72
|
+
className: labelClassName,
|
|
73
|
+
children: label
|
|
74
|
+
});
|
|
75
|
+
$[17] = isRequired;
|
|
76
|
+
$[18] = label;
|
|
77
|
+
$[19] = labelClassName;
|
|
78
|
+
$[20] = t6;
|
|
79
|
+
} else t6 = $[20];
|
|
80
|
+
let t7;
|
|
81
|
+
if ($[21] !== textAreaClassName) {
|
|
82
|
+
t7 = cx(Field_module_default.control, TextArea_module_default.control, textAreaClassName);
|
|
83
|
+
$[21] = textAreaClassName;
|
|
84
|
+
$[22] = t7;
|
|
85
|
+
} else t7 = $[22];
|
|
86
|
+
let t8;
|
|
87
|
+
if ($[23] !== placeholder || $[24] !== rows || $[25] !== t7) {
|
|
88
|
+
t8 = /* @__PURE__ */ jsx(TextArea, {
|
|
89
|
+
placeholder,
|
|
90
|
+
rows,
|
|
91
|
+
className: t7
|
|
92
|
+
});
|
|
93
|
+
$[23] = placeholder;
|
|
94
|
+
$[24] = rows;
|
|
95
|
+
$[25] = t7;
|
|
96
|
+
$[26] = t8;
|
|
97
|
+
} else t8 = $[26];
|
|
98
|
+
let t9;
|
|
99
|
+
if ($[27] !== description || $[28] !== descriptionClassName) {
|
|
100
|
+
t9 = /* @__PURE__ */ jsx(FieldDescription, {
|
|
101
|
+
className: descriptionClassName,
|
|
102
|
+
children: description
|
|
103
|
+
});
|
|
104
|
+
$[27] = description;
|
|
105
|
+
$[28] = descriptionClassName;
|
|
106
|
+
$[29] = t9;
|
|
107
|
+
} else t9 = $[29];
|
|
108
|
+
let t10;
|
|
109
|
+
if ($[30] !== errors || $[31] !== errorsClassName) {
|
|
110
|
+
t10 = /* @__PURE__ */ jsx(FieldErrors, {
|
|
111
|
+
errors,
|
|
112
|
+
className: errorsClassName
|
|
113
|
+
});
|
|
114
|
+
$[30] = errors;
|
|
115
|
+
$[31] = errorsClassName;
|
|
116
|
+
$[32] = t10;
|
|
117
|
+
} else t10 = $[32];
|
|
118
|
+
let t11;
|
|
119
|
+
if ($[33] !== isRequired || $[34] !== props || $[35] !== t10 || $[36] !== t4 || $[37] !== t5 || $[38] !== t6 || $[39] !== t8 || $[40] !== t9) {
|
|
120
|
+
t11 = /* @__PURE__ */ jsxs(TextField, {
|
|
121
|
+
...props,
|
|
122
|
+
isRequired,
|
|
123
|
+
isInvalid: t4,
|
|
124
|
+
validationBehavior: "aria",
|
|
125
|
+
className: t5,
|
|
126
|
+
children: [
|
|
127
|
+
t6,
|
|
128
|
+
t8,
|
|
129
|
+
t9,
|
|
130
|
+
t10
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
$[33] = isRequired;
|
|
134
|
+
$[34] = props;
|
|
135
|
+
$[35] = t10;
|
|
136
|
+
$[36] = t4;
|
|
137
|
+
$[37] = t5;
|
|
138
|
+
$[38] = t6;
|
|
139
|
+
$[39] = t8;
|
|
140
|
+
$[40] = t9;
|
|
141
|
+
$[41] = t11;
|
|
142
|
+
} else t11 = $[41];
|
|
143
|
+
return t11;
|
|
37
144
|
}
|
|
38
145
|
//#endregion
|
|
39
146
|
export { TextArea$1 as TextArea };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","names":["TextArea","fieldStyles","
|
|
1
|
+
{"version":3,"file":"TextArea.js","names":["TextArea","AriaTextArea","TextFieldProps","AriaTextFieldProps","TextField","FieldChromeProps","FieldDescription","FieldErrors","FieldLabel","fieldStyles","cx","styles","TextAreaProps","Omit","placeholder","rows","textAreaClassName","t0","$","_c","className","description","descriptionClassName","errorsClassName","isRequired","label","labelClassName","props","t1","t2","errors","t3","undefined","t4","length","t5","field","t6","t7","control","t8","t9","t10","t11","TextArea","_c","fieldStyles","styles","AriaTextArea"],"sources":["../../src/text-area/TextArea.tsx"],"sourcesContent":["import {\n TextArea as AriaTextArea,\n type TextFieldProps as AriaTextFieldProps,\n TextField,\n} from 'react-aria-components';\n\nimport {\n type FieldChromeProps,\n FieldDescription,\n FieldErrors,\n FieldLabel,\n fieldStyles,\n} from '../field/FieldParts';\nimport { cx } from '../utils/cx';\nimport styles from './TextArea.module.css';\n\nexport interface TextAreaProps\n extends\n Omit<AriaTextFieldProps, 'className' | 'style' | 'children' | 'isInvalid' | 'validate'>,\n FieldChromeProps {\n placeholder?: string;\n /** Visible lines of text. Defaults to 4. */\n rows?: number;\n textAreaClassName?: string;\n}\n\n/** A multi-line text input with its label, description and errors. */\nexport function TextArea({\n label,\n description,\n errors = [],\n placeholder,\n rows = 4,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n textAreaClassName,\n isRequired,\n ...props\n}: TextAreaProps) {\n return (\n <TextField\n {...props}\n isRequired={isRequired}\n isInvalid={errors.length > 0}\n validationBehavior=\"aria\"\n className={cx('panneau-text-area', fieldStyles.field, className)}\n >\n <FieldLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FieldLabel>\n <AriaTextArea\n placeholder={placeholder}\n rows={rows}\n className={cx(fieldStyles.control, styles.control, textAreaClassName)}\n />\n <FieldDescription className={descriptionClassName}>{description}</FieldDescription>\n <FieldErrors errors={errors} className={errorsClassName} />\n </TextField>\n );\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAOA,WAAAiB,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAZ;CAAA,IAAAa;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAb;CAAA,IAAAE,EAAA,OAAAD,IAAA;EAAkB,CAAA,CAAAQ,OAAAJ,aAAAS,QAAAF,IAAAd,aAAAC,MAAAc,IAAAT,WAAAM,gBAAAJ,sBAAAC,iBAAAP,mBAAAQ,YAAA,GAAAG,SAAAV;EAaTC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAJ;EAAAI,EAAA,KAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAF;CAAA,OAAA;EAAAI,YAAAF,EAAA;EAAAG,cAAAH,EAAA;EAAAI,uBAAAJ,EAAA;EAAAK,kBAAAL,EAAA;EAAAM,aAAAN,EAAA;EAAAO,QAAAP,EAAA;EAAAQ,iBAAAR,EAAA;EAAAJ,cAAAI,EAAA;EAAAS,QAAAT,EAAA;EAAAU,KAAAV,EAAA;EAAAW,KAAAX,EAAA;EAAAF,oBAAAE,EAAA;CAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAU,IAAA;EAVZG,KAAAH,OAAAI,KAAAA,IAAA,CAAA,IAAAJ;EAAWV,EAAA,MAAAU;EAAAV,EAAA,MAAAa;CAA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,EAAA,MAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,IAAAwB;CAAA,IAAAxB,EAAA,QAAAY,UAAAZ,EAAA,QAAAK,iBAAA;EACnFmB,MAAA,oBAAC,aAAD;GAAqBZ;GAAmBP,WAAAA;EAAe,CAAA;EAAIL,EAAA,MAAAY;EAAAZ,EAAA,MAAAK;EAAAL,EAAA,MAAAwB;CAAA,OAAAA,MAAAxB,EAAA;CAAA,IAAAyB;CAAA,IAAAzB,EAAA,QAAAM,cAAAN,EAAA,QAAAS,SAAAT,EAAA,QAAAwB,OAAAxB,EAAA,QAAAe,MAAAf,EAAA,QAAAiB,MAAAjB,EAAA,QAAAmB,MAAAnB,EAAA,QAAAsB,MAAAtB,EAAA,QAAAuB,IAAA;EAhB/DE,MAAA,qBAAC,WAAD;GAAU,GACFhB;GACQH;GACD,WAAAS;GACQ,oBAAA;GACR,WAAAE;GALf,UAAA;IAOIE;IAGAG;IAKAC;IACAC;GAhBM;;EAiBExB,EAAA,MAAAM;EAAAN,EAAA,MAAAS;EAAAT,EAAA,MAAAwB;EAAAxB,EAAA,MAAAe;EAAAf,EAAA,MAAAiB;EAAAjB,EAAA,MAAAmB;EAAAnB,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;EAAAvB,EAAA,MAAAyB;CAAA,OAAAA,MAAAzB,EAAA;CAAA,OAjBZyB;AAiBY"}
|
|
@@ -1,61 +1,176 @@
|
|
|
1
1
|
import { cx } from "../utils/cx.js";
|
|
2
2
|
import Field_module_default from "../field/Field.module.js";
|
|
3
3
|
import { FieldDescription, FieldErrors, FieldLabel } from "../field/FieldParts.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import { Group, Input, TextField } from "react-aria-components";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
//#region src/text-input/TextInput.tsx
|
|
7
8
|
/** A single-line text input with its label, description and errors. */
|
|
8
|
-
function TextInput(
|
|
9
|
+
function TextInput(t0) {
|
|
10
|
+
const $ = c(50);
|
|
11
|
+
let className;
|
|
12
|
+
let controlClassName;
|
|
13
|
+
let description;
|
|
14
|
+
let descriptionClassName;
|
|
15
|
+
let errorsClassName;
|
|
16
|
+
let inputClassName;
|
|
17
|
+
let isReadOnly;
|
|
18
|
+
let isRequired;
|
|
19
|
+
let label;
|
|
20
|
+
let labelClassName;
|
|
21
|
+
let placeholder;
|
|
22
|
+
let prefix;
|
|
23
|
+
let props;
|
|
24
|
+
let suffix;
|
|
25
|
+
let t1;
|
|
26
|
+
if ($[0] !== t0) {
|
|
27
|
+
({label, description, errors: t1, placeholder, prefix, suffix, className, labelClassName, descriptionClassName, errorsClassName, controlClassName, inputClassName, isRequired, isReadOnly, ...props} = t0);
|
|
28
|
+
$[0] = t0;
|
|
29
|
+
$[1] = className;
|
|
30
|
+
$[2] = controlClassName;
|
|
31
|
+
$[3] = description;
|
|
32
|
+
$[4] = descriptionClassName;
|
|
33
|
+
$[5] = errorsClassName;
|
|
34
|
+
$[6] = inputClassName;
|
|
35
|
+
$[7] = isReadOnly;
|
|
36
|
+
$[8] = isRequired;
|
|
37
|
+
$[9] = label;
|
|
38
|
+
$[10] = labelClassName;
|
|
39
|
+
$[11] = placeholder;
|
|
40
|
+
$[12] = prefix;
|
|
41
|
+
$[13] = props;
|
|
42
|
+
$[14] = suffix;
|
|
43
|
+
$[15] = t1;
|
|
44
|
+
} else {
|
|
45
|
+
className = $[1];
|
|
46
|
+
controlClassName = $[2];
|
|
47
|
+
description = $[3];
|
|
48
|
+
descriptionClassName = $[4];
|
|
49
|
+
errorsClassName = $[5];
|
|
50
|
+
inputClassName = $[6];
|
|
51
|
+
isReadOnly = $[7];
|
|
52
|
+
isRequired = $[8];
|
|
53
|
+
label = $[9];
|
|
54
|
+
labelClassName = $[10];
|
|
55
|
+
placeholder = $[11];
|
|
56
|
+
prefix = $[12];
|
|
57
|
+
props = $[13];
|
|
58
|
+
suffix = $[14];
|
|
59
|
+
t1 = $[15];
|
|
60
|
+
}
|
|
61
|
+
let t2;
|
|
62
|
+
if ($[16] !== t1) {
|
|
63
|
+
t2 = t1 === void 0 ? [] : t1;
|
|
64
|
+
$[16] = t1;
|
|
65
|
+
$[17] = t2;
|
|
66
|
+
} else t2 = $[17];
|
|
67
|
+
const errors = t2;
|
|
9
68
|
const invalid = errors.length > 0;
|
|
10
69
|
const adorned = prefix !== void 0 || suffix !== void 0;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
]
|
|
58
|
-
|
|
70
|
+
let t3;
|
|
71
|
+
if ($[18] !== className) {
|
|
72
|
+
t3 = cx("panneau-text-input", Field_module_default.field, className);
|
|
73
|
+
$[18] = className;
|
|
74
|
+
$[19] = t3;
|
|
75
|
+
} else t3 = $[19];
|
|
76
|
+
let t4;
|
|
77
|
+
if ($[20] !== isRequired || $[21] !== label || $[22] !== labelClassName) {
|
|
78
|
+
t4 = /* @__PURE__ */ jsx(FieldLabel, {
|
|
79
|
+
isRequired,
|
|
80
|
+
className: labelClassName,
|
|
81
|
+
children: label
|
|
82
|
+
});
|
|
83
|
+
$[20] = isRequired;
|
|
84
|
+
$[21] = label;
|
|
85
|
+
$[22] = labelClassName;
|
|
86
|
+
$[23] = t4;
|
|
87
|
+
} else t4 = $[23];
|
|
88
|
+
let t5;
|
|
89
|
+
if ($[24] !== adorned || $[25] !== controlClassName || $[26] !== inputClassName || $[27] !== invalid || $[28] !== isReadOnly || $[29] !== placeholder || $[30] !== prefix || $[31] !== props || $[32] !== suffix) {
|
|
90
|
+
t5 = adorned ? /* @__PURE__ */ jsxs(Group, {
|
|
91
|
+
className: cx(Field_module_default.control, controlClassName),
|
|
92
|
+
"data-invalid": invalid || void 0,
|
|
93
|
+
"data-readonly": isReadOnly || void 0,
|
|
94
|
+
isDisabled: props.isDisabled,
|
|
95
|
+
children: [
|
|
96
|
+
prefix !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: Field_module_default.adornment,
|
|
98
|
+
"data-text": typeof prefix === "string" || void 0,
|
|
99
|
+
children: prefix
|
|
100
|
+
}) : null,
|
|
101
|
+
/* @__PURE__ */ jsx(Input, {
|
|
102
|
+
placeholder,
|
|
103
|
+
className: cx(Field_module_default.bare, inputClassName)
|
|
104
|
+
}),
|
|
105
|
+
suffix !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
106
|
+
className: Field_module_default.adornment,
|
|
107
|
+
"data-text": typeof suffix === "string" || void 0,
|
|
108
|
+
children: suffix
|
|
109
|
+
}) : null
|
|
110
|
+
]
|
|
111
|
+
}) : /* @__PURE__ */ jsx(Input, {
|
|
112
|
+
placeholder,
|
|
113
|
+
className: cx(Field_module_default.control, controlClassName, inputClassName)
|
|
114
|
+
});
|
|
115
|
+
$[24] = adorned;
|
|
116
|
+
$[25] = controlClassName;
|
|
117
|
+
$[26] = inputClassName;
|
|
118
|
+
$[27] = invalid;
|
|
119
|
+
$[28] = isReadOnly;
|
|
120
|
+
$[29] = placeholder;
|
|
121
|
+
$[30] = prefix;
|
|
122
|
+
$[31] = props;
|
|
123
|
+
$[32] = suffix;
|
|
124
|
+
$[33] = t5;
|
|
125
|
+
} else t5 = $[33];
|
|
126
|
+
let t6;
|
|
127
|
+
if ($[34] !== description || $[35] !== descriptionClassName) {
|
|
128
|
+
t6 = /* @__PURE__ */ jsx(FieldDescription, {
|
|
129
|
+
className: descriptionClassName,
|
|
130
|
+
children: description
|
|
131
|
+
});
|
|
132
|
+
$[34] = description;
|
|
133
|
+
$[35] = descriptionClassName;
|
|
134
|
+
$[36] = t6;
|
|
135
|
+
} else t6 = $[36];
|
|
136
|
+
let t7;
|
|
137
|
+
if ($[37] !== errors || $[38] !== errorsClassName) {
|
|
138
|
+
t7 = /* @__PURE__ */ jsx(FieldErrors, {
|
|
139
|
+
errors,
|
|
140
|
+
className: errorsClassName
|
|
141
|
+
});
|
|
142
|
+
$[37] = errors;
|
|
143
|
+
$[38] = errorsClassName;
|
|
144
|
+
$[39] = t7;
|
|
145
|
+
} else t7 = $[39];
|
|
146
|
+
let t8;
|
|
147
|
+
if ($[40] !== invalid || $[41] !== isReadOnly || $[42] !== isRequired || $[43] !== props || $[44] !== t3 || $[45] !== t4 || $[46] !== t5 || $[47] !== t6 || $[48] !== t7) {
|
|
148
|
+
t8 = /* @__PURE__ */ jsxs(TextField, {
|
|
149
|
+
...props,
|
|
150
|
+
isRequired,
|
|
151
|
+
isReadOnly,
|
|
152
|
+
isInvalid: invalid,
|
|
153
|
+
validationBehavior: "aria",
|
|
154
|
+
className: t3,
|
|
155
|
+
children: [
|
|
156
|
+
t4,
|
|
157
|
+
t5,
|
|
158
|
+
t6,
|
|
159
|
+
t7
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
$[40] = invalid;
|
|
163
|
+
$[41] = isReadOnly;
|
|
164
|
+
$[42] = isRequired;
|
|
165
|
+
$[43] = props;
|
|
166
|
+
$[44] = t3;
|
|
167
|
+
$[45] = t4;
|
|
168
|
+
$[46] = t5;
|
|
169
|
+
$[47] = t6;
|
|
170
|
+
$[48] = t7;
|
|
171
|
+
$[49] = t8;
|
|
172
|
+
} else t8 = $[49];
|
|
173
|
+
return t8;
|
|
59
174
|
}
|
|
60
175
|
//#endregion
|
|
61
176
|
export { TextInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","names":["styles"],"sources":["../../src/text-input/TextInput.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n type TextFieldProps as AriaTextFieldProps,\n Group,\n Input,\n TextField,\n} from 'react-aria-components';\n\nimport {\n type FieldChromeProps,\n FieldDescription,\n FieldErrors,\n FieldLabel,\n fieldStyles as styles,\n} from '../field/FieldParts';\nimport { cx } from '../utils/cx';\n\nexport interface TextInputProps\n extends\n Omit<\n AriaTextFieldProps,\n 'className' | 'style' | 'children' | 'isInvalid' | 'validate' | 'type'\n >,\n FieldChromeProps {\n type?: 'text' | 'email' | 'url' | 'tel' | 'password' | 'search';\n placeholder?: string;\n /** Content before the text, inside the control: a unit, a URL prefix, an icon. */\n prefix?: ReactNode;\n /** Content after the text, inside the control. */\n suffix?: ReactNode;\n /** Class name of the control (the box around the text). */\n controlClassName?: string;\n inputClassName?: string;\n}\n\n/** A single-line text input with its label, description and errors. */\nexport function TextInput({\n label,\n description,\n errors = [],\n placeholder,\n prefix,\n suffix,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n controlClassName,\n inputClassName,\n isRequired,\n isReadOnly,\n ...props\n}: TextInputProps) {\n const invalid = errors.length > 0;\n const adorned = prefix !== undefined || suffix !== undefined;\n return (\n <TextField\n {...props}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n isInvalid={invalid}\n validationBehavior=\"aria\"\n className={cx('panneau-text-input', styles.field, className)}\n >\n <FieldLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FieldLabel>\n {adorned ? (\n <Group\n className={cx(styles.control, controlClassName)}\n data-invalid={invalid || undefined}\n data-readonly={isReadOnly || undefined}\n isDisabled={props.isDisabled}\n >\n {prefix !== undefined ? (\n <span\n className={styles.adornment}\n data-text={typeof prefix === 'string' || undefined}\n >\n {prefix}\n </span>\n ) : null}\n <Input placeholder={placeholder} className={cx(styles.bare, inputClassName)} />\n {suffix !== undefined ? (\n <span\n className={styles.adornment}\n data-text={typeof suffix === 'string' || undefined}\n >\n {suffix}\n </span>\n ) : null}\n </Group>\n ) : (\n <Input\n placeholder={placeholder}\n className={cx(styles.control, controlClassName, inputClassName)}\n />\n )}\n <FieldDescription className={descriptionClassName}>{description}</FieldDescription>\n <FieldErrors errors={errors} className={errorsClassName} />\n </TextField>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextInput.js","names":["ReactNode","TextFieldProps","AriaTextFieldProps","Group","Input","TextField","FieldChromeProps","FieldDescription","FieldErrors","FieldLabel","fieldStyles","styles","cx","TextInputProps","Omit","type","placeholder","prefix","suffix","controlClassName","inputClassName","TextInput","t0","$","_c","className","description","descriptionClassName","errorsClassName","isReadOnly","isRequired","label","labelClassName","props","t1","errors","t2","undefined","invalid","length","adorned","t3","field","t4","t5","control","isDisabled","adornment","bare","t6","t7","t8","_c","styles"],"sources":["../../src/text-input/TextInput.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n type TextFieldProps as AriaTextFieldProps,\n Group,\n Input,\n TextField,\n} from 'react-aria-components';\n\nimport {\n type FieldChromeProps,\n FieldDescription,\n FieldErrors,\n FieldLabel,\n fieldStyles as styles,\n} from '../field/FieldParts';\nimport { cx } from '../utils/cx';\n\nexport interface TextInputProps\n extends\n Omit<\n AriaTextFieldProps,\n 'className' | 'style' | 'children' | 'isInvalid' | 'validate' | 'type'\n >,\n FieldChromeProps {\n type?: 'text' | 'email' | 'url' | 'tel' | 'password' | 'search';\n placeholder?: string;\n /** Content before the text, inside the control: a unit, a URL prefix, an icon. */\n prefix?: ReactNode;\n /** Content after the text, inside the control. */\n suffix?: ReactNode;\n /** Class name of the control (the box around the text). */\n controlClassName?: string;\n inputClassName?: string;\n}\n\n/** A single-line text input with its label, description and errors. */\nexport function TextInput({\n label,\n description,\n errors = [],\n placeholder,\n prefix,\n suffix,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n controlClassName,\n inputClassName,\n isRequired,\n isReadOnly,\n ...props\n}: TextInputProps) {\n const invalid = errors.length > 0;\n const adorned = prefix !== undefined || suffix !== undefined;\n return (\n <TextField\n {...props}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n isInvalid={invalid}\n validationBehavior=\"aria\"\n className={cx('panneau-text-input', styles.field, className)}\n >\n <FieldLabel isRequired={isRequired} className={labelClassName}>\n {label}\n </FieldLabel>\n {adorned ? (\n <Group\n className={cx(styles.control, controlClassName)}\n data-invalid={invalid || undefined}\n data-readonly={isReadOnly || undefined}\n isDisabled={props.isDisabled}\n >\n {prefix !== undefined ? (\n <span\n className={styles.adornment}\n data-text={typeof prefix === 'string' || undefined}\n >\n {prefix}\n </span>\n ) : null}\n <Input placeholder={placeholder} className={cx(styles.bare, inputClassName)} />\n {suffix !== undefined ? (\n <span\n className={styles.adornment}\n data-text={typeof suffix === 'string' || undefined}\n >\n {suffix}\n </span>\n ) : null}\n </Group>\n ) : (\n <Input\n placeholder={placeholder}\n className={cx(styles.control, controlClassName, inputClassName)}\n />\n )}\n <FieldDescription className={descriptionClassName}>{description}</FieldDescription>\n <FieldErrors errors={errors} className={errorsClassName} />\n </TextField>\n );\n}\n"],"mappings":";;;;;;;;AAoCA,SAAOqB,UAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAN;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAR;CAAA,IAAAS;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAhB;CAAA,IAAAC;CAAA,IAAAgB;CAAA,IAAAf;CAAA,IAAAgB;CAAA,IAAAX,EAAA,OAAAD,IAAA;EAAmB,CAAA,CAAAS,OAAAL,aAAAS,QAAAD,IAAAlB,aAAAC,QAAAC,QAAAO,WAAAO,gBAAAL,sBAAAC,iBAAAT,kBAAAC,gBAAAU,Y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bootstrap.ts"],"sourcesContent":["import type { ThemeDefinition } from './defineTheme';\nimport type { Theme } from './theme';\nimport type { ToneValues } from './tones';\n\n/**\n * A tone from one of Bootstrap's theme colors, read from its CSS variables (`--bs-<color>`,\n * `-text-emphasis`, `-bg-subtle`, `-border-subtle`), so that a site's custom colors carry over:\n * `tones: { brand: bootstrapTone('brand') }`. Text on the subtle background uses the emphasis\n * color, as Bootstrap's alerts do. Light colors need dark solid text: `{ solidText: 'var(--bs-dark)' }`.\n */\nexport function bootstrapTone(\n color: string,\n { solidText = 'var(--bs-white)' }: { solidText?: string } = {},\n): ToneValues {\n return {\n text: `var(--bs-${color}-text-emphasis)`,\n subtle: `var(--bs-${color}-bg-subtle)`,\n border: `var(--bs-${color}-border-subtle)`,\n outline: `var(--bs-${color})`,\n solid: `var(--bs-${color})`,\n solidHover: `color-mix(in srgb, var(--bs-${color}), #000 15%)`,\n solidText,\n };\n}\n\n/**\n * Maps Panneau's tokens to the CSS variables of Bootstrap 5.3, for sites that use Bootstrap: Panneau\n * then follows the site's colors, fonts and radii, and its color mode (`data-bs-theme`), without\n * using any Bootstrap class. Bootstrap's CSS must be loaded by the site.\n */\nexport const bootstrapTheme: Theme = {\n label: 'Bootstrap',\n tokens: {\n 'panneau-color-bg': 'var(--bs-body-bg)',\n 'panneau-color-surface': 'var(--bs-body-bg)',\n 'panneau-color-surface-sunken': 'var(--bs-tertiary-bg)',\n 'panneau-color-surface-raised': 'var(--bs-body-bg)',\n 'panneau-color-hover': 'rgba(var(--bs-emphasis-color-rgb), 0.06)',\n 'panneau-color-pressed': 'rgba(var(--bs-emphasis-color-rgb), 0.1)',\n 'panneau-color-text': 'var(--bs-body-color)',\n 'panneau-color-text-muted': 'var(--bs-secondary-color)',\n 'panneau-color-link': 'var(--bs-link-color)',\n 'panneau-color-border': 'var(--bs-border-color)',\n 'panneau-color-border-control': 'var(--bs-border-color)',\n 'panneau-color-accent': 'var(--bs-primary)',\n 'panneau-color-accent-hover': 'color-mix(in srgb, var(--bs-primary), #000 15%)',\n 'panneau-color-accent-text': 'var(--bs-white)',\n 'panneau-color-accent-subtle': 'var(--bs-primary-bg-subtle)',\n 'panneau-color-focus': 'rgba(var(--bs-primary-rgb), 0.5)',\n 'panneau-color-danger': 'var(--bs-danger-text-emphasis)',\n 'panneau-color-danger-subtle': 'var(--bs-danger-bg-subtle)',\n 'panneau-color-danger-border': 'var(--bs-danger-border-subtle)',\n 'panneau-color-danger-solid': 'var(--bs-danger)',\n 'panneau-color-danger-solid-hover': 'color-mix(in srgb, var(--bs-danger), #000 15%)',\n 'panneau-color-danger-solid-text': 'var(--bs-white)',\n 'panneau-color-success': 'var(--bs-success-text-emphasis)',\n 'panneau-color-success-subtle': 'var(--bs-success-bg-subtle)',\n 'panneau-color-success-border': 'var(--bs-success-border-subtle)',\n 'panneau-color-success-solid': 'var(--bs-success)',\n 'panneau-color-success-solid-hover': 'color-mix(in srgb, var(--bs-success), #000 15%)',\n 'panneau-color-success-solid-text': 'var(--bs-white)',\n 'panneau-color-warning': 'var(--bs-warning-text-emphasis)',\n 'panneau-color-warning-subtle': 'var(--bs-warning-bg-subtle)',\n 'panneau-color-warning-border': 'var(--bs-warning-border-subtle)',\n 'panneau-color-warning-solid': 'var(--bs-warning)',\n 'panneau-color-warning-solid-hover': 'color-mix(in srgb, var(--bs-warning), #000 10%)',\n // Like Bootstrap's .btn-warning and .text-bg-warning: dark text on yellow.\n 'panneau-color-warning-solid-text': 'var(--bs-dark)',\n 'panneau-color-info': 'var(--bs-info-text-emphasis)',\n 'panneau-color-info-subtle': 'var(--bs-info-bg-subtle)',\n 'panneau-color-info-border': 'var(--bs-info-border-subtle)',\n 'panneau-color-info-solid': 'var(--bs-info)',\n 'panneau-color-info-solid-hover': 'color-mix(in srgb, var(--bs-info), #000 10%)',\n 'panneau-color-info-solid-text': 'var(--bs-dark)',\n 'panneau-font-family-body': 'var(--bs-body-font-family)',\n 'panneau-font-family-mono': 'var(--bs-font-monospace)',\n 'panneau-font-size-md': 'var(--bs-body-font-size)',\n 'panneau-line-height': 'var(--bs-body-line-height)',\n 'panneau-radius-sm': 'var(--bs-border-radius-sm)',\n 'panneau-radius-md': 'var(--bs-border-radius)',\n 'panneau-radius-lg': 'var(--bs-border-radius-lg)',\n 'panneau-radius-full': 'var(--bs-border-radius-pill)',\n 'panneau-border-width': 'var(--bs-border-width)',\n 'panneau-shadow-sm': 'var(--bs-box-shadow-sm)',\n 'panneau-shadow-md': 'var(--bs-box-shadow)',\n 'panneau-shadow-lg': 'var(--bs-box-shadow-lg)',\n // Bootstrap 5.3 declares its component variables (--bs-btn-*, --bs-card-*) on the classes\n // of its components, out of reach: components map to the root variables those default to.\n 'panneau-heading-color': 'var(--bs-heading-color)',\n 'panneau-badge-radius': 'var(--bs-border-radius)',\n 'panneau-card-radius': 'var(--bs-border-radius)',\n 'panneau-card-border-color': 'var(--bs-border-color-translucent)',\n 'panneau-popover-radius': 'var(--bs-border-radius)',\n 'panneau-popover-border-color': 'var(--bs-border-color-translucent)',\n 'panneau-tooltip-bg': 'var(--bs-emphasis-color)',\n 'panneau-tooltip-color': 'var(--bs-body-bg)',\n 'panneau-tooltip-radius': 'var(--bs-border-radius)',\n },\n // Bootstrap's theme colors as tones: accent is primary, and primary and secondary are there by\n // their Bootstrap names (declare them in PanneauTones to use them).\n tones: {\n accent: bootstrapTone('primary'),\n primary: bootstrapTone('primary'),\n secondary: bootstrapTone('secondary'),\n },\n // Bootstrap's sizes of controls are those of the comfortable density: the others keep Panneau's.\n densities: {\n comfortable: {\n 'panneau-font-size-control': 'var(--bs-body-font-size)',\n 'panneau-control-height': 'calc(1.5em + 0.75rem + 2 * var(--bs-border-width))',\n 'panneau-control-height-sm': 'calc(1.5em + 0.5rem + 2 * var(--bs-border-width))',\n 'panneau-control-padding-x': '0.75rem',\n },\n },\n} satisfies ThemeDefinition;\n"],"mappings":";;;;;;;AAUA,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","names":["ThemeDefinition","Theme","ToneValues","bootstrapTone","color","solidText","text","subtle","border","outline","solid","solidHover","bootstrapTheme","label","tokens","tones","accent","primary","secondary","densities","comfortable"],"sources":["../../src/theme/bootstrap.ts"],"sourcesContent":["import type { ThemeDefinition } from './defineTheme';\nimport type { Theme } from './theme';\nimport type { ToneValues } from './tones';\n\n/**\n * A tone from one of Bootstrap's theme colors, read from its CSS variables (`--bs-<color>`,\n * `-text-emphasis`, `-bg-subtle`, `-border-subtle`), so that a site's custom colors carry over:\n * `tones: { brand: bootstrapTone('brand') }`. Text on the subtle background uses the emphasis\n * color, as Bootstrap's alerts do. Light colors need dark solid text: `{ solidText: 'var(--bs-dark)' }`.\n */\nexport function bootstrapTone(\n color: string,\n { solidText = 'var(--bs-white)' }: { solidText?: string } = {},\n): ToneValues {\n return {\n text: `var(--bs-${color}-text-emphasis)`,\n subtle: `var(--bs-${color}-bg-subtle)`,\n border: `var(--bs-${color}-border-subtle)`,\n outline: `var(--bs-${color})`,\n solid: `var(--bs-${color})`,\n solidHover: `color-mix(in srgb, var(--bs-${color}), #000 15%)`,\n solidText,\n };\n}\n\n/**\n * Maps Panneau's tokens to the CSS variables of Bootstrap 5.3, for sites that use Bootstrap: Panneau\n * then follows the site's colors, fonts and radii, and its color mode (`data-bs-theme`), without\n * using any Bootstrap class. Bootstrap's CSS must be loaded by the site.\n */\nexport const bootstrapTheme: Theme = {\n label: 'Bootstrap',\n tokens: {\n 'panneau-color-bg': 'var(--bs-body-bg)',\n 'panneau-color-surface': 'var(--bs-body-bg)',\n 'panneau-color-surface-sunken': 'var(--bs-tertiary-bg)',\n 'panneau-color-surface-raised': 'var(--bs-body-bg)',\n 'panneau-color-hover': 'rgba(var(--bs-emphasis-color-rgb), 0.06)',\n 'panneau-color-pressed': 'rgba(var(--bs-emphasis-color-rgb), 0.1)',\n 'panneau-color-text': 'var(--bs-body-color)',\n 'panneau-color-text-muted': 'var(--bs-secondary-color)',\n 'panneau-color-link': 'var(--bs-link-color)',\n 'panneau-color-border': 'var(--bs-border-color)',\n 'panneau-color-border-control': 'var(--bs-border-color)',\n 'panneau-color-accent': 'var(--bs-primary)',\n 'panneau-color-accent-hover': 'color-mix(in srgb, var(--bs-primary), #000 15%)',\n 'panneau-color-accent-text': 'var(--bs-white)',\n 'panneau-color-accent-subtle': 'var(--bs-primary-bg-subtle)',\n 'panneau-color-focus': 'rgba(var(--bs-primary-rgb), 0.5)',\n 'panneau-color-danger': 'var(--bs-danger-text-emphasis)',\n 'panneau-color-danger-subtle': 'var(--bs-danger-bg-subtle)',\n 'panneau-color-danger-border': 'var(--bs-danger-border-subtle)',\n 'panneau-color-danger-solid': 'var(--bs-danger)',\n 'panneau-color-danger-solid-hover': 'color-mix(in srgb, var(--bs-danger), #000 15%)',\n 'panneau-color-danger-solid-text': 'var(--bs-white)',\n 'panneau-color-success': 'var(--bs-success-text-emphasis)',\n 'panneau-color-success-subtle': 'var(--bs-success-bg-subtle)',\n 'panneau-color-success-border': 'var(--bs-success-border-subtle)',\n 'panneau-color-success-solid': 'var(--bs-success)',\n 'panneau-color-success-solid-hover': 'color-mix(in srgb, var(--bs-success), #000 15%)',\n 'panneau-color-success-solid-text': 'var(--bs-white)',\n 'panneau-color-warning': 'var(--bs-warning-text-emphasis)',\n 'panneau-color-warning-subtle': 'var(--bs-warning-bg-subtle)',\n 'panneau-color-warning-border': 'var(--bs-warning-border-subtle)',\n 'panneau-color-warning-solid': 'var(--bs-warning)',\n 'panneau-color-warning-solid-hover': 'color-mix(in srgb, var(--bs-warning), #000 10%)',\n // Like Bootstrap's .btn-warning and .text-bg-warning: dark text on yellow.\n 'panneau-color-warning-solid-text': 'var(--bs-dark)',\n 'panneau-color-info': 'var(--bs-info-text-emphasis)',\n 'panneau-color-info-subtle': 'var(--bs-info-bg-subtle)',\n 'panneau-color-info-border': 'var(--bs-info-border-subtle)',\n 'panneau-color-info-solid': 'var(--bs-info)',\n 'panneau-color-info-solid-hover': 'color-mix(in srgb, var(--bs-info), #000 10%)',\n 'panneau-color-info-solid-text': 'var(--bs-dark)',\n 'panneau-font-family-body': 'var(--bs-body-font-family)',\n 'panneau-font-family-mono': 'var(--bs-font-monospace)',\n 'panneau-font-size-md': 'var(--bs-body-font-size)',\n 'panneau-line-height': 'var(--bs-body-line-height)',\n 'panneau-radius-sm': 'var(--bs-border-radius-sm)',\n 'panneau-radius-md': 'var(--bs-border-radius)',\n 'panneau-radius-lg': 'var(--bs-border-radius-lg)',\n 'panneau-radius-full': 'var(--bs-border-radius-pill)',\n 'panneau-border-width': 'var(--bs-border-width)',\n 'panneau-shadow-sm': 'var(--bs-box-shadow-sm)',\n 'panneau-shadow-md': 'var(--bs-box-shadow)',\n 'panneau-shadow-lg': 'var(--bs-box-shadow-lg)',\n // Bootstrap 5.3 declares its component variables (--bs-btn-*, --bs-card-*) on the classes\n // of its components, out of reach: components map to the root variables those default to.\n 'panneau-heading-color': 'var(--bs-heading-color)',\n 'panneau-badge-radius': 'var(--bs-border-radius)',\n 'panneau-card-radius': 'var(--bs-border-radius)',\n 'panneau-card-border-color': 'var(--bs-border-color-translucent)',\n 'panneau-popover-radius': 'var(--bs-border-radius)',\n 'panneau-popover-border-color': 'var(--bs-border-color-translucent)',\n 'panneau-tooltip-bg': 'var(--bs-emphasis-color)',\n 'panneau-tooltip-color': 'var(--bs-body-bg)',\n 'panneau-tooltip-radius': 'var(--bs-border-radius)',\n },\n // Bootstrap's theme colors as tones: accent is primary, and primary and secondary are there by\n // their Bootstrap names (declare them in PanneauTones to use them).\n tones: {\n accent: bootstrapTone('primary'),\n primary: bootstrapTone('primary'),\n secondary: bootstrapTone('secondary'),\n },\n // Bootstrap's sizes of controls are those of the comfortable density: the others keep Panneau's.\n densities: {\n comfortable: {\n 'panneau-font-size-control': 'var(--bs-body-font-size)',\n 'panneau-control-height': 'calc(1.5em + 0.75rem + 2 * var(--bs-border-width))',\n 'panneau-control-height-sm': 'calc(1.5em + 0.5rem + 2 * var(--bs-border-width))',\n 'panneau-control-padding-x': '0.75rem',\n },\n },\n} sat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B,0BAA0B;CAC9B;CAGAC,OAAO;EACHC,QAAQb,cAAc,SAAS;EAC/Bc,SAASd,cAAc,SAAS;EAChCe,WAAWf,cAAc,WAAW;CACxC;CAEAgB,WAAW,EACPC,aAAa;EACT,6BAA6B;EAC7B,0BAA0B;EAC1B,6BAA6B;EAC7B,6BAA6B;CACjC,EACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartColors.js","names":[],"sources":["../../src/theme/chartColors.ts"],"sourcesContent":["/** The number of categorical chart colors: series beyond it reuse them in order. */\nexport const CHART_CATEGORICAL_COUNT = 8;\n\n/** The number of steps of the sequential chart ramp. */\nexport const CHART_SEQUENTIAL_COUNT = 5;\n\n/**\n * The colors of charts, as CSS variables for `fill` and `stroke`: they follow the theme, the color\n * scheme and the scope of the chart. Dashboard charts use only these.\n *\n * - `categorical(index)`: the color of a series, in a fixed order (`index` from 0), repeating after\n * 8. Each one reaches 3:1 against the surface and stays distinct with color vision deficiencies.\n * - `sequential(step)`: a step from 1 (low) to 5 (high) of a ramp, for quantities.\n * - `diverging`: two colors around a neutral midpoint, for values above and below a reference.\n */\nexport const chartColors = Object.freeze({\n categorical: (index: number): string =>\n `var(--panneau-chart-categorical-${(((Math.floor(index) % CHART_CATEGORICAL_COUNT) + CHART_CATEGORICAL_COUNT) % CHART_CATEGORICAL_COUNT) + 1})`,\n sequential: (step: 1 | 2 | 3 | 4 | 5): string => `var(--panneau-chart-sequential-${step})`,\n diverging: Object.freeze({\n negative: 'var(--panneau-chart-diverging-negative)',\n neutral: 'var(--panneau-chart-diverging-neutral)',\n positive: 'var(--panneau-chart-diverging-positive)',\n }),\n});\n"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"chartColors.js","names":["CHART_CATEGORICAL_COUNT","CHART_SEQUENTIAL_COUNT","chartColors","Object","freeze","categorical","index","Math","floor","sequential","step","diverging","negative","neutral","positive"],"sources":["../../src/theme/chartColors.ts"],"sourcesContent":["/** The number of categorical chart colors: series beyond it reuse them in order. */\nexport const CHART_CATEGORICAL_COUNT = 8;\n\n/** The number of steps of the sequential chart ramp. */\nexport const CHART_SEQUENTIAL_COUNT = 5;\n\n/**\n * The colors of charts, as CSS variables for `fill` and `stroke`: they follow the theme, the color\n * scheme and the scope of the chart. Dashboard charts use only these.\n *\n * - `categorical(index)`: the color of a series, in a fixed order (`index` from 0), repeating after\n * 8. Each one reaches 3:1 against the surface and stays distinct with color vision deficiencies.\n * - `sequential(step)`: a step from 1 (low) to 5 (high) of a ramp, for quantities.\n * - `diverging`: two colors around a neutral midpoint, for values above and below a reference.\n */\nexport const chartColors = Object.freeze({\n categorical: (index: number): string =>\n `var(--panneau-chart-categorical-${(((Math.floor(index) % CHART_CATEGORICAL_COUNT) + CHART_CATEGORICAL_COUNT) % CHART_CATEGORICAL_COUNT) + 1})`,\n sequential: (step: 1 | 2 | 3 | 4 | 5): string => `var(--panneau-chart-sequential-${step})`,\n diverging: Object.freeze({\n negative: 'var(--panneau-chart-diverging-negative)',\n neutral: 'var(--panneau-chart-diverging-neutral)',\n positive: 'var(--panneau-chart-diverging-positive)',\n }),\n});\n"],"mappings":";;AACA,IAAaA,0BAA0B;;AAGvC,IAAaC,yBAAyB;;;;;;;;;;AAWtC,IAAaC,cAAcC,OAAOC,OAAO;CACrCC,cAAcC,UACV,oCAAsCC,KAAKC,MAAMF,KAAK,IAAA,IAAA,KAAA,IAAqF,EAAC;CAChJG,aAAaC,SAAoC,kCAAkCA,KAAI;CACvFC,WAAWR,OAAOC,OAAO;EACrBQ,UAAU;EACVC,SAAS;EACTC,UAAU;CACd,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTheme.js","names":[],"sources":["../../src/theme/checkTheme.ts"],"sourcesContent":["import { type Rgb, WHITE, contrastRatio, mixColors, parseColor } from './color';\nimport { type ColorDifferenceCheck, checkColorDifferences } from './colorVision';\nimport { type Theme, paletteVariables, resolveReference, themeSurfaces } from './theme';\nimport { MIN_CONTRAST_RATIO, SUBTLE_AMOUNTS, resolveTone } from './tones';\n\n/** A pair of colors that a theme must keep readable. */\nexport interface ThemeContrastCheck {\n scheme: 'light' | 'dark';\n /** What is checked: `tone signal: text on surface`, `tokens: text on bg`. */\n name: string;\n foreground: string;\n background: string;\n /** The contrast ratio, or `null` when a color can't be read (a CSS variable, `color-mix()`). */\n ratio: number | null;\n minimum: number;\n}\n\nexport interface ThemeReport {\n /** Every pair checked. */\n checks: ThemeContrastCheck[];\n /** Pairs below their minimum ratio. */\n failures: ThemeContrastCheck[];\n /** Pairs with a color Panneau can't read: check them in a browser. */\n unchecked: ThemeContrastCheck[];\n /**\n * Categorical chart colors of the theme that look too alike, for typical vision or with a\n * color vision deficiency.\n */\n colorDifferences: (ColorDifferenceCheck & { scheme: 'light' | 'dark' })[];\n}\n\n/** Surfaces of the default theme, used when a theme doesn't set its own. */\nconst DEFAULT_SURFACES: Record<'light' | 'dark', Rgb> = {\n light: WHITE,\n dark: { r: 24, g: 24, b: 27 },\n};\n\n/** Chart colors that must stand out from the surface: series, the high step and diverging ends. */\nconst CHART_TOKENS = [\n ...Array.from({ length: 8 }, (_, index) => `panneau-chart-categorical-${index + 1}`),\n 'panneau-chart-sequential-5',\n 'panneau-chart-diverging-negative',\n 'panneau-chart-diverging-positive',\n];\n\n/** Non-text elements (borders of controls, outlines) need 3:1 (WCAG 2 non-text contrast). */\nconst MIN_NON_TEXT_RATIO = 3;\n\nconst TOKEN_PAIRS: [name: string, foreground: string, background: string, minimum: number][] = [\n ['text on bg', 'panneau-color-text', 'panneau-color-bg', MIN_CONTRAST_RATIO],\n ['text on surface', 'panneau-color-text', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'muted text on surface',\n 'panneau-color-text-muted',\n 'panneau-color-surface',\n MIN_CONTRAST_RATIO,\n ],\n ['link on surface', 'panneau-color-link', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'accent text on accent',\n 'panneau-color-accent-text',\n 'panneau-color-accent',\n MIN_CONTRAST_RATIO,\n ],\n [\n 'control border on surface',\n 'panneau-color-border-control',\n 'panneau-color-surface',\n MIN_NON_TEXT_RATIO,\n ],\n];\n\n/**\n * Checks the contrast of a theme, like Bootstrap's `$min-contrast-ratio`, but as a report: text\n * tokens against backgrounds (4.5:1), control borders (3:1), and every tone of the theme (its text\n * on the surface, its solid text on the solid background and its hover), and chart colors (3:1\n * against the surface, and categorical colors distinct with color vision deficiencies). Pairs where a color comes\n * from the default theme and is not set by the theme are skipped, except the surface, which falls\n * back to the default one. Values that refer to the theme's palette or tokens with `var()` are\n * checked as what they refer to; colors Panneau can't read are listed as unchecked.\n */\nexport function checkTheme(theme: Theme): ThemeReport {\n const checks: ThemeContrastCheck[] = [];\n const colorDifferences: ThemeReport['colorDifferences'] = [];\n const palette = paletteVariables(theme.palette);\n const surfaces = themeSurfaces(theme);\n (['light', 'dark'] as const).forEach((scheme) => {\n const variables = {\n ...palette,\n ...theme.tokens,\n ...(scheme === 'dark' ? theme.dark : undefined),\n };\n const tokens = Object.fromEntries(\n Object.entries(variables).map(([name, value]) => [\n name,\n resolveReference(value, variables),\n ]),\n );\n const surface = tokens['panneau-color-surface'];\n const surfaceColor = surface !== undefined ? parseColor(surface) : DEFAULT_SURFACES[scheme];\n const add = (\n name: string,\n foreground: string,\n background: string,\n minimum: number,\n backgroundColor: Rgb | null = parseColor(background),\n ) => {\n const foregroundColor = parseColor(foreground);\n checks.push({\n scheme,\n name,\n foreground,\n background,\n ratio:\n foregroundColor !== null && backgroundColor !== null\n ? Math.round(contrastRatio(foregroundColor, backgroundColor) * 100) / 100\n : null,\n minimum,\n });\n };\n TOKEN_PAIRS.forEach(([name, foreground, background, minimum]) => {\n const foregroundValue = tokens[foreground];\n const backgroundValue = tokens[background];\n if (foregroundValue !== undefined && backgroundValue !== undefined) {\n add(`tokens: ${name}`, foregroundValue, backgroundValue, minimum);\n }\n });\n // Chart colors are graphics: 3:1 against the surface, and distinct from each other.\n const surfaceValue = surface ?? (scheme === 'light' ? '#ffffff' : '#18181b');\n CHART_TOKENS.forEach((token) => {\n const value = tokens[token];\n if (value !== undefined) {\n add(\n `chart: ${token.replace('panneau-chart-', '')} on surface`,\n value,\n surfaceValue,\n MIN_NON_TEXT_RATIO,\n surfaceColor,\n );\n }\n });\n const categorical = CHART_TOKENS.filter((token) => token.includes('categorical')).flatMap(\n (token) => (tokens[token] !== undefined ? [tokens[token]] : []),\n );\n colorDifferences.push(\n ...checkColorDifferences(categorical).map((check) => ({ ...check, scheme })),\n );\n Object.entries(theme.tones ?? {}).forEach(([tone, toneInput]) => {\n const input =\n typeof toneInput === 'string' ? resolveReference(toneInput, palette) : toneInput;\n const values = resolveTone(input, surfaces)[scheme];\n add(\n `tone ${tone}: text on surface`,\n values.text,\n surface ?? (scheme === 'light' ? '#ffffff' : '#18181b'),\n MIN_CONTRAST_RATIO,\n surfaceColor,\n );\n // The subtle background of a tone is often mixed with the surface in CSS: compute it\n // against the surface of the scheme when it can't be read directly.\n const color = typeof input === 'string' ? parseColor(input) : null;\n const subtleColor =\n parseColor(values.subtle) ??\n (color !== null && surfaceColor !== null\n ? mixColors(surfaceColor, color, SUBTLE_AMOUNTS[scheme])\n : null);\n add(\n `tone ${tone}: text on subtle`,\n values.text,\n values.subtle,\n MIN_CONTRAST_RATIO,\n subtleColor,\n );\n add(\n `tone ${tone}: solid text on solid`,\n values.solidText,\n values.solid,\n MIN_CONTRAST_RATIO,\n );\n add(\n `tone ${tone}: solid text on hover`,\n values.solidText,\n values.solidHover,\n MIN_CONTRAST_RATIO,\n );\n });\n });\n return {\n checks,\n failures: checks.filter((check) => check.ratio !== null && check.ratio < check.minimum),\n unchecked: checks.filter((check) => check.ratio === null),\n colorDifferences,\n };\n}\n"],"mappings":";;;;;;AAgCA,IAAM,mBAAkD;CACpD,OAAO;CACP,MAAM;EAAE,GAAG;EAAI,GAAG;EAAI,GAAG;CAAG;AAChC;;AAGA,IAAM,eAAe;CACjB,GAA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A,UAAU,OAAO,QAAQ,UAAU,MAAM,UAAU,QAAQ,MAAM,QAAQ,MAAM,OAAO;EACtF,WAAW,OAAO,QAAQ,UAAU,MAAM,UAAU,IAAI;EACxD;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"checkTheme.js","names":["Rgb","WHITE","contrastRatio","mixColors","parseColor","ColorDifferenceCheck","checkColorDifferences","Theme","paletteVariables","resolveReference","themeSurfaces","MIN_CONTRAST_RATIO","SUBTLE_AMOUNTS","resolveTone","ThemeContrastCheck","scheme","name","foreground","background","ratio","minimum","ThemeReport","checks","failures","unchecked","colorDifferences","DEFAULT_SURFACES","Record","light","dark","r","g","b","CHART_TOKENS","Array","from","length","_","index","MIN_NON_TEXT_RATIO","TOKEN_PAIRS","checkTheme","theme","palette","surfaces","const","forEach","variables","tokens","undefined","Object","fromEntries","entries","map","value","surface","surfaceColor","add","backgroundColor","foregroundColor","push","Math","round","foregroundValue","backgroundValue","surfaceValue","token","replace","categorical","filter","includes","flatMap","check","tones","tone","toneInput","input","values","text","color","subtleColor","subtle","solidText","solid","solidHover"],"sources":["../../src/theme/checkTheme.ts"],"sourcesContent":["import { type Rgb, WHITE, contrastRatio, mixColors, parseColor } from './color';\nimport { type ColorDifferenceCheck, checkColorDifferences } from './colorVision';\nimport { type Theme, paletteVariables, resolveReference, themeSurfaces } from './theme';\nimport { MIN_CONTRAST_RATIO, SUBTLE_AMOUNTS, resolveTone } from './tones';\n\n/** A pair of colors that a theme must keep readable. */\nexport interface ThemeContrastCheck {\n scheme: 'light' | 'dark';\n /** What is checked: `tone signal: text on surface`, `tokens: text on bg`. */\n name: string;\n foreground: string;\n background: string;\n /** The contrast ratio, or `null` when a color can't be read (a CSS variable, `color-mix()`). */\n ratio: number | null;\n minimum: number;\n}\n\nexport interface ThemeReport {\n /** Every pair checked. */\n checks: ThemeContrastCheck[];\n /** Pairs below their minimum ratio. */\n failures: ThemeContrastCheck[];\n /** Pairs with a color Panneau can't read: check them in a browser. */\n unchecked: ThemeContrastCheck[];\n /**\n * Categorical chart colors of the theme that look too alike, for typical vision or with a\n * color vision deficiency.\n */\n colorDifferences: (ColorDifferenceCheck & { scheme: 'light' | 'dark' })[];\n}\n\n/** Surfaces of the default theme, used when a theme doesn't set its own. */\nconst DEFAULT_SURFACES: Record<'light' | 'dark', Rgb> = {\n light: WHITE,\n dark: { r: 24, g: 24, b: 27 },\n};\n\n/** Chart colors that must stand out from the surface: series, the high step and diverging ends. */\nconst CHART_TOKENS = [\n ...Array.from({ length: 8 }, (_, index) => `panneau-chart-categorical-${index + 1}`),\n 'panneau-chart-sequential-5',\n 'panneau-chart-diverging-negative',\n 'panneau-chart-diverging-positive',\n];\n\n/** Non-text elements (borders of controls, outlines) need 3:1 (WCAG 2 non-text contrast). */\nconst MIN_NON_TEXT_RATIO = 3;\n\nconst TOKEN_PAIRS: [name: string, foreground: string, background: string, minimum: number][] = [\n ['text on bg', 'panneau-color-text', 'panneau-color-bg', MIN_CONTRAST_RATIO],\n ['text on surface', 'panneau-color-text', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'muted text on surface',\n 'panneau-color-text-muted',\n 'panneau-color-surface',\n MIN_CONTRAST_RATIO,\n ],\n ['link on surface', 'panneau-color-link', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'accent text on accent',\n 'panneau-color-accent-text',\n 'panneau-color-accent',\n MIN_CONTRAST_RATIO,\n ],\n [\n 'control border on surface',\n 'panneau-color-border-control',\n 'panneau-color-surface',\n MIN_NON_TEXT_RATIO,\n ],\n];\n\n/**\n * Checks the contrast of a theme, like Bootstrap's `$min-contrast-ratio`, but as a report: text\n * tokens against backgrounds (4.5:1), control borders (3:1), and every tone of the theme (its text\n * on the surface, its solid text on the solid background and its hover), and chart colors (3:1\n * against the surface, and categorical colors distinct with color vision deficiencies). Pairs where a color comes\n * from the default theme and is not set by the theme are skipped, except the surface, which falls\n * back to the default one. Values that refer to the theme's palette or tokens with `var()` are\n * checked as what they refer to; colors Panneau can't read are listed as unchecked.\n */\nexport function checkTheme(theme: Theme): ThemeReport {\n const checks: ThemeContrastCheck[] = [];\n const colorDifferences: ThemeReport['colorDifferences'] = [];\n const palette = paletteVariables(theme.palette);\n const surfaces = themeSurfaces(theme);\n (['light', 'dark'] as const).forEach((scheme) => {\n const variables = {\n ...palette,\n ...theme.tokens,\n ...(scheme === 'dark' ? theme.dark : undefined),\n };\n const tokens = Object.fromEntries(\n Object.entries(variables).map(([name, value]) => [\n name,\n resolveReference(value, variables),\n ]),\n );\n const surface = tokens['panneau-color-surface'];\n const surfaceColor = surface !== undefined ? parseColor(surface) : DEFAULT_SURFACES[scheme];\n const add = (\n name: string,\n foreground: string,\n background: string,\n minimum: number,\n backgroundColor: Rgb | null = parseColor(background),\n ) => {\n const foregroundColor = parseColor(foreground);\n checks.push({\n scheme,\n name,\n foreground,\n background,\n ratio:\n foregroundColor !== null && backgroundColor !== null\n ? Math.round(contrastRatio(foregroundColor, backgroundColor) * 100) / 100\n : null,\n minimum,\n });\n };\n TOKEN_PAIRS.forEach(([name, foreground, background, minimum]) => {\n const foregroundValue = tokens[foreground];\n const backgroundValue = tokens[background];\n if (foregroundValue !== undefined && backgroundValue !== undefined) {\n add(`tokens: ${name}`, foregroundValue, backgroundValue, minimum);\n }\n });\n // Chart colors are graphics: 3:1 against the surface, and distinct from each other.\n const surfaceValue = surface ?? (scheme === 'light' ? '#ffffff' : '#18181b');\n CHART_TOKENS.forEach((token) => {\n const value = tokens[token];\n if (value !== undefined) {\n add(\n `chart: ${token.replace('panneau-chart-', '')} on surface`,\n value,\n surfaceValue,\n MIN_NON_TEXT_RATIO,\n surfaceColor,\n );\n }\n });\n const categorical = CHART_TOKENS.filter((token) => token.includes('categorical')).flatMap(\n (token) => (tokens[token] !== undefined ? [tokens[token]] : []),\n );\n colorDifferences.push(\n ...checkColorDifferences(categorical).map((check) => ({ ...check, scheme })),\n );\n Object.entries(theme.tones ?? {}).forEach(([tone, toneInput]) => {\n const input =\n typeof toneInput === 'string' ? resolveReference(toneInput, palette) : toneInput;\n const values = resolveTone(input, surfaces)[scheme];\n add(\n `tone ${tone}: text on surface`,\n values.text,\n surface ?? (scheme === 'light' ? '#ffffff' : '#18181b'),\n MIN_CONTRAST_RATIO,\n surfaceColor,\n );\n // The subtle background of a tone is often mixed with the surface in CSS: compute it\n // against the surface of the scheme when it can't be read directly.\n const color = typeof input === 'string' ? parseColor(input) : null;\n const subtleColor =\n parseColor(values.subtle) ??\n (color !== null && surfaceColor !== null\n ? mixColors(surfaceColor, color, SUBTLE_AMOUNTS[scheme])\n : null);\n add(\n `tone ${tone}: text on subtle`,\n values.text,\n values.subtle,\n MIN_CONTRAST_RATIO,\n subtleColor,\n );\n add(\n `tone ${tone}: solid text on solid`,\n values.solidText,\n values.solid,\n MIN_CONTRAST_RATIO,\n );\n add(\n `tone ${tone}: solid text on hover`,\n values.solidText,\n values.solidHover,\n MIN_CONTRAST_RATIO,\n );\n });\n });\n return {\n checks,\n failures: checks.filter((check) => check.ratio !== null && check.ratio < check.minimum),\n unchecked: checks.filter((check) => check.ratio === null),\n colorDifferences,\n };\n}\n"],"mappings":";;;;;;AAgCA,IAAM0B,mBAAkD;CACpDE,OAAO3B;CACP4B,MAAM;EAAEC,GAAG;EAAIC,GAAG;EAAIC,GAAG;CAAG;AAChC;;AAGA,IAAMC,eAAe;CACjB,GAAGC,MAAMC,KAAK,EAAEC,QAAQ,EAAE,IAAIC,GAAGC,UAAU,6BAA6BA,QAAQ,GAAG;CACnF;CACA;CACA;AAAkC;;AAItC,IAAMC,qBAAqB;AAE3B,IAAMC,cAAyF;CAC3F;EAAC;EAAc;EAAsB;EAAoB7B;CAAkB;CAC3E;EAAC;EAAmB;EAAsB;EAAyBA;CAAkB;CACrF;EACI;EACA;EACA;EACAA;CAAkB;CAEtB;EAAC;EAAmB;EAAsB;EAAyBA;CAAkB;CACrF;EACI;EACA;EACA;EACAA;CAAkB;CAEtB;EACI;EACA;EACA;EACA4B;CAAkB;AACrB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AUA,MAAMrD,UAAU,QAAQqD,MAAMrD,QAAQqD,MAAMpD,OAAO;EACtFI,WAAWF,OAAO+C,QAAQG,UAAUA,MAAMrD,UAAU,IAAI;EACxDM;CACJ;AACJ"}
|
package/dist/theme/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../../src/theme/cli.ts"],"sourcesContent":["// The `panneau-check-theme` command, for Node only: it is not part of the exports.\n/// <reference types=\"node\" />\nimport { readFile } from 'node:fs/promises';\nimport { extname, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { type ThemeReport, checkTheme } from './checkTheme';\nimport type { Theme } from './theme';\n\nconst USAGE = `Usage: panneau-check-theme <file> [--export <name>] [--json]\n\nChecks the contrast of a theme, and the differences between its chart colors with color vision\ndeficiencies. <file> is a JSON file (the Theme schema of @panneau/protocol), or a module whose\ndefault export, or the export named by --export, is a theme. Exits with 1 when a check fails.`;\n\nfunction isTheme(value: unknown): value is Theme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'tokens' in value &&\n typeof value.tokens === 'object' &&\n value.tokens !== null\n );\n}\n\n/** Loads a module from its URL: `import()`, replaced in tests. */\nexport type ModuleImporter = (url: string) => Promise<Record<string, unknown>>;\n\nconst importModule: ModuleImporter = (url) => import(url) as Promise<Record<string, unknown>>;\n\n/** Reads a theme from a JSON file or from an export of a module. */\nexport async function loadTheme(\n path: string,\n exportName = 'default',\n load: ModuleImporter = importModule,\n): Promise<Theme> {\n const file = resolve(path);\n const value: unknown =\n extname(file) === '.json'\n ? JSON.parse(await readFile(file, 'utf8'))\n : (await load(pathToFileURL(file).href))[exportName];\n if (!isTheme(value)) {\n throw new Error(\n extname(file) === '.json'\n ? `${path} is not a theme: it has no tokens.`\n : `The export \"${exportName}\" of ${path} is not a theme.`,\n );\n }\n return value;\n}\n\n/** A report as text, one line per check that failed or that Panneau couldn't read. */\nexport function formatThemeReport(report: ThemeReport, label = 'Theme'): string {\n const lines = [\n `${label}: ${report.checks.length} contrast checks, ${report.failures.length} failed, ` +\n `${report.unchecked.length} unchecked, ${report.colorDifferences.length} similar chart colors.`,\n ];\n report.failures.forEach((check) => {\n lines.push(\n ` fail ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background}, ${String(check.ratio)}:1 < ${String(check.minimum)}:1`,\n );\n });\n report.colorDifferences.forEach((check) => {\n lines.push(\n ` similar ${check.scheme.padEnd(5)} chart colors ${check.first} and ` +\n `${check.second} with ${check.vision}: ${String(check.difference)} < ${String(check.minimum)}`,\n );\n });\n report.unchecked.forEach((check) => {\n lines.push(\n ` unchecked ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background} (check it in a browser)`,\n );\n });\n return lines.join('\\n');\n}\n\n/** Runs `panneau-check-theme` with its arguments, and returns the exit code. */\nexport async function runCheckTheme(\n args: readonly string[],\n output: { log: (text: string) => void; error: (text: string) => void } = console,\n load: ModuleImporter = importModule,\n): Promise<number> {\n const json = args.includes('--json');\n const exportIndex = args.indexOf('--export');\n const exportName = exportIndex >= 0 ? args[exportIndex + 1] : undefined;\n const files = args.filter(\n (arg, index) => !arg.startsWith('--') && (exportIndex < 0 || index !== exportIndex + 1),\n );\n const [file] = files;\n if (file === undefined || files.length > 1 || args.includes('--help')) {\n output.error(USAGE);\n return args.includes('--help') ? 0 : 2;\n }\n let theme: Theme;\n try {\n theme = await loadTheme(file, exportName, load);\n } catch (error) {\n output.error(error instanceof Error ? error.message : String(error));\n return 2;\n }\n const report = checkTheme(theme);\n output.log(json ? JSON.stringify(report, null, 2) : formatThemeReport(report, theme.label));\n return report.failures.length > 0 || report.colorDifferences.length > 0 ? 1 : 0;\n}\n"],"mappings":";;;;;AASA,
|
|
1
|
+
{"version":3,"file":"cli.js","names":["readFile","extname","resolve","pathToFileURL","ThemeReport","checkTheme","Theme","USAGE","isTheme","value","tokens","ModuleImporter","url","Promise","Record","importModule","loadTheme","path","exportName","load","file","JSON","parse","href","Error","formatThemeReport","report","label","lines","checks","length","failures","unchecked","colorDifferences","forEach","check","push","scheme","padEnd","name","foreground","background","String","ratio","minimum","first","second","vision","difference","join","runCheckTheme","args","output","log","text","error","console","json","includes","exportIndex","indexOf","undefined","files","filter","arg","index","startsWith","theme","message","stringify"],"sources":["../../src/theme/cli.ts"],"sourcesContent":["// The `panneau-check-theme` command, for Node only: it is not part of the exports.\n/// <reference types=\"node\" />\nimport { readFile } from 'node:fs/promises';\nimport { extname, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { type ThemeReport, checkTheme } from './checkTheme';\nimport type { Theme } from './theme';\n\nconst USAGE = `Usage: panneau-check-theme <file> [--export <name>] [--json]\n\nChecks the contrast of a theme, and the differences between its chart colors with color vision\ndeficiencies. <file> is a JSON file (the Theme schema of @panneau/protocol), or a module whose\ndefault export, or the export named by --export, is a theme. Exits with 1 when a check fails.`;\n\nfunction isTheme(value: unknown): value is Theme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'tokens' in value &&\n typeof value.tokens === 'object' &&\n value.tokens !== null\n );\n}\n\n/** Loads a module from its URL: `import()`, replaced in tests. */\nexport type ModuleImporter = (url: string) => Promise<Record<string, unknown>>;\n\nconst importModule: ModuleImporter = (url) => import(url) as Promise<Record<string, unknown>>;\n\n/** Reads a theme from a JSON file or from an export of a module. */\nexport async function loadTheme(\n path: string,\n exportName = 'default',\n load: ModuleImporter = importModule,\n): Promise<Theme> {\n const file = resolve(path);\n const value: unknown =\n extname(file) === '.json'\n ? JSON.parse(await readFile(file, 'utf8'))\n : (await load(pathToFileURL(file).href))[exportName];\n if (!isTheme(value)) {\n throw new Error(\n extname(file) === '.json'\n ? `${path} is not a theme: it has no tokens.`\n : `The export \"${exportName}\" of ${path} is not a theme.`,\n );\n }\n return value;\n}\n\n/** A report as text, one line per check that failed or that Panneau couldn't read. */\nexport function formatThemeReport(report: ThemeReport, label = 'Theme'): string {\n const lines = [\n `${label}: ${report.checks.length} contrast checks, ${report.failures.length} failed, ` +\n `${report.unchecked.length} unchecked, ${report.colorDifferences.length} similar chart colors.`,\n ];\n report.failures.forEach((check) => {\n lines.push(\n ` fail ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background}, ${String(check.ratio)}:1 < ${String(check.minimum)}:1`,\n );\n });\n report.colorDifferences.forEach((check) => {\n lines.push(\n ` similar ${check.scheme.padEnd(5)} chart colors ${check.first} and ` +\n `${check.second} with ${check.vision}: ${String(check.difference)} < ${String(check.minimum)}`,\n );\n });\n report.unchecked.forEach((check) => {\n lines.push(\n ` unchecked ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background} (check it in a browser)`,\n );\n });\n return lines.join('\\n');\n}\n\n/** Runs `panneau-check-theme` with its arguments, and returns the exit code. */\nexport async function runCheckTheme(\n args: readonly string[],\n output: { log: (text: string) => void; error: (text: string) => void } = console,\n load: ModuleImporter = importModule,\n): Promise<number> {\n const json = args.includes('--json');\n const exportIndex = args.indexOf('--export');\n const exportName = exportIndex >= 0 ? args[exportIndex + 1] : undefined;\n const files = args.filter(\n (arg, index) => !arg.startsWith('--') && (exportIndex < 0 || index !== exportIndex + 1),\n );\n const [file] = files;\n if (file === undefined || files.length > 1 || args.includes('--help')) {\n output.error(USAGE);\n return args.includes('--help') ? 0 : 2;\n }\n let theme: Theme;\n try {\n theme = await loadTheme(file, exportName, load);\n } catch (error) {\n output.error(error instanceof Error ? error.message : String(error));\n return 2;\n }\n const report = checkTheme(theme);\n output.log(json ? JSON.stringify(report, null, 2) : formatThemeReport(report, theme.label));\n return report.failures.length > 0 || report.colorDifferences.length > 0 ? 1 : 0;\n}\n"],"mappings":";;;;;AASA,IAAMO,QAAQ;;;;;AAMd,SAASC,QAAQC,OAAgC;CAC7C,OACI,OAAOA,UAAU,YACjBA,UAAU,QACV,YAAYA,SACZ,OAAOA,MAAMC,WAAW,YACxBD,MAAMC,WAAW;AAEzB;AAKA,IAAMK,gBAAgC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