@kanso-labs/kanso-ui 0.47.2 → 0.47.3

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.
@@ -29,8 +29,10 @@ type ColorSliderProps = Omit<ColorSliderProps$1, 'children' | 'className' | 'sty
29
29
  * one throws rather than converting — pass `colorSpace="hsl"` to convert it,
30
30
  * or give the value in the space you mean to slide.
31
31
  *
32
- * React Aria paints the gradient and names the value — "200°, cyan blue" —
33
- * so the readout beside the label is what it announces.
32
+ * React Aria paints the gradient and names the value — "200°, cyan blue".
33
+ * The readout beside the label shows the value rounded to the channel's
34
+ * step, as a ColorField editing the channel shows it: a hex converted to
35
+ * HSL has a hue of 256.43, which reads `256°`.
34
36
  *
35
37
  * The call site's `className` and `style` land on the slider as a whole,
36
38
  * which is the element a layout positions.
@@ -6,8 +6,9 @@ import { chequer } from "../../styles/chequer.js";
6
6
  import { thumbClassName, verticalThumbClassName } from "../../styles/color.js";
7
7
  import { mergeStatefulStyles } from "../../styles/merge.js";
8
8
  import { c } from "react/compiler-runtime";
9
+ import { useContext } from "react";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
- import { ColorSlider as ColorSlider$1, ColorThumb, SliderOutput, SliderTrack } from "react-aria-components";
11
+ import { ColorSlider as ColorSlider$1, ColorSliderStateContext, ColorThumb, SliderOutput, SliderTrack, useLocale } from "react-aria-components";
11
12
  // src/components/color-slider/index.tsx
