@kanso-labs/react-native-kanso-ui 0.11.24 → 0.11.25

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.
@@ -35,6 +35,7 @@ const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>
35
35
  height: SWATCH,
36
36
  width: SWATCH
37
37
  },
38
+ swatchDisabled: { opacity: stateLayerOpacity.disabledContent },
38
39
  trigger: {
39
40
  alignItems: "center",
40
41
  alignSelf: "flex-start",
@@ -73,7 +74,7 @@ const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>
73
74
  * places.
74
75
  */
75
76
  function ColorPicker(t0) {
76
- const $ = c(68);
77
+ const $ = c(69);
77
78
  const { alpha: t1, children, defaultOpen, defaultValue, isDisabled: t2, isOpen, label, onChange, onOpenChange, ref, style, testID, value } = t0;
78
79
  const alpha = t1 === void 0 ? false : t1;
79
80
  const isDisabled = t2 === void 0 ? false : t2;
@@ -160,38 +161,42 @@ function ColorPicker(t0) {
160
161
  const t14 = "button";
161
162
  const t15 = composeStyles(styles.trigger, isDisabled ? styles.disabled : void 0, feedback.ring, style);
162
163
  const t16 = feedback.layer;
163
- let t17;
164
- if ($[22] !== state.color || $[23] !== styles.swatch) {
165
- t17 = /* @__PURE__ */ jsx(ColorSwatch, {
166
- color: state.color,
167
- style: styles.swatch
168
- });
169
- $[22] = state.color;
170
- $[23] = styles.swatch;
171
- $[24] = t17;
172
- } else t17 = $[24];
173
- let t18;
174
- if ($[25] !== colors.onSurface || $[26] !== isDisabled || $[27] !== labelRole || $[28] !== stateLayerOpacity) {
175
- t18 = composeStyles(labelRole, { color: isDisabled ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent) : colors.onSurface });
176
- $[25] = colors.onSurface;
177
- $[26] = isDisabled;
178
- $[27] = labelRole;
179
- $[28] = stateLayerOpacity;
180
- $[29] = t18;
181
- } else t18 = $[29];
164
+ const T1 = ColorSwatch;
165
+ const t17 = state.color;
166
+ const t18 = composeStyles(styles.swatch, isDisabled ? styles.swatchDisabled : void 0);
182
167
  let t19;
183
- if ($[30] !== label || $[31] !== t18) {
184
- t19 = /* @__PURE__ */ jsx(Text, {
185
- style: t18,
186
- children: label
168
+ if ($[22] !== T1 || $[23] !== state.color || $[24] !== t18) {
169
+ t19 = /* @__PURE__ */ jsx(T1, {
170
+ color: t17,
171
+ style: t18
187
172
  });
188
- $[30] = label;
189
- $[31] = t18;
190
- $[32] = t19;
191
- } else t19 = $[32];
173
+ $[22] = T1;
174
+ $[23] = state.color;
175
+ $[24] = t18;
176
+ $[25] = t19;
177
+ } else t19 = $[25];
192
178
  let t20;
193
- if ($[33] !== T0 || $[34] !== feedback.handlers || $[35] !== feedback.layer || $[36] !== isDisabled || $[37] !== overlay.isOpen || $[38] !== show || $[39] !== t10 || $[40] !== t12 || $[41] !== t13 || $[42] !== t15 || $[43] !== t17 || $[44] !== t19 || $[45] !== testID) {
194
- t20 = /* @__PURE__ */ jsxs(T0, {
179
+ if ($[26] !== colors.onSurface || $[27] !== isDisabled || $[28] !== labelRole || $[29] !== stateLayerOpacity) {
180
+ t20 = composeStyles(labelRole, { color: isDisabled ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent) : colors.onSurface });
181
+ $[26] = colors.onSurface;
182
+ $[27] = isDisabled;
183
+ $[28] = labelRole;
184
+ $[29] = stateLayerOpacity;
185
+ $[30] = t20;
186
+ } else t20 = $[30];
187
+ let t21;
188
+ if ($[31] !== label || $[32] !== t20) {
189
+ t21 = /* @__PURE__ */ jsx(Text, {
190
+ style: t20,
191
+ children: label
192
+ });
193
+ $[31] = label;
194
+ $[32] = t20;
195
+ $[33] = t21;
196
+ } else t21 = $[33];
197
+ let t22;
198
+ if ($[34] !== T0 || $[35] !== feedback.handlers || $[36] !== feedback.layer || $[37] !== isDisabled || $[38] !== overlay.isOpen || $[39] !== show || $[40] !== t10 || $[41] !== t12 || $[42] !== t13 || $[43] !== t15 || $[44] !== t19 || $[45] !== t21 || $[46] !== testID) {
199
+ t22 = /* @__PURE__ */ jsxs(T0, {
195
200
  ...t8,
196
201
  "aria-expanded": t9,
197
202
  "aria-label": t10,
@@ -204,35 +209,35 @@ function ColorPicker(t0) {
204
209
  testID,
205
210
  children: [
206
211
  t16,
207
- t17,
208
- t19
212
+ t19,
213
+ t21
209
214
  ]
210
215
  });
211
- $[33] = T0;
212
- $[34] = feedback.handlers;
213
- $[35] = feedback.layer;
214
- $[36] = isDisabled;
215
- $[37] = overlay.isOpen;
216
- $[38] = show;
217
- $[39] = t10;
218
- $[40] = t12;
219
- $[41] = t13;
220
- $[42] = t15;
221
- $[43] = t17;
216
+ $[34] = T0;
217
+ $[35] = feedback.handlers;
218
+ $[36] = feedback.layer;
219
+ $[37] = isDisabled;
220
+ $[38] = overlay.isOpen;
221
+ $[39] = show;
222
+ $[40] = t10;
223
+ $[41] = t12;
224
+ $[42] = t13;
225
+ $[43] = t15;
222
226
  $[44] = t19;
223
- $[45] = testID;
224
- $[46] = t20;
225
- } else t20 = $[46];
226
- const t21 = overlay.isOpen;
227
- let t22;
228
- if ($[47] !== state) {
229
- t22 = pickedOf(state);
230
- $[47] = state;
231
- $[48] = t22;
232
- } else t22 = $[48];
233
- let t23;
234
- if ($[49] !== alpha || $[50] !== children || $[51] !== isDisabled || $[52] !== label || $[53] !== locale || $[54] !== styles.body) {
235
- t23 = children ?? /* @__PURE__ */ jsxs(View, {
227
+ $[45] = t21;
228
+ $[46] = testID;
229
+ $[47] = t22;
230
+ } else t22 = $[47];
231
+ const t23 = overlay.isOpen;
232
+ let t24;
233
+ if ($[48] !== state) {
234
+ t24 = pickedOf(state);
235
+ $[48] = state;
236
+ $[49] = t24;
237
+ } else t24 = $[49];
238
+ let t25;
239
+ if ($[50] !== alpha || $[51] !== children || $[52] !== isDisabled || $[53] !== label || $[54] !== locale || $[55] !== styles) {
240
+ t25 = children ?? /* @__PURE__ */ jsxs(View, {
236
241
  style: styles.body,
237
242
  children: [
238
243
  /* @__PURE__ */ jsx(ColorArea, {
@@ -259,49 +264,49 @@ function ColorPicker(t0) {
259
264
  })
260
265
  ]
261
266
  });
262
- $[49] = alpha;
263
- $[50] = children;
264
- $[51] = isDisabled;
265
- $[52] = label;
266
- $[53] = locale;
267
- $[54] = styles.body;
268
- $[55] = t23;
269
- } else t23 = $[55];
270
- let t24;
271
- if ($[56] !== t22 || $[57] !== t23) {
272
- t24 = /* @__PURE__ */ jsx(PickedColorContext, {
273
- value: t22,
274
- children: t23
267
+ $[50] = alpha;
268
+ $[51] = children;
269
+ $[52] = isDisabled;
270
+ $[53] = label;
271
+ $[54] = locale;
272
+ $[55] = styles;
273
+ $[56] = t25;
274
+ } else t25 = $[56];
275
+ let t26;
276
+ if ($[57] !== t24 || $[58] !== t25) {
277
+ t26 = /* @__PURE__ */ jsx(PickedColorContext, {
278
+ value: t24,
279
+ children: t25
275
280
  });
276
- $[56] = t22;
277
- $[57] = t23;
278
- $[58] = t24;
279
- } else t24 = $[58];
280
- let t25;
281
- if ($[59] !== close || $[60] !== label || $[61] !== overlay.isOpen || $[62] !== t24 || $[63] !== trigger) {
282
- t25 = /* @__PURE__ */ jsx(PickerPopup, {
281
+ $[57] = t24;
282
+ $[58] = t25;
283
+ $[59] = t26;
284
+ } else t26 = $[59];
285
+ let t27;
286
+ if ($[60] !== close || $[61] !== label || $[62] !== overlay.isOpen || $[63] !== t26 || $[64] !== trigger) {
287
+ t27 = /* @__PURE__ */ jsx(PickerPopup, {
283
288
  anchor,
284
289
  close,
285
- isOpen: t21,
290
+ isOpen: t23,
286
291
  label,
287
292
  trigger,
288
- children: t24
293
+ children: t26
289
294
  });
290
- $[59] = close;
291
- $[60] = label;
292
- $[61] = overlay.isOpen;
293
- $[62] = t24;
294
- $[63] = trigger;
295
- $[64] = t25;
296
- } else t25 = $[64];
297
- let t26;
298
- if ($[65] !== t20 || $[66] !== t25) {
299
- t26 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t20, t25] });
300
- $[65] = t20;
301
- $[66] = t25;
302
- $[67] = t26;
303
- } else t26 = $[67];
304
- return t26;
295
+ $[60] = close;
296
+ $[61] = label;
297
+ $[62] = overlay.isOpen;
298
+ $[63] = t26;
299
+ $[64] = trigger;
300
+ $[65] = t27;
301
+ } else t27 = $[65];
302
+ let t28;
303
+ if ($[66] !== t22 || $[67] !== t27) {
304
+ t28 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t22, t27] });
305
+ $[66] = t22;
306
+ $[67] = t27;
307
+ $[68] = t28;
308
+ } else t28 = $[68];
309
+ return t28;
305
310
  }
306
311
  function pickedOf(state) {
307
312
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","HostInstance","StyleProp","TextStyle","View","ViewStyle","Color","ColorPickerState","useRef","useState","NativeView","Pressable","StyleSheet","Text","parseColor","useColorPickerState","useOverlayTriggerState","PickedColor","useLocaleOf","useMessages","PickerPopup","hitSlop","usePressFeedback","refsOf","colorNameOf","PickedColorContext","withOpacity","useTheme","composeStyles","themedStyles","useTypeRole","ColorArea","ColorField","ColorSlider","ColorSwatch","SWATCH","SURFACE_WIDTH","CHANNELS","stylesOf","colors","radii","spacing","stateLayerOpacity","create","body","boxSizing","gap","md","maxWidth","padding","lg","width","disabled","backgroundColor","onSurface","disabledContainer","swatch","height","trigger","alignItems","alignSelf","surfaceContainerLow","borderRadius","pill","flexDirection","sm","paddingHorizontal","paddingVertical","ColorPickerProps","alpha","children","defaultOpen","defaultValue","isDisabled","isOpen","label","onChange","value","onOpenChange","ref","style","testID","ColorPicker","t0","$","_c","t1","t2","undefined","theme","styles","locale","messages","labelRole","t3","state","t4","overlay","close","open","show","anchor","setTrigger","t5","t6","color","corners","feedback","t7","transparent","name","T0","t8","handlers","t9","t10","t11","t12","t13","t14","t15","ring","t16","layer","t17","t18","disabledContent","t19","t20","t21","t22","pickedOf","t23","getChannelName","t24","t25","t26","setColor","_c","NativeView"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n HostInstance,\n StyleProp,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native'\nimport type { Color } from 'react-stately'\nimport type { ColorPickerState } from 'react-stately/useColorPickerState'\n\nimport { useRef, useState } from 'react'\nimport { View as NativeView, Pressable, StyleSheet, Text } from 'react-native'\nimport { parseColor } from 'react-stately'\nimport { useColorPickerState } from 'react-stately/useColorPickerState'\nimport { useOverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport type { PickedColor } from '../../swatch'\n\nimport { useLocaleOf, useMessages } from '../../i18n/provider'\nimport { PickerPopup } from '../../picker'\nimport { hitSlop, usePressFeedback } from '../../press'\nimport { refsOf } from '../../ref'\nimport { colorNameOf, PickedColorContext } from '../../swatch'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\nimport { ColorArea } from '../color-area'\nimport { ColorField } from '../color-field'\nimport { ColorSlider } from '../color-slider'\nimport { ColorSwatch } from '../color-swatch'\n\n// Every colour control in one, as kanso-ui's ColorPicker composes them: a\n// swatch and a label as the trigger, and a plane, a hue slider, an alpha\n// slider and a hex field on the surface it opens. The value is React\n// Stately's `useColorPickerState`, which the controls on the surface take\n// through src/swatch's PickedColorContext, as React Aria's picker hands its\n// value to each control's context on web. So an arrangement passed as\n// `children` shares the value the same way, whatever it holds.\n//\n// Material Design carries no page for a colour picker. What it does carry is\n// the text fields page, which the field inside draws through, and the surface\n// a date picker opens on, which this one shares through src/picker. Three\n// choices are web's own, and kept.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch on\n// its own is a coloured square with no affordance, and a screen reader would\n// be told a colour rather than an action. It is a pill on surface container\n// low, the swatch at 24dp, the height of the label's line rather than a\n// swatch's own 40dp, and the label in label large, with the state layer and\n// ripple every control here draws in on surface. A screen reader hears the\n// label and then the colour, \"Label, dark purple\", where web's reads the\n// swatch's name first: the visible label leads, so a voice command that says\n// it finds the button.\n//\n// **Hue is a slider rather than a wheel.** A wheel and the plane want the\n// same room, and would make the surface square and large; the strip sits\n// under the plane at the width it already has. ColorWheel is for a picker\n// that wants to be round, which a call site builds as `children`.\n//\n// **It is docked from the medium window size up and modal below it**, the\n// date picker's pairing, through the same src/picker surface: a 280dp\n// surface anchored to a trigger is out of reach on a phone, and a centred one\n// on a tablet covers a form for no reason. Its dismissal, its motion and\n// where a screen reader goes are the date picker's.\n//\n// One thing the picker does that its parts do not. **The plane and the hue\n// slider are read in HSL.** A channel has to belong to the value's own space\n// or React Stately throws, and a hex is read as RGB, which has no saturation,\n// so `<ColorPicker defaultValue=\"#6750A4\" />` would throw outright. Reading\n// the two in HSL is what lets the picker take any notation. A change made on\n// either reports the colour in HSL, as React Stately's area and slider do on\n// web, and the field shows it as hex whatever space it is in.\n//\n// **Disabled reaches every control on the surface**, not only the trigger.\n// React Stately's picker state carries no disabled state, and the surface\n// opens independently of the trigger, so a disabled picker can still be on\n// screen: already open when a form disables it, or opened from outside. An\n// arrangement passed as `children` is the call site's own to disable.\n\n// The swatch in the trigger, at the height of the label's line rather than\n// the 40dp a swatch takes on its own.\nconst SWATCH = 24\n\n// The surface's width, as web's: room for the plane and a hex field.\nconst SURFACE_WIDTH = 280\n\n// Any HSL colour names the channels the two sliders draw. Their labels are\n// read off it in the locale, as React Stately words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)')\n\nconst stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>\n StyleSheet.create({\n // What the surface holds, stacked: the plane, the sliders, then the\n // field. One column, so a picker reads top to bottom.\n body: {\n boxSizing: 'border-box',\n gap: spacing.md,\n maxWidth: '100%',\n padding: spacing.lg,\n width: SURFACE_WIDTH,\n },\n disabled: {\n backgroundColor: withOpacity(\n colors.onSurface,\n stateLayerOpacity.disabledContainer,\n ),\n },\n swatch: {\n height: SWATCH,\n width: SWATCH,\n },\n trigger: {\n alignItems: 'center',\n alignSelf: 'flex-start',\n backgroundColor: colors.surfaceContainerLow,\n borderRadius: radii.pill,\n boxSizing: 'border-box',\n flexDirection: 'row',\n gap: spacing.sm,\n paddingHorizontal: spacing.md,\n paddingVertical: spacing.sm,\n },\n }),\n)\n\ntype ColorPickerProps = {\n /** Whether the alpha slider is drawn under the hue one. @default false */\n readonly alpha?: boolean\n /**\n * Replaces everything on the surface, for a picker that arranges its own\n * parts. The colour controls in it take the picker's value.\n */\n readonly children?: ReactNode\n /** Whether the surface starts open, when the picker keeps its own open state. */\n readonly defaultOpen?: boolean\n /**\n * The colour the picker holds at first, when it keeps its own: a CSS colour\n * string, or a `Color` from `parseColor`.\n * @default '#000000'\n */\n readonly defaultValue?: Color | string\n /**\n * Whether the whole picker is inert: the trigger, and the plane, sliders\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed as\n * `children` is the call site's own to disable.\n * @default false\n */\n readonly isDisabled?: boolean\n /** Whether the surface is open, for a call site holding it with `onOpenChange`. */\n readonly isOpen?: boolean\n /**\n * What the trigger says beside its swatch. Required: it is the button's\n * name, the surface's and the field's.\n */\n readonly label: string\n /** Called with the colour each time a control on the surface changes it. */\n readonly onChange?: (value: Color) => void\n /** Called when the surface opens or closes. */\n readonly onOpenChange?: (isOpen: boolean) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n /** The colour, for a call site holding it itself with `onChange`. */\n readonly value?: Color | string\n}\n\n/**\n * A colour picked from a plane, a hue slider and a hex field, behind a\n * trigger showing the colour. Pass `value` with `onChange` to control it, or\n * `defaultValue`, as a CSS colour string or a `Color` from `parseColor`,\n * which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency slider. From the medium window size up the\n * surface is docked under the trigger; below it, it opens centred over a\n * scrim, as a date picker's does. `defaultOpen`, `isOpen` and `onOpenChange`\n * reach the surface.\n *\n * Every part on the surface is this package's own, `ColorArea`,\n * `ColorSlider` and `ColorField`, and they share the picker's value rather\n * than taking it as props. Passing `children` replaces all of them, and a\n * `ColorArea`, `ColorField`, `ColorSlider`, `ColorSwatch`,\n * `ColorSwatchPicker` or `ColorWheel` among them takes the picker's value\n * where it is given none of its own.\n *\n * `style`, `ref` and `testID` land on the trigger, which is what a layout\n * places.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n defaultOpen,\n defaultValue,\n isDisabled = false,\n isOpen,\n label,\n onChange,\n onOpenChange,\n ref,\n style,\n testID,\n value,\n}: ColorPickerProps) {\n const theme = useTheme()\n const { colors, radii, spacing, stateLayerOpacity } = theme\n const styles = stylesOf(theme)\n const locale = useLocaleOf(undefined)\n const messages = useMessages()\n const labelRole = useTypeRole('labelLarge')\n const state = useColorPickerState({ defaultValue, onChange, value })\n const overlay = useOverlayTriggerState({ defaultOpen, isOpen, onOpenChange })\n // oxlint-disable-next-line typescript/unbound-method -- React Stately's setters are callbacks, and read no `this`\n const { close, open: show } = overlay\n const anchor = useRef<HostInstance | null>(null)\n const [trigger, setTrigger] = useState<HostInstance | null>(null)\n const feedback = usePressFeedback({\n color: colors.onSurface,\n corners: { borderRadius: radii.pill },\n disabled: isDisabled,\n })\n const name = colorNameOf(state.color, locale, messages.transparent)\n\n return (\n <>\n <Pressable\n {...feedback.handlers}\n aria-expanded={overlay.isOpen}\n aria-label={`${label}, ${name}`}\n disabled={isDisabled}\n hitSlop={hitSlop(SWATCH + 2 * spacing.sm)}\n onPress={show}\n ref={refsOf<HostInstance>(ref, anchor, setTrigger)}\n role=\"button\"\n style={composeStyles<ViewStyle>(\n styles.trigger,\n isDisabled ? styles.disabled : undefined,\n feedback.ring,\n style,\n )}\n testID={testID}\n >\n {feedback.layer}\n <ColorSwatch color={state.color} style={styles.swatch} />\n <Text\n style={composeStyles<TextStyle>(labelRole, {\n color: isDisabled\n ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n : colors.onSurface,\n })}\n >\n {label}\n </Text>\n </Pressable>\n <PickerPopup\n anchor={anchor}\n close={close}\n isOpen={overlay.isOpen}\n label={label}\n trigger={trigger}\n >\n {/*\n Inside the surface rather than around the picker, since the surface\n is drawn in the overlay host, which context set around the picker\n does not reach.\n */}\n <PickedColorContext value={pickedOf(state)}>\n {children ?? (\n <NativeView style={styles.body}>\n <ColorArea\n aria-label={label}\n colorSpace=\"hsl\"\n isDisabled={isDisabled}\n xChannel=\"saturation\"\n yChannel=\"lightness\"\n />\n <ColorSlider\n channel=\"hue\"\n colorSpace=\"hsl\"\n isDisabled={isDisabled}\n label={CHANNELS.getChannelName('hue', locale)}\n />\n {alpha ? (\n <ColorSlider\n channel=\"alpha\"\n isDisabled={isDisabled}\n label={CHANNELS.getChannelName('alpha', locale)}\n />\n ) : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </NativeView>\n )}\n </PickedColorContext>\n </PickerPopup>\n </>\n )\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's jsx-no-new-object-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction pickedOf(state: ColorPickerState): PickedColor {\n return {\n onChange: (color) => {\n state.setColor(color)\n },\n value: state.color,\n }\n}\n\nexport { ColorPicker }\nexport type { ColorPickerProps }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmFA,MAAMqC,SAAS;AAGf,MAAMC,gBAAgB;AAKtB,MAAMC,WAAWvB,WAAW,gBAAgB;AAE5C,MAAMwB,WAAWT,cAAc,EAAEU,QAAQC,OAAOC,SAASC,wBACvD9B,WAAW+B,OAAO;CAGhBC,MAAM;EACJC,WAAW;EACXC,KAAKL,QAAQM;EACbC,UAAU;EACVC,SAASR,QAAQS;EACjBC,OAAOf;CACT;CACAgB,UAAU,EACRC,iBAAiB3B,YACfa,OAAOe,WACPZ,kBAAkBa,iBACpB,EACF;CACAC,QAAQ;EACNC,QAAQtB;EACRgB,OAAOhB;CAC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MAAAc;EAAAd,EAAA,MAAAT;EAAAS,EAAA,MAAAa,QAAAvB;EAAAU,EAAA,MAAAkD;EAAAlD,EAAA,MAAA1B;EAAA0B,EAAA,MAAAmD;CAAA,OAAAA,MAAAnD,EAAA;CAAA,IAAAoD;CAAA,IAAApD,EAAA,QAAA4C,OAAA5C,EAAA,QAAAmD,KAAA;EArEhBC,MAAA,qBAAA,YAAA,EAAA,UAAA,CACER,KA6BAO,GAuCc,EAAA,CAAA;EACbnD,EAAA,MAAA4C;EAAA5C,EAAA,MAAAmD;EAAAnD,EAAA,MAAAoD;CAAA,OAAAA,MAAApD,EAAA;CAAA,OAtEHoD;AAsEG;AAOP,SAASL,SAASpC,OAAsC;CACtD,OAAO;EACLnB,WAAW6B,UAAU;GACnBV,MAAM0C,SAAShC,KAAK;EACtB;EACA5B,OAAOkB,MAAMU;CACf;AACF"}
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","HostInstance","StyleProp","TextStyle","View","ViewStyle","Color","ColorPickerState","useRef","useState","NativeView","Pressable","StyleSheet","Text","parseColor","useColorPickerState","useOverlayTriggerState","PickedColor","useLocaleOf","useMessages","PickerPopup","hitSlop","usePressFeedback","refsOf","colorNameOf","PickedColorContext","withOpacity","useTheme","composeStyles","themedStyles","useTypeRole","ColorArea","ColorField","ColorSlider","ColorSwatch","SWATCH","SURFACE_WIDTH","CHANNELS","stylesOf","colors","radii","spacing","stateLayerOpacity","create","body","boxSizing","gap","md","maxWidth","padding","lg","width","disabled","backgroundColor","onSurface","disabledContainer","swatch","height","swatchDisabled","opacity","disabledContent","trigger","alignItems","alignSelf","surfaceContainerLow","borderRadius","pill","flexDirection","sm","paddingHorizontal","paddingVertical","ColorPickerProps","alpha","children","defaultOpen","defaultValue","isDisabled","isOpen","label","onChange","value","onOpenChange","ref","style","testID","ColorPicker","t0","$","_c","t1","t2","undefined","theme","styles","locale","messages","labelRole","t3","state","t4","overlay","close","open","show","anchor","setTrigger","t5","t6","color","corners","feedback","t7","transparent","name","T0","t8","handlers","t9","t10","t11","t12","t13","t14","t15","ring","t16","layer","T1","t17","t18","t19","t20","t21","t22","t23","t24","pickedOf","t25","getChannelName","t26","t27","t28","setColor","_c","NativeView"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n HostInstance,\n StyleProp,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native'\nimport type { Color } from 'react-stately'\nimport type { ColorPickerState } from 'react-stately/useColorPickerState'\n\nimport { useRef, useState } from 'react'\nimport { View as NativeView, Pressable, StyleSheet, Text } from 'react-native'\nimport { parseColor } from 'react-stately'\nimport { useColorPickerState } from 'react-stately/useColorPickerState'\nimport { useOverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport type { PickedColor } from '../../swatch'\n\nimport { useLocaleOf, useMessages } from '../../i18n/provider'\nimport { PickerPopup } from '../../picker'\nimport { hitSlop, usePressFeedback } from '../../press'\nimport { refsOf } from '../../ref'\nimport { colorNameOf, PickedColorContext } from '../../swatch'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\nimport { ColorArea } from '../color-area'\nimport { ColorField } from '../color-field'\nimport { ColorSlider } from '../color-slider'\nimport { ColorSwatch } from '../color-swatch'\n\n// Every colour control in one, as kanso-ui's ColorPicker composes them: a\n// swatch and a label as the trigger, and a plane, a hue slider, an alpha\n// slider and a hex field on the surface it opens. The value is React\n// Stately's `useColorPickerState`, which the controls on the surface take\n// through src/swatch's PickedColorContext, as React Aria's picker hands its\n// value to each control's context on web. So an arrangement passed as\n// `children` shares the value the same way, whatever it holds.\n//\n// Material Design carries no page for a colour picker. What it does carry is\n// the text fields page, which the field inside draws through, and the surface\n// a date picker opens on, which this one shares through src/picker. Three\n// choices are web's own, and kept.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch on\n// its own is a coloured square with no affordance, and a screen reader would\n// be told a colour rather than an action. It is a pill on surface container\n// low, the swatch at 24dp, the height of the label's line rather than a\n// swatch's own 40dp, and the label in label large, with the state layer and\n// ripple every control here draws in on surface. A screen reader hears the\n// label and then the colour, \"Label, dark purple\", where web's reads the\n// swatch's name first: the visible label leads, so a voice command that says\n// it finds the button.\n//\n// **Hue is a slider rather than a wheel.** A wheel and the plane want the\n// same room, and would make the surface square and large; the strip sits\n// under the plane at the width it already has. ColorWheel is for a picker\n// that wants to be round, which a call site builds as `children`.\n//\n// **It is docked from the medium window size up and modal below it**, the\n// date picker's pairing, through the same src/picker surface: a 280dp\n// surface anchored to a trigger is out of reach on a phone, and a centred one\n// on a tablet covers a form for no reason. Its dismissal, its motion and\n// where a screen reader goes are the date picker's.\n//\n// One thing the picker does that its parts do not. **The plane and the hue\n// slider are read in HSL.** A channel has to belong to the value's own space\n// or React Stately throws, and a hex is read as RGB, which has no saturation,\n// so `<ColorPicker defaultValue=\"#6750A4\" />` would throw outright. Reading\n// the two in HSL is what lets the picker take any notation. A change made on\n// either reports the colour in HSL, as React Stately's area and slider do on\n// web, and the field shows it as hex whatever space it is in.\n//\n// **Disabled reaches every control on the surface**, not only the trigger.\n// React Stately's picker state carries no disabled state, and the surface\n// opens independently of the trigger, so a disabled picker can still be on\n// screen: already open when a form disables it, or opened from outside. An\n// arrangement passed as `children` is the call site's own to disable.\n\n// The swatch in the trigger, at the height of the label's line rather than\n// the 40dp a swatch takes on its own.\nconst SWATCH = 24\n\n// The surface's width, as web's: room for the plane and a hex field.\nconst SURFACE_WIDTH = 280\n\n// Any HSL colour names the channels the two sliders draw. Their labels are\n// read off it in the locale, as React Stately words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)')\n\nconst stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>\n StyleSheet.create({\n // What the surface holds, stacked: the plane, the sliders, then the\n // field. One column, so a picker reads top to bottom.\n body: {\n boxSizing: 'border-box',\n gap: spacing.md,\n maxWidth: '100%',\n padding: spacing.lg,\n width: SURFACE_WIDTH,\n },\n disabled: {\n backgroundColor: withOpacity(\n colors.onSurface,\n stateLayerOpacity.disabledContainer,\n ),\n },\n swatch: {\n height: SWATCH,\n width: SWATCH,\n },\n // Laid over the swatch while the trigger is disabled, at the opacity a\n // disabled label's colour mixes at, so the swatch fades with the label\n // and the trigger does not read as half enabled.\n swatchDisabled: {\n opacity: stateLayerOpacity.disabledContent,\n },\n trigger: {\n alignItems: 'center',\n alignSelf: 'flex-start',\n backgroundColor: colors.surfaceContainerLow,\n borderRadius: radii.pill,\n boxSizing: 'border-box',\n flexDirection: 'row',\n gap: spacing.sm,\n paddingHorizontal: spacing.md,\n paddingVertical: spacing.sm,\n },\n }),\n)\n\ntype ColorPickerProps = {\n /** Whether the alpha slider is drawn under the hue one. @default false */\n readonly alpha?: boolean\n /**\n * Replaces everything on the surface, for a picker that arranges its own\n * parts. The colour controls in it take the picker's value.\n */\n readonly children?: ReactNode\n /** Whether the surface starts open, when the picker keeps its own open state. */\n readonly defaultOpen?: boolean\n /**\n * The colour the picker holds at first, when it keeps its own: a CSS colour\n * string, or a `Color` from `parseColor`.\n * @default '#000000'\n */\n readonly defaultValue?: Color | string\n /**\n * Whether the whole picker is inert: the trigger, and the plane, sliders\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed as\n * `children` is the call site's own to disable.\n * @default false\n */\n readonly isDisabled?: boolean\n /** Whether the surface is open, for a call site holding it with `onOpenChange`. */\n readonly isOpen?: boolean\n /**\n * What the trigger says beside its swatch. Required: it is the button's\n * name, the surface's and the field's.\n */\n readonly label: string\n /** Called with the colour each time a control on the surface changes it. */\n readonly onChange?: (value: Color) => void\n /** Called when the surface opens or closes. */\n readonly onOpenChange?: (isOpen: boolean) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n /** The colour, for a call site holding it itself with `onChange`. */\n readonly value?: Color | string\n}\n\n/**\n * A colour picked from a plane, a hue slider and a hex field, behind a\n * trigger showing the colour. Pass `value` with `onChange` to control it, or\n * `defaultValue`, as a CSS colour string or a `Color` from `parseColor`,\n * which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency slider. From the medium window size up the\n * surface is docked under the trigger; below it, it opens centred over a\n * scrim, as a date picker's does. `defaultOpen`, `isOpen` and `onOpenChange`\n * reach the surface.\n *\n * Every part on the surface is this package's own, `ColorArea`,\n * `ColorSlider` and `ColorField`, and they share the picker's value rather\n * than taking it as props. Passing `children` replaces all of them, and a\n * `ColorArea`, `ColorField`, `ColorSlider`, `ColorSwatch`,\n * `ColorSwatchPicker` or `ColorWheel` among them takes the picker's value\n * where it is given none of its own.\n *\n * `style`, `ref` and `testID` land on the trigger, which is what a layout\n * places.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n defaultOpen,\n defaultValue,\n isDisabled = false,\n isOpen,\n label,\n onChange,\n onOpenChange,\n ref,\n style,\n testID,\n value,\n}: ColorPickerProps) {\n const theme = useTheme()\n const { colors, radii, spacing, stateLayerOpacity } = theme\n const styles = stylesOf(theme)\n const locale = useLocaleOf(undefined)\n const messages = useMessages()\n const labelRole = useTypeRole('labelLarge')\n const state = useColorPickerState({ defaultValue, onChange, value })\n const overlay = useOverlayTriggerState({ defaultOpen, isOpen, onOpenChange })\n // oxlint-disable-next-line typescript/unbound-method -- React Stately's setters are callbacks, and read no `this`\n const { close, open: show } = overlay\n const anchor = useRef<HostInstance | null>(null)\n const [trigger, setTrigger] = useState<HostInstance | null>(null)\n const feedback = usePressFeedback({\n color: colors.onSurface,\n corners: { borderRadius: radii.pill },\n disabled: isDisabled,\n })\n const name = colorNameOf(state.color, locale, messages.transparent)\n\n return (\n <>\n <Pressable\n {...feedback.handlers}\n aria-expanded={overlay.isOpen}\n aria-label={`${label}, ${name}`}\n disabled={isDisabled}\n hitSlop={hitSlop(SWATCH + 2 * spacing.sm)}\n onPress={show}\n ref={refsOf<HostInstance>(ref, anchor, setTrigger)}\n role=\"button\"\n style={composeStyles<ViewStyle>(\n styles.trigger,\n isDisabled ? styles.disabled : undefined,\n feedback.ring,\n style,\n )}\n testID={testID}\n >\n {feedback.layer}\n <ColorSwatch\n color={state.color}\n style={composeStyles<ViewStyle>(\n styles.swatch,\n isDisabled ? styles.swatchDisabled : undefined,\n )}\n />\n <Text\n style={composeStyles<TextStyle>(labelRole, {\n color: isDisabled\n ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n : colors.onSurface,\n })}\n >\n {label}\n </Text>\n </Pressable>\n <PickerPopup\n anchor={anchor}\n close={close}\n isOpen={overlay.isOpen}\n label={label}\n trigger={trigger}\n >\n {/*\n Inside the surface rather than around the picker, since the surface\n is drawn in the overlay host, which context set around the picker\n does not reach.\n */}\n <PickedColorContext value={pickedOf(state)}>\n {children ?? (\n <NativeView style={styles.body}>\n <ColorArea\n aria-label={label}\n colorSpace=\"hsl\"\n isDisabled={isDisabled}\n xChannel=\"saturation\"\n yChannel=\"lightness\"\n />\n <ColorSlider\n channel=\"hue\"\n colorSpace=\"hsl\"\n isDisabled={isDisabled}\n label={CHANNELS.getChannelName('hue', locale)}\n />\n {alpha ? (\n <ColorSlider\n channel=\"alpha\"\n isDisabled={isDisabled}\n label={CHANNELS.getChannelName('alpha', locale)}\n />\n ) : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </NativeView>\n )}\n </PickedColorContext>\n </PickerPopup>\n </>\n )\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's jsx-no-new-object-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction pickedOf(state: ColorPickerState): PickedColor {\n return {\n onChange: (color) => {\n state.setColor(color)\n },\n value: state.color,\n }\n}\n\nexport { ColorPicker }\nexport type { ColorPickerProps }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmFA,MAAMqC,SAAS;AA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MAAAkD;CAAA,OAAAA,MAAAlD,EAAA;CAAA,IAAAoD;CAAA,IAAApD,EAAA,QAAAgD,OAAAhD,EAAA,QAAAkD,KAAA;EAzBHE,MAAA,oBAAC,oBAAD;GAA2B,OAAAJ;GACxBE,UAAAA;EADgB,CAAA;EA0BElD,EAAA,MAAAgD;EAAAhD,EAAA,MAAAkD;EAAAlD,EAAA,MAAAoD;CAAA,OAAAA,MAAApD,EAAA;CAAA,IAAAqD;CAAA,IAAArD,EAAA,QAAAc,SAAAd,EAAA,QAAAT,SAAAS,EAAA,QAAAa,QAAAvB,UAAAU,EAAA,QAAAoD,OAAApD,EAAA,QAAA1B,SAAA;EAtCvB+E,MAAA,oBAAC,aAAD;GACUpC;GACDH;GACC,QAAAiC;GACDxD;GACEjB;GAOT8E,UAAAA;EAZU,CAAA;EAuCEpD,EAAA,MAAAc;EAAAd,EAAA,MAAAT;EAAAS,EAAA,MAAAa,QAAAvB;EAAAU,EAAA,MAAAoD;EAAApD,EAAA,MAAA1B;EAAA0B,EAAA,MAAAqD;CAAA,OAAAA,MAAArD,EAAA;CAAA,IAAAsD;CAAA,IAAAtD,EAAA,QAAA8C,OAAA9C,EAAA,QAAAqD,KAAA;EA3EhBC,MAAA,qBAAA,YAAA,EAAA,UAAA,CACER,KAmCAO,GAuCc,EAAA,CAAA;EACbrD,EAAA,MAAA8C;EAAA9C,EAAA,MAAAqD;EAAArD,EAAA,MAAAsD;CAAA,OAAAA,MAAAtD,EAAA;CAAA,OA5EHsD;AA4EG;AAOP,SAASL,SAAStC,OAAsC;CACtD,OAAO;EACLnB,WAAW6B,UAAU;GACnBV,MAAM4C,SAASlC,KAAK;EACtB;EACA5B,OAAOkB,MAAMU;CACf;AACF"}
@@ -31,8 +31,8 @@ type RangeCalendarProps$1<T extends DateValue = DateValue> = Pick<RangeCalendarP
31
31
  readonly testID?: string;
32
32
  /**
33
33
  * How many months the calendar shows at once, and moves by: side by side
34
- * from the expanded window size up, one under another below it. Only
35
- * `months` is read.
34
+ * from the expanded window size up, one under another below it, each
35
+ * named over its weeks. Only `months` is read.
36
36
  * @default { months: 1 }
37
37
  */
38
38
  readonly visibleDuration?: DateDuration;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DateDuration","ComponentRef","Ref","StyleProp","ViewStyle","DateValue","RangeCalendarProps","StatelyRangeCalendarProps","createCalendar","View","useRangeCalendarState","CalendarFrame","useRootStyle","visibleRangeOf","useLocaleOf","composeStyles","Pick","T","locale","ref","showMonthYearMenus","style","testID","visibleDuration","RangeCalendar","t0","$","_c","ariaLabel","props","t1","undefined","writtenIn","months","Math","max","rootStyle","t2","t3","state","t4","shown","t5","t6","t7","firstDayOfWeek","t8","_c"],"sources":["../../../src/components/range-calendar/index.tsx"],"sourcesContent":["import type { DateDuration } from '@internationalized/date'\nimport type { ComponentRef, Ref } from 'react'\nimport type { StyleProp, ViewStyle } from 'react-native'\nimport type {\n DateValue,\n RangeCalendarProps as StatelyRangeCalendarProps,\n} from 'react-stately/useRangeCalendarState'\n\nimport { createCalendar } from '@internationalized/date'\nimport { View } from 'react-native'\nimport { useRangeCalendarState } from 'react-stately/useRangeCalendarState'\n\nimport { CalendarFrame, useRootStyle, visibleRangeOf } from '../../calendar'\nimport { useLocaleOf } from '../../i18n/provider'\nimport { composeStyles } from '../../theme/styles'\n\n// kanso-ui's RangeCalendar: the date pickers page's calendar again, picking\n// two dates rather than one. Every part it draws is Calendar's, from\n// src/calendar, the container, the header, the month and year menus, the\n// grid and the date cell, so the two cannot come apart.\n//\n// What a range adds is the band between its two ends. The docked token set\n// stops at the selected date, so the band's colours are the modal date\n// picker's range-selection tokens: the secondary container, one step down\n// from the primary the two ends take, with its label in on secondary\n// container and its state layers in on primary container. Two things follow\n// from drawing a band across a grid whose dates are spaced apart, as on web.\n//\n// **The band is square and the ends are round.** A run of days reads as one\n// shape rather than a row of circles, and the first and last day round only\n// their outer side, which is what makes the band begin and end at a circle.\n// The sides are logical, so a right-to-left layout turns the band over.\n//\n// **The band fills the whole of each day's column.** A day in the range\n// drops the 4dp either side that every other date keeps and takes the full\n// width of its column, so one day's band meets the next one's.\n//\n// The state is React Stately's `useRangeCalendarState`, which web's React\n// Aria range calendar is built on. A first press starts the range and a\n// second ends it, on either side of the first. While a range is started a\n// pointer over a date draws the range as far as it, as web's does; a touch\n// has no such preview, so on a phone the band shows once the second date is\n// pressed. A date `isDateUnavailable` rules out is struck through, and once\n// a range is started the dates past it are disabled, unless\n// `allowsNonContiguousRanges` lets the range run over it.\n//\n// Each date's name is React Aria's: the two ends open with the whole range,\n// a day inside it is said to be selected, and each date's hint says whether\n// a press starts a range or ends the one started.\n\ntype RangeCalendarProps<T extends DateValue = DateValue> = Pick<\n StatelyRangeCalendarProps<T>,\n | 'allowsNonContiguousRanges'\n | 'defaultFocusedValue'\n | 'defaultValue'\n | 'firstDayOfWeek'\n | 'focusedValue'\n | 'isDateUnavailable'\n | 'isDisabled'\n | 'isReadOnly'\n | 'maxValue'\n | 'minValue'\n | 'onChange'\n | 'onFocusChange'\n | 'value'\n> & {\n /**\n * The calendar's name. The month shown, or the months, is added to it, as\n * React Aria adds it on web.\n */\n readonly 'aria-label'?: string\n /**\n * The BCP 47 locale the calendar is written in: its month and weekday\n * names, its digits, its first day of the week and its calendar system.\n * Defaults to the `I18nProvider`'s, or the device's outside one.\n */\n readonly locale?: string\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as `Calendar`'s does. The\n * year list runs a century either side of the year shown, or to\n * `minValue` and `maxValue` where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown, since\n * the menus name only the first.\n * @default false\n */\n readonly showMonthYearMenus?: boolean\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n /**\n * How many months the calendar shows at once, and moves by: side by side\n * from the expanded window size up, one under another below it. Only\n * `months` is read.\n * @default { months: 1 }\n */\n readonly visibleDuration?: DateDuration\n}\n\n/**\n * A calendar for picking a range of dates. The value is a `{ start, end }`\n * pair of `@internationalized/date` values, as on web: pass `value` with\n * `onChange` to control it, or `defaultValue` to let it keep its own.\n *\n * ```tsx\n * import { CalendarDate } from '@internationalized/date'\n *\n * <RangeCalendar\n * aria-label=\"Label\"\n * defaultValue={{\n * start: new CalendarDate(2026, 9, 8),\n * end: new CalendarDate(2026, 9, 15),\n * }}\n * />\n * ```\n *\n * The two ends take the circle a selected date takes in `Calendar`, and the\n * days between them a band in the secondary container. `minValue`,\n * `maxValue`, `isDateUnavailable` and `visibleDuration` are the props\n * `Calendar` takes, and `allowsNonContiguousRanges` lets a range run past\n * the dates ruled out inside it rather than stopping at the first.\n *\n * `style`, `ref` and `testID` land on the container.\n */\nfunction RangeCalendar<T extends DateValue = DateValue>({\n 'aria-label': ariaLabel,\n locale,\n ref,\n showMonthYearMenus = false,\n style,\n testID,\n visibleDuration,\n ...props\n}: RangeCalendarProps<T>) {\n const writtenIn = useLocaleOf(locale)\n const months = Math.max(1, visibleDuration?.months ?? 1)\n const rootStyle = useRootStyle(months)\n const state = useRangeCalendarState<T>({\n ...props,\n createCalendar,\n locale: writtenIn,\n visibleDuration: { months },\n })\n const shown = visibleRangeOf(state, writtenIn, true)\n\n return (\n <View\n aria-label={ariaLabel === undefined ? shown : `${ariaLabel}, ${shown}`}\n ref={ref}\n role=\"group\"\n style={composeStyles<ViewStyle>(rootStyle, style)}\n testID={testID}\n >\n <CalendarFrame\n firstDayOfWeek={props.firstDayOfWeek}\n locale={writtenIn}\n months={months}\n showMonthYearMenus={showMonthYearMenus}\n state={state}\n />\n </View>\n )\n}\n\nexport type { RangeCalendarProps }\n\nexport { RangeCalendar }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HA,SAAAwB,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAV;CAAA,IAAAW;CAAA,IAAAV;CAAA,IAAAE;CAA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AdPoB;AAcO"}
1
+ {"version":3,"file":"index.js","names":["DateDuration","ComponentRef","Ref","StyleProp","ViewStyle","DateValue","RangeCalendarProps","StatelyRangeCalendarProps","createCalendar","View","useRangeCalendarState","CalendarFrame","useRootStyle","visibleRangeOf","useLocaleOf","composeStyles","Pick","T","locale","ref","showMonthYearMenus","style","testID","visibleDuration","RangeCalendar","t0","$","_c","ariaLabel","props","t1","undefined","writtenIn","months","Math","max","rootStyle","t2","t3","state","t4","shown","t5","t6","t7","firstDayOfWeek","t8","_c"],"sources":["../../../src/components/range-calendar/index.tsx"],"sourcesContent":["import type { DateDuration } from '@internationalized/date'\nimport type { ComponentRef, Ref } from 'react'\nimport type { StyleProp, ViewStyle } from 'react-native'\nimport type {\n DateValue,\n RangeCalendarProps as StatelyRangeCalendarProps,\n} from 'react-stately/useRangeCalendarState'\n\nimport { createCalendar } from '@internationalized/date'\nimport { View } from 'react-native'\nimport { useRangeCalendarState } from 'react-stately/useRangeCalendarState'\n\nimport { CalendarFrame, useRootStyle, visibleRangeOf } from '../../calendar'\nimport { useLocaleOf } from '../../i18n/provider'\nimport { composeStyles } from '../../theme/styles'\n\n// kanso-ui's RangeCalendar: the date pickers page's calendar again, picking\n// two dates rather than one. Every part it draws is Calendar's, from\n// src/calendar, the container, the header, the month and year menus, the\n// grid and the date cell, so the two cannot come apart.\n//\n// What a range adds is the band between its two ends. The docked token set\n// stops at the selected date, so the band's colours are the modal date\n// picker's range-selection tokens: the secondary container, one step down\n// from the primary the two ends take, with its label in on secondary\n// container and its state layers in on primary container. Two things follow\n// from drawing a band across a grid whose dates are spaced apart, as on web.\n//\n// **The band is square and the ends are round.** A run of days reads as one\n// shape rather than a row of circles, and the first and last day round only\n// their outer side, which is what makes the band begin and end at a circle.\n// The sides are logical, so a right-to-left layout turns the band over.\n//\n// **The band fills the whole of each day's column.** A day in the range\n// drops the 4dp either side that every other date keeps and takes the full\n// width of its column, so one day's band meets the next one's.\n//\n// The state is React Stately's `useRangeCalendarState`, which web's React\n// Aria range calendar is built on. A first press starts the range and a\n// second ends it, on either side of the first. While a range is started a\n// pointer over a date draws the range as far as it, as web's does; a touch\n// has no such preview, so on a phone the band shows once the second date is\n// pressed. A date `isDateUnavailable` rules out is struck through, and once\n// a range is started the dates past it are disabled, unless\n// `allowsNonContiguousRanges` lets the range run over it.\n//\n// Each date's name is React Aria's: the two ends open with the whole range,\n// a day inside it is said to be selected, and each date's hint says whether\n// a press starts a range or ends the one started.\n\ntype RangeCalendarProps<T extends DateValue = DateValue> = Pick<\n StatelyRangeCalendarProps<T>,\n | 'allowsNonContiguousRanges'\n | 'defaultFocusedValue'\n | 'defaultValue'\n | 'firstDayOfWeek'\n | 'focusedValue'\n | 'isDateUnavailable'\n | 'isDisabled'\n | 'isReadOnly'\n | 'maxValue'\n | 'minValue'\n | 'onChange'\n | 'onFocusChange'\n | 'value'\n> & {\n /**\n * The calendar's name. The month shown, or the months, is added to it, as\n * React Aria adds it on web.\n */\n readonly 'aria-label'?: string\n /**\n * The BCP 47 locale the calendar is written in: its month and weekday\n * names, its digits, its first day of the week and its calendar system.\n * Defaults to the `I18nProvider`'s, or the device's outside one.\n */\n readonly locale?: string\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as `Calendar`'s does. The\n * year list runs a century either side of the year shown, or to\n * `minValue` and `maxValue` where they are closer.\n *\n * For one visible month. With `visibleDuration` of more than one, the\n * header is the plain one, whose heading names every month shown, since\n * the menus name only the first.\n * @default false\n */\n readonly showMonthYearMenus?: boolean\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n /**\n * How many months the calendar shows at once, and moves by: side by side\n * from the expanded window size up, one under another below it, each\n * named over its weeks. Only `months` is read.\n * @default { months: 1 }\n */\n readonly visibleDuration?: DateDuration\n}\n\n/**\n * A calendar for picking a range of dates. The value is a `{ start, end }`\n * pair of `@internationalized/date` values, as on web: pass `value` with\n * `onChange` to control it, or `defaultValue` to let it keep its own.\n *\n * ```tsx\n * import { CalendarDate } from '@internationalized/date'\n *\n * <RangeCalendar\n * aria-label=\"Label\"\n * defaultValue={{\n * start: new CalendarDate(2026, 9, 8),\n * end: new CalendarDate(2026, 9, 15),\n * }}\n * />\n * ```\n *\n * The two ends take the circle a selected date takes in `Calendar`, and the\n * days between them a band in the secondary container. `minValue`,\n * `maxValue`, `isDateUnavailable` and `visibleDuration` are the props\n * `Calendar` takes, and `allowsNonContiguousRanges` lets a range run past\n * the dates ruled out inside it rather than stopping at the first.\n *\n * `style`, `ref` and `testID` land on the container.\n */\nfunction RangeCalendar<T extends DateValue = DateValue>({\n 'aria-label': ariaLabel,\n locale,\n ref,\n showMonthYearMenus = false,\n style,\n testID,\n visibleDuration,\n ...props\n}: RangeCalendarProps<T>) {\n const writtenIn = useLocaleOf(locale)\n const months = Math.max(1, visibleDuration?.months ?? 1)\n const rootStyle = useRootStyle(months)\n const state = useRangeCalendarState<T>({\n ...props,\n createCalendar,\n locale: writtenIn,\n visibleDuration: { months },\n })\n const shown = visibleRangeOf(state, writtenIn, true)\n\n return (\n <View\n aria-label={ariaLabel === undefined ? shown : `${ariaLabel}, ${shown}`}\n ref={ref}\n role=\"group\"\n style={composeStyles<ViewStyle>(rootStyle, style)}\n testID={testID}\n >\n <CalendarFrame\n firstDayOfWeek={props.firstDayOfWeek}\n locale={writtenIn}\n months={months}\n showMonthYearMenus={showMonthYearMenus}\n state={state}\n />\n </View>\n )\n}\n\nexport type { RangeCalendarProps }\n\nexport { RangeCalendar }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HA,SAAAwB,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAV;CAAA,IAAAW;CAAA,IAAAV;CAAA,IAAAE;CAAA,IAAAS;CAAA,IAAAR;CAAA,IAAAC;CAAA,IAAAG,EAAA,OAAAD,IAAA;EAAwD,CAAA,CAAA,cAAAG,WAA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