12
13
  const styles = {
13
14
  root: {
@@ -43,6 +44,32 @@ const styles = {
43
44
  }
44
45
  };
45
46
  /**
47
+ * The slider's value as a ColorField editing the same channel shows it:
48
+ * snapped to the channel's step within its range, then formatted as React
49
+ * Aria formats the channel. React Aria's own readout formats the value
50
+ * unrounded, so a hex converted to HSL read `256.43°` beside a field
51
+ * reading `256°`, the decimals coming from the conversion rather than from
52
+ * anything the reader chose.
53
+ *
54
+ * Only the readout is rounded. The value, the arrow keys' steps from it and
55
+ * the `aria-valuetext` React Aria builds are React Aria's, as they were.
56
+ */
57
+ function ChannelReadout(t0) {
58
+ const $ = c(4);
59
+ const { channel } = t0;
60
+ const state = useContext(ColorSliderStateContext);
61
+ const { locale } = useLocale();
62
+ let t1;
63
+ if ($[0] !== channel || $[1] !== locale || $[2] !== state) {
64
+ t1 = state === null ? null : readoutOf(state.value, channel, locale);
65
+ $[0] = channel;
66
+ $[1] = locale;
67
+ $[2] = state;
68
+ $[3] = t1;
69
+ } else t1 = $[3];
70
+ return t1;
71
+ }
72
+ /**
46
73
  * A slider over one channel of a colour — hue, saturation, lightness, alpha
47
74
  * and the rest. The value is React Aria's: pass `value` with `onChange` to
48
75
  * control it, or `defaultValue`, as a CSS colour string or a `Color` from
@@ -57,25 +84,29 @@ const styles = {
57
84
  * one throws rather than converting — pass `colorSpace="hsl"` to convert it,
58
85
  * or give the value in the space you mean to slide.
59
86
  *
60
- * React Aria paints the gradient and names the value — "200°, cyan blue" —
61
- * so the readout beside the label is what it announces.
87
+ * React Aria paints the gradient and names the value — "200°, cyan blue".
88
+ * The readout beside the label shows the value rounded to the channel's
89
+ * step, as a ColorField editing the channel shows it: a hex converted to
90
+ * HSL has a hue of 256.43, which reads `256°`.
62
91
  *
63
92
  * The call site's `className` and `style` land on the slider as a whole,
64
93
  * which is the element a layout positions.
65
94
  */
66
95
  function ColorSlider(t0) {
67
- const $ = c(35);
96
+ const $ = c(37);
68
97
  let T0;
69
98
  let isDisabled;
70
99
  let label;
100
+ let props$1;
71
101
  let showValue;
72
102
  let t1;
73
103
  let t2;
74
104
  let t3;
75
105
  let vertical;
76
106
  if ($[0] !== t0) {
77
- const { isDisabled: t4, label: t5, showValue: t6, ...props$1 } = t0;
107
+ const { isDisabled: t4, label: t5, showValue: t6, ...t7 } = t0;
78
108
  label = t5;
109
+ props$1 = t7;
79
110
  isDisabled = t4 === void 0 ? false : t4;
80
111
  showValue = t6 === void 0 ? true : t6;
81
112
  vertical = props$1.orientation === "vertical";
@@ -87,109 +118,121 @@ function ColorSlider(t0) {
87
118
  $[1] = T0;
88
119
  $[2] = isDisabled;
89
120
  $[3] = label;
90
- $[4] = showValue;
91
- $[5] = t1;
92
- $[6] = t2;
93
- $[7] = t3;
94
- $[8] = vertical;
121
+ $[4] = props$1;
122
+ $[5] = showValue;
123
+ $[6] = t1;
124
+ $[7] = t2;
125
+ $[8] = t3;
126
+ $[9] = vertical;
95
127
  } else {
96
128
  T0 = $[1];
97
129
  isDisabled = $[2];
98
130
  label = $[3];
99
- showValue = $[4];
100
- t1 = $[5];
101
- t2 = $[6];
102
- t3 = $[7];
103
- vertical = $[8];
131
+ props$1 = $[4];
132
+ showValue = $[5];
133
+ t1 = $[6];
134
+ t2 = $[7];
135
+ t3 = $[8];
136
+ vertical = $[9];
104
137
  }
105
138
  let t4;
106
- if ($[9] !== label) {
139
+ if ($[10] !== label) {
107
140
  t4 = label === void 0 ? null : /* @__PURE__ */ jsx(FieldLabel, {
108
141
  variant: "group",
109
142
  children: label
110
143
  });
111
- $[9] = label;
112
- $[10] = t4;
113
- } else t4 = $[10];
144
+ $[10] = label;
145
+ $[11] = t4;
146
+ } else t4 = $[11];
114
147
  let t5;
115
- if ($[11] !== showValue) {
116
- t5 = showValue ? /* @__PURE__ */ jsx(SliderOutput, { className: "x1w5n3ug x1yicsit x1b35g6e xwth0xh xybisxh xvc5jky" }) : null;
117
- $[11] = showValue;
118
- $[12] = t5;
119
- } else t5 = $[12];
148
+ if ($[12] !== props$1 || $[13] !== showValue) {
149
+ t5 = showValue ? /* @__PURE__ */ jsx(SliderOutput, {
150
+ className: "x1w5n3ug x1yicsit x1b35g6e xwth0xh xybisxh xvc5jky",
151
+ children: /* @__PURE__ */ jsx(ChannelReadout, { channel: props$1.channel })
152
+ }) : null;
153
+ $[12] = props$1;
154
+ $[13] = showValue;
155
+ $[14] = t5;
156
+ } else t5 = $[14];
120
157
  let t6;
121
- if ($[13] !== t4 || $[14] !== t5) {
158
+ if ($[15] !== t4 || $[16] !== t5) {
122
159
  t6 = /* @__PURE__ */ jsxs("div", {
123
160
  className: "x1pha0wt x78zum5 x126z3so",
124
161
  children: [t4, t5]
125
162
  });
126
- $[13] = t4;
127
- $[14] = t5;
128
- $[15] = t6;
129
- } else t6 = $[15];
163
+ $[15] = t4;
164
+ $[16] = t5;
165
+ $[17] = t6;
166
+ } else t6 = $[17];
130
167
  let t7;
131
- if ($[16] !== isDisabled || $[17] !== vertical) {
168
+ if ($[18] !== isDisabled || $[19] !== vertical) {
132
169
  t7 = props(chequer.ground, styles.trackGround, vertical && styles.trackGroundVertical, isDisabled && styles.trackGroundDisabled);
133
- $[16] = isDisabled;
134
- $[17] = vertical;
135
- $[18] = t7;
136
- } else t7 = $[18];
170
+ $[18] = isDisabled;
171
+ $[19] = vertical;
172
+ $[20] = t7;
173
+ } else t7 = $[20];
137
174
  let t8;
138
- if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
175
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
139
176
  t8 = {
140
177
  0: { className: "x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6" },
141
178
  2: { className: "x1cpjm7i x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6 x1nc033x x8s3y0y" },
142
179
  1: { className: "x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1h6gzvc" },
143
180
  3: { className: "x1cpjm7i x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1nc033x x8s3y0y x1h6gzvc" }
144
181
  };
145
- $[19] = t8;
146
- } else t8 = $[19];
182
+ $[21] = t8;
183
+ } else t8 = $[21];
147
184
  const t9 = t8[!!vertical << 1 | !!isDisabled << 0];
148
185
  const t10 = vertical ? verticalThumbClassName : thumbClassName;
149
186
  let t11;
150
- if ($[20] !== t10) {
187
+ if ($[22] !== t10) {
151
188
  t11 = /* @__PURE__ */ jsx(ColorThumb, { className: t10 });
152
- $[20] = t10;
153
- $[21] = t11;
154
- } else t11 = $[21];
189
+ $[22] = t10;
190
+ $[23] = t11;
191
+ } else t11 = $[23];
155
192
  let t12;
156
- if ($[22] !== t11 || $[23] !== t9) {
193
+ if ($[24] !== t11 || $[25] !== t9) {
157
194
  t12 = /* @__PURE__ */ jsx(SliderTrack, {
158
195
  ...t9,
159
196
  children: t11
160
197
  });
161
- $[22] = t11;
162
- $[23] = t9;
163
- $[24] = t12;
164
- } else t12 = $[24];
198
+ $[24] = t11;
199
+ $[25] = t9;
200
+ $[26] = t12;
201
+ } else t12 = $[26];
165
202
  let t13;
166
- if ($[25] !== t12 || $[26] !== t7) {
203
+ if ($[27] !== t12 || $[28] !== t7) {
167
204
  t13 = /* @__PURE__ */ jsx("div", {
168
205
  ...t7,
169
206
  children: t12
170
207
  });
171
- $[25] = t12;
172
- $[26] = t7;
173
- $[27] = t13;
174
- } else t13 = $[27];
208
+ $[27] = t12;
209
+ $[28] = t7;
210
+ $[29] = t13;
211
+ } else t13 = $[29];
175
212
  let t14;
176
- if ($[28] !== T0 || $[29] !== t1 || $[30] !== t13 || $[31] !== t2 || $[32] !== t3 || $[33] !== t6) {
213
+ if ($[30] !== T0 || $[31] !== t1 || $[32] !== t13 || $[33] !== t2 || $[34] !== t3 || $[35] !== t6) {
177
214
  t14 = /* @__PURE__ */ jsxs(T0, {
178
215
  isDisabled: t1,
179
216
  ...t2,
180
217
  ...t3,
181
218
  children: [t6, t13]
182
219
  });
183
- $[28] = T0;
184
- $[29] = t1;
185
- $[30] = t13;
186
- $[31] = t2;
187
- $[32] = t3;
188
- $[33] = t6;
189
- $[34] = t14;
190
- } else t14 = $[34];
220
+ $[30] = T0;
221
+ $[31] = t1;
222
+ $[32] = t13;
223
+ $[33] = t2;
224
+ $[34] = t3;
225
+ $[35] = t6;
226
+ $[36] = t14;
227
+ } else t14 = $[36];
191
228
  return t14;
192
229
  }
230
+ function readoutOf(color, channel, locale) {
231
+ const { maxValue, minValue, step } = color.getChannelRange(channel);
232
+ const steps = Math.round((color.getChannelValue(channel) - minValue) / step);
233
+ const snapped = Math.min(maxValue, Math.max(minValue, minValue + steps * step));
234
+ return color.withChannelValue(channel, snapped).formatChannelValue(channel, locale);
235
+ }
193
236
  export { ColorSlider as default };
194
237
 
195
238
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_c","stylex","ColorSlider","RACColorSlider","groupStyles","chequer","thumbClassName","verticalThumbClassName","mergeStatefulStyles","styles","root","kzqmXN","$$css","rootVertical","kGNEyG","kZKoxP","trackGround","kaIpWk","kB7OPa","kqGvvJ","trackGroundDisabled","kSiTet","trackGroundVertical","kzQI83","kUOVxO","kAzted","className","label","showValue","t0","$","T0","isDisabled","t1","t2","t3","vertical","t4","t5","t6","props","undefined","orientation","t7","ground","t8","Symbol","for","0","2","1","3","t9","t10","t11","t12","t13","t14","RACSliderOutput","RACColorThumb","RACSliderTrack"],"sources":["../../../src/components/color-slider/index.tsx"],"sourcesContent":["'use client';\n\nimport type { RefAttributes } from 'react';\nimport 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 { groupStyles } from '../../field/styles';\nimport { chequer } from '../../styles/chequer';\nimport { thumbClassName, verticalThumbClassName } 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// Vertical, the strip stands up with the channel rising from the bottom, as\n// React Aria paints it, and takes Slider's geometry: 240px tall until the\n// call site's style says otherwise, the press target widened across rather\n// than along, and the handle centred across the strip.\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 root: {\n kzqmXN: \"xh8yej3\",\n $$css: true\n },\n rootVertical: {\n kGNEyG: \"x1cy8zhl\",\n kZKoxP: \"x1u5z0ei\",\n kzqmXN: \"x14atkfc\",\n $$css: true\n },\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 trackGroundVertical: {\n kZKoxP: \"xt7dq6l\",\n kzQI83: \"x1iyjqo2\",\n kzqmXN: \"x1kky2od\",\n kqGvvJ: \"x10im51j\",\n kUOVxO: \"xcwsfa8\",\n kAzted: \"x2lwn1j\",\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 & RefAttributes<HTMLDivElement>) {\n const vertical = props.orientation === 'vertical';\n return <RACColorSlider isDisabled={isDisabled} {...props} {...mergeStatefulStyles(stylex.props(groupStyles.root, styles.root, vertical && styles.rootVertical), props)}>\n <div className=\"x1pha0wt x78zum5 x126z3so\">\n {label === undefined ? null : <FieldLabel variant=\"group\">{label}</FieldLabel>}\n {showValue ? <RACSliderOutput className=\"x1w5n3ug x1yicsit x1b35g6e xwth0xh xybisxh xvc5jky\" /> : null}\n </div>\n <div {...stylex.props(chequer.ground, styles.trackGround, vertical && styles.trackGroundVertical, isDisabled && styles.trackGroundDisabled)}>\n <RACSliderTrack {...{\n 0: {\n className: \"x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6\"\n },\n 2: {\n className: \"x1cpjm7i x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6 x1nc033x x8s3y0y\"\n },\n 1: {\n className: \"x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1h6gzvc\"\n },\n 3: {\n className: \"x1cpjm7i x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1nc033x x8s3y0y x1h6gzvc\"\n }\n }[!!vertical << 1 | !!isDisabled << 0]}>\n <RACColorThumb className={vertical ? verticalThumbClassName : thumbClassName} />\n </RACSliderTrack>\n </div>\n </RACColorSlider>;\n}\nexport type { ColorSliderProps };\nexport default ColorSlider;"],"mappings":";;;;;;;;;;;AAgDA,MAAMS,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,OAAO;CACT;CACAC,cAAc;EACZC,QAAQ;EACRC,QAAQ;EACRJ,QAAQ;EACRC,OAAO;CACT;CACAI,aAAa;EACXD,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRP,QAAQ;EACRQ,QAAQ;EACRP,OAAO;CACT;CACAQ,qBAAqB;EACnBC,QAAQ;EACRT,OAAO;CACT;CACAU,qBAAqB;EACnBP,QAAQ;EACRQ,QAAQ;EACRZ,QAAQ;EACRQ,QAAQ;EACRK,QAAQ;EACRC,QAAQ;EACRb,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAAV,YAAA2B,IAAA;CAAA,MAAAC,IAAA9B,EAAA,EAAA;CAAA,IAAA+B;CAAA,IAAAC;CAAA,IAAAL;CAAA,IAAAC;CAAA,IAAAK;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAN,EAAA,OAAAD,IAAA;EAAqB,MAAA,EAAAG,YAAAK,IAAAV,OAAAW,IAAAV,WAAAW,IAAA,GAAAC,YAAAX;EAAAF,QAAAW;EACnBN,aAAAK,OAAAI,KAAAA,IAAA,QAAAJ;EAEAT,YAAAW,OAAAE,KAAAA,IAAA,OAAAF;EAGAH,WAAiBI,QAAKE,gBAAiB;EAC/BX,KAAA5B;EAA2B6B,KAAAA;EAAgBQ,KAAAA;EAAWL,KAAA3B,oBAAoBP,MA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MAAAL,EAAA,QAAAS,IAAA;EAtBHkB,MAAA,qBAAC,IAAD;GAA4BzB,YAAAA;GAAU,GAAMQ;GAAK,GAAML;GAAvD,UAAA,CACHI,IAIAiB,GALkB;;EAuBH1B,EAAA,MAAAC;EAAAD,EAAA,MAAAG;EAAAH,EAAA,MAAA0B;EAAA1B,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAS;EAAAT,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,OAvBZ2B;AAuBY"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","useContext","ColorSlider","RACColorSlider","RACColorSliderStateContext","useLocale","groupStyles","chequer","thumbClassName","verticalThumbClassName","mergeStatefulStyles","styles","root","kzqmXN","$$css","rootVertical","kGNEyG","kZKoxP","trackGround","kaIpWk","kB7OPa","kqGvvJ","trackGroundDisabled","kSiTet","trackGroundVertical","kzQI83","kUOVxO","kAzted","className","label","showValue","ChannelReadout","t0","$","channel","state","locale","t1","readoutOf","value","T0","isDisabled","props","t2","t3","vertical","t4","t5","t6","t7","undefined","orientation","ground","t8","Symbol","for","0","2","1","3","t9","t10","t11","t12","t13","t14","color","maxValue","minValue","step","getChannelRange","steps","Math","round","getChannelValue","snapped","min","max","withChannelValue","formatChannelValue","RACSliderOutput","RACColorThumb","RACSliderTrack"],"sources":["../../../src/components/color-slider/index.tsx"],"sourcesContent":["'use client';\n\nimport type { RefAttributes } from 'react';\nimport type { Color, ColorChannel, ColorSliderProps as RACColorSliderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { ColorSlider as RACColorSlider, ColorSliderStateContext as RACColorSliderStateContext, ColorThumb as RACColorThumb, SliderOutput as RACSliderOutput, SliderTrack as RACSliderTrack, useLocale } from 'react-aria-components';\nimport { FieldLabel } from '../../field';\nimport { groupStyles } from '../../field/styles';\nimport { chequer } from '../../styles/chequer';\nimport { thumbClassName, verticalThumbClassName } 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// Vertical, the strip stands up with the channel rising from the bottom, as\n// React Aria paints it, and takes Slider's geometry: 240px tall until the\n// call site's style says otherwise, the press target widened across rather\n// than along, and the handle centred across the strip.\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 root: {\n kzqmXN: \"xh8yej3\",\n $$css: true\n },\n rootVertical: {\n kGNEyG: \"x1cy8zhl\",\n kZKoxP: \"x1u5z0ei\",\n kzqmXN: \"x14atkfc\",\n $$css: true\n },\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 trackGroundVertical: {\n kZKoxP: \"xt7dq6l\",\n kzQI83: \"x1iyjqo2\",\n kzqmXN: \"x1kky2od\",\n kqGvvJ: \"x10im51j\",\n kUOVxO: \"xcwsfa8\",\n kAzted: \"x2lwn1j\",\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 * The slider's value as a ColorField editing the same channel shows it:\n * snapped to the channel's step within its range, then formatted as React\n * Aria formats the channel. React Aria's own readout formats the value\n * unrounded, so a hex converted to HSL read `256.43°` beside a field\n * reading `256°`, the decimals coming from the conversion rather than from\n * anything the reader chose.\n *\n * Only the readout is rounded. The value, the arrow keys' steps from it and\n * the `aria-valuetext` React Aria builds are React Aria's, as they were.\n */\nfunction ChannelReadout({\n channel\n}: {\n channel: ColorChannel;\n}) {\n const state = useContext(RACColorSliderStateContext);\n const {\n locale\n } = useLocale();\n return state === null ? null : readoutOf(state.value, channel, locale);\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 * The readout beside the label shows the value rounded to the channel's\n * step, as a ColorField editing the channel shows it: a hex converted to\n * HSL has a hue of 256.43, which reads `256°`.\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 & RefAttributes<HTMLDivElement>) {\n const vertical = props.orientation === 'vertical';\n return <RACColorSlider isDisabled={isDisabled} {...props} {...mergeStatefulStyles(stylex.props(groupStyles.root, styles.root, vertical && styles.rootVertical), props)}>\n <div className=\"x1pha0wt x78zum5 x126z3so\">\n {label === undefined ? null : <FieldLabel variant=\"group\">{label}</FieldLabel>}\n {showValue ? <RACSliderOutput className=\"x1w5n3ug x1yicsit x1b35g6e xwth0xh xybisxh xvc5jky\">\n <ChannelReadout channel={props.channel} />\n </RACSliderOutput> : null}\n </div>\n <div {...stylex.props(chequer.ground, styles.trackGround, vertical && styles.trackGroundVertical, isDisabled && styles.trackGroundDisabled)}>\n <RACSliderTrack {...{\n 0: {\n className: \"x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6\"\n },\n 2: {\n className: \"x1cpjm7i x1hmns74 x5yr21d x9f619 x1ypdohk xh8yej3 x1n2onr6 x1nc033x x8s3y0y\"\n },\n 1: {\n className: \"x1cpjm7i x1mtdikz xm4btww x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1h6gzvc\"\n },\n 3: {\n className: \"x1cpjm7i x1hmns74 x5yr21d x9f619 xh8yej3 x1n2onr6 x1nc033x x8s3y0y x1h6gzvc\"\n }\n }[!!vertical << 1 | !!isDisabled << 0]}>\n <RACColorThumb className={vertical ? verticalThumbClassName : thumbClassName} />\n </RACSliderTrack>\n </div>\n </RACColorSlider>;\n}\nfunction readoutOf(color: Color, channel: ColorChannel, locale: string) {\n const {\n maxValue,\n minValue,\n step\n } = color.getChannelRange(channel);\n const steps = Math.round((color.getChannelValue(channel) - minValue) / step);\n const snapped = Math.min(maxValue, Math.max(minValue, minValue + steps * step));\n return color.withChannelValue(channel, snapped).formatChannelValue(channel, locale);\n}\nexport type { ColorSliderProps };\nexport default ColorSlider;"],"mappings":";;;;;;;;;;;;AAiDA,MAAMY,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,OAAO;CACT;CACAC,cAAc;EACZC,QAAQ;EACRC,QAAQ;EACRJ,QAAQ;EACRC,OAAO;CACT;CACAI,aAAa;EACXD,QAAQ;EACRE,QAAQ;EACRC,QAAQ;EACRP,QAAQ;EACRQ,QAAQ;EACRP,OAAO;CACT;CACAQ,qBAAqB;EACnBC,QAAQ;EACRT,OAAO;CACT;CACAU,qBAAqB;EACnBP,QAAQ;EACRQ,QAAQ;EACRZ,QAAQ;EACRQ,QAAQ;EACRK,QAAQ;EACRC,QAAQ;EACRb,OAAO;CACT;AACF;;;;;;;;;;;;AA2BA,SAAAiB,eAAAC,IAAA;CAAA,MAAAC,IAAAlC,EAAA,CAAA;CAAwB,MAAA,EAAAmC,YAAAF;CAKtB,MAAAG,QAAclC,WAAWG,uBAA0B;CACnD,MAAA,EAAAgC,WAEI/B,UAAU;CAAE,IAAAgC;CAAA,IAAAJ,EAAA,OAAAC,WAAAD,EAAA,OAAAG,UAAAH,EAAA,OAAAE,OAAA;EACTE,KAAAF,UAAU,OAAV,OAAwBG,UAAUH,MAAKI,OAAQL,SAASE,MAAM;EAACH,EAAA,KAAAC;EAAAD,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAA/DI;AAA+D;;;;;;;;;;;;;;;;;;;;;;;;AA0BxE,SAAAnC,YAAA8B,IAAA;CAAA,MAAAC,IAAAlC,EAAA,EAAA;CAAA,IAAAyC;CAAA,IAAAC;CAAA,IAAAZ;CAAA,IAAAa;CAAA,IAAAZ;CAAA,IAAAO;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAZ,EAAA,OAAAD,IAAA;EAAqB,MAAA,EAAAS,YA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og` opens it, and one given `slot="close"` anywhere inside the
19
19
  * content closes it; neither needs a part of its own.
20
20
  *
21
+ * Full screen, the header leads with its close button and ends in the
22
+ * footer's actions, and there is no action bar: the full-screen dialog's
23
+ * dismissive action is its close button, and its confirming one a text
24
+ * button at the header's trailing end. A dialog that fills a phone's window
25
+ * therefore gives its footer the confirming action alone, as below; a Cancel
26
+ * beside it would be drawn in the header too.
27
+ *
21
28
  * ```tsx
22
29
  * <Dialog>
23
30
  * <Button>Open dialog</Button>
@@ -30,9 +37,6 @@ type DialogProps = Omit<DialogTriggerProps, 'children'> & {
30
37
  * </Dialog.Header>
31
38
  * <Dialog.Body>Supporting text</Dialog.Body>
32
39
  * <Dialog.Footer>
33
- * <Button slot="close" variant="text">
34
- * Cancel
35
- * </Button>
36
40
  * <Button onPress={confirm} slot="close" variant="text">
37
41
  * Confirm
38
42
  * </Button>
@@ -92,9 +96,12 @@ declare function DialogBody({ ref: callerRef, ...props }: HTMLAttributes<HTMLDiv
92
96
  */
93
97
  declare function DialogContent({ children, className, container, defaultOpen, isDismissable, isKeyboardDismissDisabled, isOpen, onOpenChange, ref, style, ...props }: DialogContentProps & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
94
98
  /**
95
- * The dialog's actions. Full screen they are the action bar on the window's
96
- * bottom edge, which a toast rises clear of while the dialog is open, so a
97
- * tap meant for one of them never lands on the toast's own action instead.
99
+ * The dialog's actions. Full screen they are drawn at the trailing end of
100
+ * `Dialog.Header`, where the page's full-screen dialog has its confirming
101
+ * action. In a dialog with no header they are the action bar on the
102
+ * window's bottom edge instead, which a toast rises clear of while the
103
+ * dialog is open, so a tap meant for one of them never lands on the toast's
104
+ * own action instead.
98
105
  */
99
106
  declare function DialogFooter({ ref: callerRef, ...props }: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
100
107
  declare function DialogHeader(props: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>): import("react").JSX.Element;
@@ -9,8 +9,9 @@ import { overlay } from "../../styles/overlay.js";
9
9
  import { sizing, typography } from "../../tokens/design.tokens.stylex.js";
10
10
  import { c } from "react/compiler-runtime";
11
11
  import { createContext, useContext, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
12
- import { jsx } from "react/jsx-runtime";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
13
  import { Dialog as Dialog$1, DialogTrigger, Heading, HeadingContext, Modal, ModalOverlay, useSlottedContext } from "react-aria-components";
14
+ import { createPortal } from "react-dom";
14
15
  // src/components/dialog/index.tsx
15
16
  `${sizing.controlSm}${typography.headlineSmallLineHeight}`;
16
17
  const FULL_SCREEN = "(width < 600px)";
@@ -54,6 +55,8 @@ const basic = {
54
55
  };
55
56
  const BasicContext = createContext(false);
56
57
  const HeaderContext = createContext(false);
58
+ const FooterSlotContext = createContext(null);
59
+ const SetFooterSlotContext = createContext(null);
57
60
  const DescriptionContext = createContext(null);
58
61
  /**
59
62
  * A modal dialog centred over the page, and the same dialog filling the
@@ -70,6 +73,13 @@ const DescriptionContext = createContext(null);
70
73
  * `Dialog` opens it, and one given `slot="close"` anywhere inside the
71
74
  * content closes it; neither needs a part of its own.
72
75
  *
76
+ * Full screen, the header leads with its close button and ends in the
77
+ * footer's actions, and there is no action bar: the full-screen dialog's
78
+ * dismissive action is its close button, and its confirming one a text
79
+ * button at the header's trailing end. A dialog that fills a phone's window
80
+ * therefore gives its footer the confirming action alone, as below; a Cancel
81
+ * beside it would be drawn in the header too.
82
+ *
73
83
  * ```tsx
74
84
  * <Dialog>
75
85
  * <Button>Open dialog</Button>
@@ -82,9 +92,6 @@ const DescriptionContext = createContext(null);
82
92
  * </Dialog.Header>
83
93
  * <Dialog.Body>Supporting text</Dialog.Body>
84
94
  * <Dialog.Footer>
85
- * <Button slot="close" variant="text">
86
- * Cancel
87
- * </Button>
88
95
  * <Button onPress={confirm} slot="close" variant="text">
89
96
  * Confirm
90
97
  * </Button>
@@ -206,7 +213,7 @@ function DialogBody(t0) {
206
213
  * over it, and React Aria's popovers and menus draw above both.
207
214
  */
208
215
  function DialogContent(t0) {
209
- const $ = c(42);
216
+ const $ = c(45);
210
217
  let children;
211
218
  let className;
212
219
  let container;
@@ -248,6 +255,7 @@ function DialogContent(t0) {
248
255
  const isDismissable = t1 === void 0 ? true : t1;
249
256
  const isBasic = props$1.role === "alertdialog";
250
257
  const [body, setBody] = useState();
258
+ const [slot, setSlot] = useState(null);
251
259
  const t2 = isBasic ? setBody : null;
252
260
  let t3;
253
261
  if ($[12] !== isBasic) {
@@ -305,16 +313,19 @@ function DialogContent(t0) {
305
313
  } else t8 = $[26];
306
314
  let t9;
307
315
  if ($[27] !== container || $[28] !== defaultOpen || $[29] !== isDismissable || $[30] !== isKeyboardDismissDisabled || $[31] !== isOpen || $[32] !== onOpenChange || $[33] !== t3 || $[34] !== t8) {
308
- t9 = /* @__PURE__ */ jsx(OverlayScope, { children: /* @__PURE__ */ jsx(ModalOverlay, {
309
- defaultOpen,
310
- isDismissable,
311
- isKeyboardDismissDisabled,
312
- isOpen,
313
- onOpenChange,
314
- UNSTABLE_portalContainer: container,
315
- ...t3,
316
- children: t8
317
- }) });
316
+ t9 = /* @__PURE__ */ jsx(SetFooterSlotContext, {
317
+ value: setSlot,
318
+ children: /* @__PURE__ */ jsx(OverlayScope, { children: /* @__PURE__ */ jsx(ModalOverlay, {
319
+ defaultOpen,
320
+ isDismissable,
321
+ isKeyboardDismissDisabled,
322
+ isOpen,
323
+ onOpenChange,
324
+ UNSTABLE_portalContainer: container,
325
+ ...t3,
326
+ children: t8
327
+ }) })
328
+ });
318
329
  $[27] = container;
319
330
  $[28] = defaultOpen;
320
331
  $[29] = isDismissable;
@@ -326,38 +337,54 @@ function DialogContent(t0) {
326
337
  $[35] = t9;
327
338
  } else t9 = $[35];
328
339
  let t10;
329
- if ($[36] !== t2 || $[37] !== t9) {
330
- t10 = /* @__PURE__ */ jsx(DescriptionContext, {
331
- value: t2,
340
+ if ($[36] !== slot || $[37] !== t9) {
341
+ t10 = /* @__PURE__ */ jsx(FooterSlotContext, {
342
+ value: slot,
332
343
  children: t9
333
344
  });
334
- $[36] = t2;
345
+ $[36] = slot;
335
346
  $[37] = t9;
336
347
  $[38] = t10;
337
348
  } else t10 = $[38];
338
349
  let t11;
339
- if ($[39] !== isBasic || $[40] !== t10) {
340
- t11 = /* @__PURE__ */ jsx(BasicContext, {
341
- value: isBasic,
350
+ if ($[39] !== t10 || $[40] !== t2) {
351
+ t11 = /* @__PURE__ */ jsx(DescriptionContext, {
352
+ value: t2,
342
353
  children: t10
343
354
  });
344
- $[39] = isBasic;
345
- $[40] = t10;
355
+ $[39] = t10;
356
+ $[40] = t2;
346
357
  $[41] = t11;
347
358
  } else t11 = $[41];
348
- return t11;
359
+ let t12;
360
+ if ($[42] !== isBasic || $[43] !== t11) {
361
+ t12 = /* @__PURE__ */ jsx(BasicContext, {
362
+ value: isBasic,
363
+ children: t11
364
+ });
365
+ $[42] = isBasic;
366
+ $[43] = t11;
367
+ $[44] = t12;
368
+ } else t12 = $[44];
369
+ return t12;
349
370
  }
350
371
  /**
351
- * The dialog's actions. Full screen they are the action bar on the window's
352
- * bottom edge, which a toast rises clear of while the dialog is open, so a
353
- * tap meant for one of them never lands on the toast's own action instead.
372
+ * The dialog's actions. Full screen they are drawn at the trailing end of
373
+ * `Dialog.Header`, where the page's full-screen dialog has its confirming
374
+ * action. In a dialog with no header they are the action bar on the
375
+ * window's bottom edge instead, which a toast rises clear of while the
376
+ * dialog is open, so a tap meant for one of them never lands on the toast's
377
+ * own action instead.
354
378
  */
355
379
  function DialogFooter(t0) {
356
- const $ = c(6);
380
+ const $ = c(9);
357
381
  const { ref: callerRef, ...props } = t0;
358
382
  const isBasic = useContext(BasicContext);
383
+ const fullScreen = useFullScreen() && !isBasic;
384
+ const footerSlot = useContext(FooterSlotContext);
385
+ const slot = fullScreen ? footerSlot : null;
359
386
  const ref = useRef(null);
360
- useHoldBottomEdge(ref, useFullScreen() && !isBasic);
387
+ useHoldBottomEdge(ref, fullScreen && slot === null);
361
388
  const t1 = callerRef ?? void 0;
362
389
  let t2;
363
390
  if ($[0] !== t1) {
@@ -366,10 +393,10 @@ function DialogFooter(t0) {
366
393
  $[1] = t2;
367
394
  } else t2 = $[1];
368
395
  const merged = t2;
369
- const t3 = mergeStyles({
396
+ const t3 = mergeStyles(slot === null ? {
370
397
  0: { className: "x6s0dn4 x12smttz x1ejq31n x1vv4zg8 x178xt8z x9f619 x78zum5 x2lah0s x1a02dak x126z3so x13a6bvl xnvi70j x8i8c5o x1pr6p50 x13h71tw xs3zajk xg0ps1x" },
371
398
  1: { className: "x6s0dn4 x12smttz x178xt8z x9f619 x78zum5 x2lah0s x1a02dak x126z3so x13a6bvl xg0ps1x x1ejq31n x8i8c5o x13h71tw" }
372
- }[!!isBasic << 0], props);
399
+ }[!!isBasic << 0] : { className: "x6s0dn4 x9f619 x78zum5 x2lah0s x126z3so x14yy4lh" }, props);
373
400
  let t4;
374
401
  if ($[2] !== merged || $[3] !== props || $[4] !== t3) {
375
402
  t4 = /* @__PURE__ */ jsx("div", {
@@ -382,11 +409,21 @@ function DialogFooter(t0) {
382
409
  $[4] = t3;
383
410
  $[5] = t4;
384
411
  } else t4 = $[5];
385
- return t4;
412
+ const footer = t4;
413
+ let t5;
414
+ if ($[6] !== footer || $[7] !== slot) {
415
+ t5 = slot === null ? footer : createPortal(footer, slot);
416
+ $[6] = footer;
417
+ $[7] = slot;
418
+ $[8] = t5;
419
+ } else t5 = $[8];
420
+ return t5;
386
421
  }
387
422
  function DialogHeader(props) {
388
- const $ = c(6);
423
+ const $ = c(10);
389
424
  const isBasic = useContext(BasicContext);
425
+ const fullScreen = useFullScreen() && !isBasic;
426
+ const setFooterSlot = useContext(SetFooterSlotContext);
390
427
  let t0;
391
428
  if ($[0] !== isBasic || $[1] !== props) {
392
429
  t0 = mergeStyles({
@@ -398,19 +435,31 @@ function DialogHeader(props) {
398
435
  $[2] = t0;
399
436
  } else t0 = $[2];
400
437
  let t1;
401
- if ($[3] !== props || $[4] !== t0) {
402
- t1 = /* @__PURE__ */ jsx(HeaderContext, {
438
+ if ($[3] !== fullScreen || $[4] !== setFooterSlot) {
439
+ t1 = fullScreen && setFooterSlot !== null ? /* @__PURE__ */ jsx("div", {
440
+ ref: setFooterSlot,
441
+ className: "xjp7ctv"
442
+ }) : null;
443
+ $[3] = fullScreen;
444
+ $[4] = setFooterSlot;
445
+ $[5] = t1;
446
+ } else t1 = $[5];
447
+ let t2;
448
+ if ($[6] !== props || $[7] !== t0 || $[8] !== t1) {
449
+ t2 = /* @__PURE__ */ jsx(HeaderContext, {
403
450
  value: true,
404
- children: /* @__PURE__ */ jsx("div", {
451
+ children: /* @__PURE__ */ jsxs("div", {
405
452
  ...props,
406
- ...t0
453
+ ...t0,
454
+ children: [props.children, t1]
407
455
  })
408
456
  });
409
- $[3] = props;
410
- $[4] = t0;
411
- $[5] = t1;
412
- } else t1 = $[5];
413
- return t1;
457
+ $[6] = props;
458
+ $[7] = t0;
459
+ $[8] = t1;
460
+ $[9] = t2;
461
+ } else t2 = $[9];
462
+ return t2;
414
463
  }
415
464
  /**
416
465
  * Names the dialog. Rendered through React Aria's title slot, which is what
@@ -424,12 +473,12 @@ function DialogTitle(props) {
424
473
  let t0;
425
474
  if ($[0] !== isBasic || $[1] !== isHeaded || $[2] !== props) {
426
475
  t0 = mergeStyles({
427
- 0: { className: "x9f619 x139gbkf x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xj0a0fe" },
428
- 4: { className: "x9f619 x139gbkf x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xj0a0fe xs2ltda xa4amcs" },
476
+ 0: { className: "x9f619 x139gbkf xy5ce5c x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xrnjqs5 xj0a0fe" },
477
+ 4: { className: "x9f619 x139gbkf xy5ce5c x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xrnjqs5 xj0a0fe xs2ltda xa4amcs" },
429
478
  2: { className: "x9f619 x139gbkf x1ghz6dp xeuugli xj0a0fe x1fz0g89 xkb6epg x76yrz5 x1s1qhaa x1voeury" },
430
479
  6: { className: "x9f619 x139gbkf x1ghz6dp xeuugli xj0a0fe xs2ltda xa4amcs x1fz0g89 xkb6epg x76yrz5 x1s1qhaa x1voeury" },
431
- 1: { className: "x9f619 x139gbkf x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xj0a0fe xs2ltda" },
432
- 5: { className: "x9f619 x139gbkf x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xj0a0fe xs2ltda" },
480
+ 1: { className: "x9f619 x139gbkf xy5ce5c x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xrnjqs5 xj0a0fe xs2ltda" },
481
+ 5: { className: "x9f619 x139gbkf xy5ce5c x1fz0g89 xl849ld xkb6epg xcji80f x76yrz5 x6ksu6j x1s1qhaa x1khanjg x1voeury xrr2tf9 x1ghz6dp xeuugli xrnjqs5 xj0a0fe xs2ltda" },
433
482
  3: { className: "x9f619 x139gbkf x1ghz6dp xeuugli xj0a0fe x1fz0g89 xkb6epg x76yrz5 x1s1qhaa x1voeury xs2ltda" },
434
483
  7: { className: "x9f619 x139gbkf x1ghz6dp xeuugli xj0a0fe x1fz0g89 xkb6epg x76yrz5 x1s1qhaa x1voeury xs2ltda" }
435
484
  }[!!isHeaded << 2 | !!isBasic << 1 | !!(isBasic && isHeaded) << 0], props);