@kanso-labs/react-native-kanso-ui 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/autocomplete/index.js +15 -1
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/button/group.d.ts +5 -0
- package/dist/button/group.js +115 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/index.d.ts +4 -1
- package/dist/button/index.js +44 -22
- package/dist/button/index.js.map +1 -1
- package/dist/button/slots.js +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/calendar/index.js +351 -182
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +33 -2
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/chequer/index.js +95 -0
- package/dist/chequer/index.js.map +1 -0
- package/dist/collection/index.d.ts +157 -0
- package/dist/collection/index.js +1358 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/color-thumb/index.js +56 -0
- package/dist/color-thumb/index.js.map +1 -0
- package/dist/components/button/index.d.ts +4 -2
- package/dist/components/button/index.js +227 -188
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +87 -0
- package/dist/components/button-group/index.js +275 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +11 -3
- package/dist/components/calendar/index.js +60 -45
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +72 -0
- package/dist/components/carousel/index.js +496 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/checkbox-group/index.d.ts +3 -4
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +4 -1
- package/dist/components/chip/index.js +229 -161
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +85 -0
- package/dist/components/color-area/index.js +630 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-field/index.d.ts +144 -0
- package/dist/components/color-field/index.js +516 -0
- package/dist/components/color-field/index.js.map +1 -0
- package/dist/components/color-picker/index.d.ts +74 -0
- package/dist/components/color-picker/index.js +317 -0
- package/dist/components/color-picker/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +82 -0
- package/dist/components/color-slider/index.js +456 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +46 -0
- package/dist/components/color-swatch/index.js +127 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +81 -0
- package/dist/components/color-swatch-picker/index.js +287 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/color-wheel/index.d.ts +71 -0
- package/dist/components/color-wheel/index.js +407 -0
- package/dist/components/color-wheel/index.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +193 -0
- package/dist/components/combo-box/index.js +616 -0
- package/dist/components/combo-box/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +120 -0
- package/dist/components/date-field/index.js +111 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +130 -0
- package/dist/components/date-picker/index.js +310 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +139 -0
- package/dist/components/date-range-picker/index.js +421 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/dialog/index.d.ts +5 -5
- package/dist/components/dialog/index.js +5 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +94 -0
- package/dist/components/disclosure/index.js +365 -0
- package/dist/components/disclosure/index.js.map +1 -0
- package/dist/components/disclosure-group/index.d.ts +61 -0
- package/dist/components/disclosure-group/index.js +100 -0
- package/dist/components/disclosure-group/index.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +113 -0
- package/dist/components/drop-zone/index.js +304 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js +91 -76
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +4 -2
- package/dist/components/icon-button/index.js +204 -171
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.d.ts +15 -158
- package/dist/components/list/index.js +21 -1047
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +73 -0
- package/dist/components/list-box/index.js +82 -0
- package/dist/components/list-box/index.js.map +1 -0
- package/dist/components/loading-indicator/index.d.ts +32 -0
- package/dist/components/loading-indicator/index.js +174 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +117 -0
- package/dist/components/navigation-tree/index.js +135 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/number-field/index.js +132 -143
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +69 -0
- package/dist/components/range-calendar/index.js +144 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/search-view/index.d.ts +79 -0
- package/dist/components/search-view/index.js +571 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/select/index.d.ts +152 -0
- package/dist/components/select/index.js +419 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/sheet/index.d.ts +16 -7
- package/dist/components/sheet/index.js +157 -152
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +111 -0
- package/dist/components/slider/index.js +673 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/split-button/index.d.ts +77 -0
- package/dist/components/split-button/index.js +354 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/table/index.d.ts +391 -0
- package/dist/components/table/index.js +1708 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +196 -0
- package/dist/components/tabs/index.js +1137 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +43 -0
- package/dist/components/time-field/index.js +107 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-picker/index.d.ts +65 -0
- package/dist/components/time-picker/index.js +1168 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/token-field/index.d.ts +105 -0
- package/dist/components/token-field/index.js +574 -0
- package/dist/components/token-field/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +102 -0
- package/dist/components/tooltip/index.js +223 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +112 -0
- package/dist/components/tree/index.js +157 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/disclosure/chevron.js +75 -0
- package/dist/disclosure/chevron.js.map +1 -0
- package/dist/disclosure/index.js +7 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/drop/index.d.ts +54 -0
- package/dist/drop/index.js +161 -0
- package/dist/drop/index.js.map +1 -0
- package/dist/field/chevron.js +74 -0
- package/dist/field/chevron.js.map +1 -0
- package/dist/field/index.d.ts +2 -1
- package/dist/field/index.js +359 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/files/index.d.ts +18 -0
- package/dist/files/index.js +107 -0
- package/dist/files/index.js.map +1 -0
- package/dist/form/index.d.ts +5 -2
- package/dist/form/index.js +64 -85
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/index.js +128 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +36 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1734 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +37 -3
- package/dist/index.js +36 -3
- package/dist/indicator/paths.js +23 -1
- package/dist/indicator/paths.js.map +1 -1
- package/dist/modal/index.js +92 -77
- package/dist/modal/index.js.map +1 -1
- package/dist/number/keyboard.js +16 -0
- package/dist/number/keyboard.js.map +1 -0
- package/dist/overlay/anchored.js +68 -38
- package/dist/overlay/anchored.js.map +1 -1
- package/dist/overlay/keyboard.js +57 -0
- package/dist/overlay/keyboard.js.map +1 -0
- package/dist/overlay/panel.js +173 -19
- package/dist/overlay/panel.js.map +1 -1
- package/dist/overlay/placement.js +13 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/picker/index.js +322 -0
- package/dist/picker/index.js.map +1 -0
- package/dist/press/index.d.ts +2 -0
- package/dist/press/index.js +102 -100
- package/dist/press/index.js.map +1 -1
- package/dist/row/index.js +77 -69
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +13 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/field.js +277 -0
- package/dist/segments/field.js.map +1 -0
- package/dist/segments/index.js +574 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +24 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/slider/index.js +145 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/swatch/index.js +56 -0
- package/dist/swatch/index.js.map +1 -0
- package/package.json +11 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","Ref","StyleProp","ViewProps","ViewStyle","Color","use","StyleSheet","View","Chequer","useLocaleOf","useMessages","colorNameOf","colorOf","PickedColorContext","SwatchColorContext","useTheme","composeStyles","themedStyles","SIZE","stylesOf","colors","radii","create","ground","borderRadius","xs","height","overflow","width","hairline","absoluteFill","borderColor","outlineVariant","borderWidth","ColorSwatchProps","Omit","color","colorName","ref","style","ColorSwatch","t0","$","_c","label","props","styles","locale","undefined","messages","itemColor","pickedColor","value","alpha","getChannelValue","name","transparent","T0","t1","t2","t3","filter","Boolean","join","t4","t5","T1","t6","backgroundColor","toString","t7","t8","t9","_c"],"sources":["../../../src/components/color-swatch/index.tsx"],"sourcesContent":["import type { ComponentRef, Ref } from 'react'\nimport type { StyleProp, ViewProps, ViewStyle } from 'react-native'\nimport type { Color } from 'react-stately'\n\nimport { use } from 'react'\nimport { StyleSheet, View } from 'react-native'\n\nimport { Chequer } from '../../chequer'\nimport { useLocaleOf, useMessages } from '../../i18n/provider'\nimport {\n colorNameOf,\n colorOf,\n PickedColorContext,\n SwatchColorContext,\n} from '../../swatch'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\n\n// A single colour, drawn as a square, as kanso-ui's ColorSwatch draws it.\n// Material Design carries no page for this: its colour guidance is about the\n// roles a component takes, not about showing a colour as a value. So the\n// shape is the library's own, built from what the rest of it already uses: a\n// 40dp square on the extra-small corner.\n//\n// Three things follow from that, and each is a choice rather than a reading.\n//\n// **A swatch is outlined.** Its own colour is the content, so it cannot carry\n// a contrasting one, and a white swatch on a light surface, or a near-black\n// one in dark mode, would otherwise have no edge at all. The outline is the\n// 1dp outline variant hairline a field's box takes, drawn as the border of a\n// view laid over the colour, so it sits on the colour's edge rather than\n// around it.\n//\n// **Transparency is drawn against a chequer rather than against the page.**\n// The chequer is src/chequer's, which follows the theme. It is drawn only\n// behind a colour with some transparency, since an opaque one would cover it\n// whole.\n//\n// **The swatch names itself from the colour.** React Stately's `Color` gives\n// the name, \"light vibrant cyan blue, 60% transparent\", in the\n// `I18nProvider`'s locale, as React Aria's swatch does on web, and a screen\n// reader hears the swatch as an image by that name. A colour with no alpha\n// left is called transparent, in the library's own words, since there is no\n// colour left to name.\n\nconst SIZE = 40\n\nconst stylesOf = themedStyles(({ colors, radii }) =>\n StyleSheet.create({\n ground: {\n borderRadius: radii.xs,\n height: SIZE,\n overflow: 'hidden',\n width: SIZE,\n },\n hairline: {\n ...StyleSheet.absoluteFill,\n borderColor: colors.outlineVariant,\n borderRadius: radii.xs,\n borderWidth: 1,\n },\n }),\n)\n\ntype ColorSwatchProps = Omit<ViewProps, 'children' | 'style'> & {\n /**\n * The colour to show: a CSS colour string, or a `Color` from `parseColor`,\n * which this package re-exports. Left out, the swatch draws the colour of\n * the `ColorSwatchPicker.Item` it is drawn in.\n * @default the item's colour, else '#fff0'\n */\n readonly color?: Color | string\n /**\n * What the swatch is called, in place of the name the colour gives itself.\n * A call site's `aria-label` follows either, after a comma.\n */\n readonly colorName?: string\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n}\n\n/**\n * A colour shown as a value: a square of it, with a chequer behind so\n * transparency reads as transparency. The colour is a CSS string, or a\n * `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * import { ColorSwatch, parseColor } from '@kanso-labs/react-native-kanso-ui'\n *\n * <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />\n * ```\n *\n * It names itself from the colour, \"light vibrant cyan blue, 60%\n * transparent\", in the `I18nProvider`'s locale, or the device's outside one,\n * so it needs no label. Pass `colorName` to say something else instead.\n *\n * `style`, `ref` and `testID` land on the square, and a `style` there applies\n * over the swatch's own, so a call site sets another size with `width` and\n * `height`. The colour fills whatever square it is given.\n *\n * Inside a `ColorPicker` it shows the picker's colour where it is given no\n * `color` and sits in no `ColorSwatchPicker` item.\n */\nfunction ColorSwatch({\n 'aria-label': label,\n color,\n colorName,\n style,\n ...props\n}: ColorSwatchProps) {\n const styles = stylesOf(useTheme())\n const locale = useLocaleOf(undefined)\n const messages = useMessages()\n const itemColor = use(SwatchColorContext)\n const pickedColor = use(PickedColorContext)?.value\n const value = colorOf(color ?? itemColor ?? pickedColor ?? '#fff0')\n const alpha = value.getChannelValue('alpha')\n const name = colorName ?? colorNameOf(value, locale, messages.transparent)\n\n return (\n <View\n accessible\n role=\"img\"\n {...props}\n aria-label={[name, label].filter(Boolean).join(', ')}\n style={composeStyles<ViewStyle>(styles.ground, style)}\n >\n {alpha < 1 ? <Chequer /> : null}\n <View\n style={composeStyles<ViewStyle>(StyleSheet.absoluteFill, {\n backgroundColor: value.toString('css'),\n })}\n />\n <View style={styles.hairline} />\n </View>\n )\n}\n\nexport { ColorSwatch }\nexport type { ColorSwatchProps }\n"],"mappings":";;;;;;;;;;AA6CA,MAAMmB,OAAO;AAEb,MAAMC,WAAWF,cAAc,EAAEG,QAAQC,YACvCf,WAAWgB,OAAO;CAChBC,QAAQ;EACNC,cAAcH,MAAMI;EACpBC,QAAQR;EACRS,UAAU;EACVC,OAAOV;CACT;CACAW,UAAU;EACR,GAAGvB,WAAWwB;EACdC,aAAaX,OAAOY;EACpBR,cAAcH,MAAMI;EACpBQ,aAAa;CACf;AACF,CAAC,CACH;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAAO,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAP;CAAA,IAAAC;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAN;CAAA,IAAAG,EAAA,OAAAD,IAAA;EAAqB,CAAA,CAAA,cAAAG,OAAAR,OAAAC,WAAAE,OAAA,GAAAM,SAAAJ;EAMFC,EAAA,KAAAD;EAAAC,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAH;CAAA,OAAA;EAAAH,QAAAM,EAAA;EAAAL,YAAAK,EAAA;EAAAE,QAAAF,EAAA;EAAAG,QAAAH,EAAA;EAAAH,QAAAG,EAAA;CAAA;CACjB,MAAAI,SAAe3B,SAASJ,SAAS,CAAC;CAClC,MAAAgC,SAAetC,YAAYuC,KAAAA,CAAS;CACpC,MAAAC,WAAiBvC,YAAY;CAC7B,MAAAwC,YAAkB7C,IAAIS,kBAAkB;CACxC,MAAAqC,cAAoB9C,IAAIQ,kBAAyB,CAAC,EAAAuC;CAClD,MAAAA,QAAcxC,QAAQwB,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;IAKAC;GAbG;;EAcE7B,EAAA,MAAAe;EAAAf,EAAA,MAAAG;EAAAH,EAAA,MAAAkB;EAAAlB,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;EAAAvB,EAAA,MAAA4B;EAAA5B,EAAA,MAAA6B;EAAA7B,EAAA,MAAA8B;CAAA,OAAAA,KAAA9B,EAAA;CAAA,OAdP8B;AAcO"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PressableProps, StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { ComponentRef, ReactNode, Ref } from "react";
|
|
3
|
+
import { Color } from "react-stately";
|
|
4
|
+
//#region src/components/color-swatch-picker/index.d.ts
|
|
5
|
+
type ColorSwatchPickerItemProps = Omit<PressableProps, 'children' | 'disabled' | 'style'> & {
|
|
6
|
+
/**
|
|
7
|
+
* What the item draws. A `ColorSwatch` by default, which draws the item's
|
|
8
|
+
* colour, as any `ColorSwatch` inside it does unless given one of its own.
|
|
9
|
+
*/
|
|
10
|
+
readonly children?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The colour the item stands for: a CSS colour string, or a `Color` from
|
|
13
|
+
* `parseColor`. The item is named by it unless given an `aria-label`.
|
|
14
|
+
* @default '#0000'
|
|
15
|
+
*/
|
|
16
|
+
readonly color?: Color | string;
|
|
17
|
+
/**
|
|
18
|
+
* Rules the colour out, so the swatch cannot be chosen.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
readonly isDisabled?: boolean;
|
|
22
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
23
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
24
|
+
};
|
|
25
|
+
/** How a `ColorSwatchPicker` lays out its swatches. */
|
|
26
|
+
type ColorSwatchPickerLayout = 'grid' | 'stack';
|
|
27
|
+
type ColorSwatchPickerProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
28
|
+
/** The swatches, each a `ColorSwatchPicker.Item` with a `color`. */
|
|
29
|
+
readonly children?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* The colour chosen at first, when the picker keeps its own value: a CSS
|
|
32
|
+
* colour string, or a `Color` from `parseColor`.
|
|
33
|
+
*/
|
|
34
|
+
readonly defaultValue?: Color | string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the swatches wrap onto rows, or line up in one column.
|
|
37
|
+
* @default 'grid'
|
|
38
|
+
*/
|
|
39
|
+
readonly layout?: ColorSwatchPickerLayout;
|
|
40
|
+
/** Called with the item's colour when another swatch is chosen. */
|
|
41
|
+
readonly onChange?: (value: Color) => void;
|
|
42
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
43
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
44
|
+
/** The colour chosen, when the call site holds the value. */
|
|
45
|
+
readonly value?: Color | string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A set of colours to choose one from, drawn as swatches. Pass `value` with
|
|
49
|
+
* `onChange` to control it, or `defaultValue`, as a CSS colour string or a
|
|
50
|
+
* `Color` from `parseColor`, which this package re-exports.
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <ColorSwatchPicker defaultValue="#6750A4">
|
|
54
|
+
* <ColorSwatchPicker.Item color="#6750A4" />
|
|
55
|
+
* <ColorSwatchPicker.Item color="#625B71" />
|
|
56
|
+
* </ColorSwatchPicker>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* The chosen swatch carries a ring. A screen reader hears a radio group
|
|
60
|
+
* named by `aria-label` or `aria-labelledby`, and "Color swatches" in the
|
|
61
|
+
* `I18nProvider`'s locale otherwise. `style`, `ref` and `testID` land on the
|
|
62
|
+
* set as a whole, which is the element a layout positions.
|
|
63
|
+
*
|
|
64
|
+
* Inside a `ColorPicker` it takes the picker's colour where it is given no
|
|
65
|
+
* `value`, and reports a change to the picker before its own `onChange`.
|
|
66
|
+
*/
|
|
67
|
+
declare function ColorSwatchPicker({ 'aria-label': ariaLabel, children, defaultValue, layout, onChange, style, value, ...props }: ColorSwatchPickerProps): import("react").JSX.Element;
|
|
68
|
+
declare namespace ColorSwatchPicker {
|
|
69
|
+
var Item: typeof ColorSwatchPickerItem;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One swatch in a {@link ColorSwatchPicker}, which chooses its `color` when
|
|
73
|
+
* pressed. Draws a `ColorSwatch` of that colour unless given other children,
|
|
74
|
+
* and is named by the colour in the picker's locale.
|
|
75
|
+
*
|
|
76
|
+
* `style`, `ref` and `testID` land on the pressable item around the swatch.
|
|
77
|
+
*/
|
|
78
|
+
declare function ColorSwatchPickerItem({ 'aria-label': ariaLabel, children, color: own, isDisabled, onPress, style, ...props }: ColorSwatchPickerItemProps): import("react").JSX.Element;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ColorSwatchPicker, ColorSwatchPickerItem, type ColorSwatchPickerItemProps, type ColorSwatchPickerLayout, type ColorSwatchPickerProps };
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { useTheme } from "../../theme/scope.js";
|
|
2
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
3
|
+
import { hitSlop, usePressFeedback } from "../../press/index.js";
|
|
4
|
+
import { useLocaleOf, useMessages } from "../../i18n/provider.js";
|
|
5
|
+
import { SwatchColorContext, colorNameOf, colorOf, usePickedColor } from "../../swatch/index.js";
|
|
6
|
+
import { ColorSwatch } from "../color-swatch/index.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { Pressable, StyleSheet, View } from "react-native";
|
|
9
|
+
import { createContext, use } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useColorPickerState } from "react-stately/useColorPickerState";
|
|
12
|
+
//#region src/components/color-swatch-picker/index.tsx
|
|
13
|
+
const SWATCH = 40;
|
|
14
|
+
const RING = 2;
|
|
15
|
+
const FOCUS_OFFSET = 6;
|
|
16
|
+
const PickerContext = createContext(null);
|
|
17
|
+
const styles = StyleSheet.create({ stack: { flexDirection: "column" } });
|
|
18
|
+
const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) => StyleSheet.create({
|
|
19
|
+
disabled: { opacity: stateLayerOpacity.disabledContent },
|
|
20
|
+
focused: {
|
|
21
|
+
outlineColor: colors.primary,
|
|
22
|
+
outlineOffset: FOCUS_OFFSET,
|
|
23
|
+
outlineStyle: "solid",
|
|
24
|
+
outlineWidth: RING
|
|
25
|
+
},
|
|
26
|
+
hovered: { borderColor: colors.outlineVariant },
|
|
27
|
+
item: { borderRadius: radii.xs },
|
|
28
|
+
picker: {
|
|
29
|
+
alignItems: "flex-start",
|
|
30
|
+
flexDirection: "row",
|
|
31
|
+
flexWrap: "wrap",
|
|
32
|
+
gap: spacing.sm
|
|
33
|
+
},
|
|
34
|
+
pressed: { borderColor: colors.outline },
|
|
35
|
+
ring: {
|
|
36
|
+
borderRadius: radii.xs + Math.min(radii.xs, 4),
|
|
37
|
+
borderWidth: RING,
|
|
38
|
+
bottom: -4,
|
|
39
|
+
left: -4,
|
|
40
|
+
pointerEvents: "none",
|
|
41
|
+
position: "absolute",
|
|
42
|
+
right: -4,
|
|
43
|
+
top: -4
|
|
44
|
+
},
|
|
45
|
+
selected: { borderColor: colors.primary }
|
|
46
|
+
}));
|
|
47
|
+
const REACH = hitSlop(SWATCH, SWATCH);
|
|
48
|
+
function chooseThen(state, color, isSelected, onPress) {
|
|
49
|
+
return (event) => {
|
|
50
|
+
onPress?.(event);
|
|
51
|
+
if (!isSelected) state.setColor(color);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A set of colours to choose one from, drawn as swatches. Pass `value` with
|
|
56
|
+
* `onChange` to control it, or `defaultValue`, as a CSS colour string or a
|
|
57
|
+
* `Color` from `parseColor`, which this package re-exports.
|
|
58
|
+
*
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <ColorSwatchPicker defaultValue="#6750A4">
|
|
61
|
+
* <ColorSwatchPicker.Item color="#6750A4" />
|
|
62
|
+
* <ColorSwatchPicker.Item color="#625B71" />
|
|
63
|
+
* </ColorSwatchPicker>
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* The chosen swatch carries a ring. A screen reader hears a radio group
|
|
67
|
+
* named by `aria-label` or `aria-labelledby`, and "Color swatches" in the
|
|
68
|
+
* `I18nProvider`'s locale otherwise. `style`, `ref` and `testID` land on the
|
|
69
|
+
* set as a whole, which is the element a layout positions.
|
|
70
|
+
*
|
|
71
|
+
* Inside a `ColorPicker` it takes the picker's colour where it is given no
|
|
72
|
+
* `value`, and reports a change to the picker before its own `onChange`.
|
|
73
|
+
*/
|
|
74
|
+
function ColorSwatchPicker(t0) {
|
|
75
|
+
const $ = c(22);
|
|
76
|
+
let ariaLabel;
|
|
77
|
+
let children;
|
|
78
|
+
let defaultValue;
|
|
79
|
+
let onChange;
|
|
80
|
+
let props;
|
|
81
|
+
let style;
|
|
82
|
+
let t1;
|
|
83
|
+
let value;
|
|
84
|
+
if ($[0] !== t0) {
|
|
85
|
+
({"aria-label": ariaLabel, children, defaultValue, layout: t1, onChange, style, value, ...props} = t0);
|
|
86
|
+
$[0] = t0;
|
|
87
|
+
$[1] = ariaLabel;
|
|
88
|
+
$[2] = children;
|
|
89
|
+
$[3] = defaultValue;
|
|
90
|
+
$[4] = onChange;
|
|
91
|
+
$[5] = props;
|
|
92
|
+
$[6] = style;
|
|
93
|
+
$[7] = t1;
|
|
94
|
+
$[8] = value;
|
|
95
|
+
} else {
|
|
96
|
+
ariaLabel = $[1];
|
|
97
|
+
children = $[2];
|
|
98
|
+
defaultValue = $[3];
|
|
99
|
+
onChange = $[4];
|
|
100
|
+
props = $[5];
|
|
101
|
+
style = $[6];
|
|
102
|
+
t1 = $[7];
|
|
103
|
+
value = $[8];
|
|
104
|
+
}
|
|
105
|
+
const layout = t1 === void 0 ? "grid" : t1;
|
|
106
|
+
const own = stylesOf(useTheme());
|
|
107
|
+
const messages = useMessages();
|
|
108
|
+
const picked = usePickedColor(value, onChange);
|
|
109
|
+
let t2;
|
|
110
|
+
if ($[9] !== defaultValue || $[10] !== picked.onChange || $[11] !== picked.value) {
|
|
111
|
+
t2 = {
|
|
112
|
+
defaultValue,
|
|
113
|
+
onChange: picked.onChange,
|
|
114
|
+
value: picked.value
|
|
115
|
+
};
|
|
116
|
+
$[9] = defaultValue;
|
|
117
|
+
$[10] = picked.onChange;
|
|
118
|
+
$[11] = picked.value;
|
|
119
|
+
$[12] = t2;
|
|
120
|
+
} else t2 = $[12];
|
|
121
|
+
const state = useColorPickerState(t2);
|
|
122
|
+
const label = ariaLabel ?? (props["aria-labelledby"] === void 0 ? messages.colorSwatches : void 0);
|
|
123
|
+
const T0 = View;
|
|
124
|
+
const t3 = "radiogroup";
|
|
125
|
+
const t4 = composeStyles(own.picker, layout === "stack" ? styles.stack : void 0, style);
|
|
126
|
+
let t5;
|
|
127
|
+
if ($[13] !== children || $[14] !== state) {
|
|
128
|
+
t5 = /* @__PURE__ */ jsx(PickerContext, {
|
|
129
|
+
value: state,
|
|
130
|
+
children
|
|
131
|
+
});
|
|
132
|
+
$[13] = children;
|
|
133
|
+
$[14] = state;
|
|
134
|
+
$[15] = t5;
|
|
135
|
+
} else t5 = $[15];
|
|
136
|
+
let t6;
|
|
137
|
+
if ($[16] !== T0 || $[17] !== label || $[18] !== props || $[19] !== t4 || $[20] !== t5) {
|
|
138
|
+
t6 = /* @__PURE__ */ jsx(T0, {
|
|
139
|
+
...props,
|
|
140
|
+
"aria-label": label,
|
|
141
|
+
role: t3,
|
|
142
|
+
style: t4,
|
|
143
|
+
children: t5
|
|
144
|
+
});
|
|
145
|
+
$[16] = T0;
|
|
146
|
+
$[17] = label;
|
|
147
|
+
$[18] = props;
|
|
148
|
+
$[19] = t4;
|
|
149
|
+
$[20] = t5;
|
|
150
|
+
$[21] = t6;
|
|
151
|
+
} else t6 = $[21];
|
|
152
|
+
return t6;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One swatch in a {@link ColorSwatchPicker}, which chooses its `color` when
|
|
156
|
+
* pressed. Draws a `ColorSwatch` of that colour unless given other children,
|
|
157
|
+
* and is named by the colour in the picker's locale.
|
|
158
|
+
*
|
|
159
|
+
* `style`, `ref` and `testID` land on the pressable item around the swatch.
|
|
160
|
+
*/
|
|
161
|
+
function ColorSwatchPickerItem(t0) {
|
|
162
|
+
const $ = c(30);
|
|
163
|
+
let ariaLabel;
|
|
164
|
+
let children;
|
|
165
|
+
let onPress;
|
|
166
|
+
let props;
|
|
167
|
+
let style;
|
|
168
|
+
let t1;
|
|
169
|
+
let t2;
|
|
170
|
+
if ($[0] !== t0) {
|
|
171
|
+
({"aria-label": ariaLabel, children, color: t1, isDisabled: t2, onPress, style, ...props} = t0);
|
|
172
|
+
$[0] = t0;
|
|
173
|
+
$[1] = ariaLabel;
|
|
174
|
+
$[2] = children;
|
|
175
|
+
$[3] = onPress;
|
|
176
|
+
$[4] = props;
|
|
177
|
+
$[5] = style;
|
|
178
|
+
$[6] = t1;
|
|
179
|
+
$[7] = t2;
|
|
180
|
+
} else {
|
|
181
|
+
ariaLabel = $[1];
|
|
182
|
+
children = $[2];
|
|
183
|
+
onPress = $[3];
|
|
184
|
+
props = $[4];
|
|
185
|
+
style = $[5];
|
|
186
|
+
t1 = $[6];
|
|
187
|
+
t2 = $[7];
|
|
188
|
+
}
|
|
189
|
+
const own = t1 === void 0 ? "#0000" : t1;
|
|
190
|
+
const isDisabled = t2 === void 0 ? false : t2;
|
|
191
|
+
const theme = useTheme();
|
|
192
|
+
const state = use(PickerContext);
|
|
193
|
+
const locale = useLocaleOf(void 0);
|
|
194
|
+
const messages = useMessages();
|
|
195
|
+
const color = colorOf(own);
|
|
196
|
+
let t3;
|
|
197
|
+
if ($[8] !== isDisabled || $[9] !== theme.colors.primary) {
|
|
198
|
+
t3 = {
|
|
199
|
+
color: theme.colors.primary,
|
|
200
|
+
disabled: isDisabled,
|
|
201
|
+
disableRipple: true
|
|
202
|
+
};
|
|
203
|
+
$[8] = isDisabled;
|
|
204
|
+
$[9] = theme.colors.primary;
|
|
205
|
+
$[10] = t3;
|
|
206
|
+
} else t3 = $[10];
|
|
207
|
+
const feedback = usePressFeedback(t3);
|
|
208
|
+
if (state === null) throw new Error("A ColorSwatchPicker.Item is drawn inside a ColorSwatchPicker, which holds its value.");
|
|
209
|
+
const styled = stylesOf(theme);
|
|
210
|
+
let t4;
|
|
211
|
+
if ($[11] !== state.color) {
|
|
212
|
+
t4 = state.color.toString("hexa");
|
|
213
|
+
$[11] = state.color;
|
|
214
|
+
$[12] = t4;
|
|
215
|
+
} else t4 = $[12];
|
|
216
|
+
const isSelected = t4 === color.toString("hexa");
|
|
217
|
+
const ring = ringOf(styled, {
|
|
218
|
+
hovered: feedback.hovered,
|
|
219
|
+
isSelected,
|
|
220
|
+
pressed: feedback.pressed
|
|
221
|
+
});
|
|
222
|
+
const T0 = Pressable;
|
|
223
|
+
const t5 = ariaLabel ?? colorNameOf(color, locale, messages.transparent);
|
|
224
|
+
const t6 = "radio";
|
|
225
|
+
const t7 = feedback.handlers;
|
|
226
|
+
const t8 = REACH;
|
|
227
|
+
const t9 = chooseThen(state, color, isSelected, onPress);
|
|
228
|
+
const t10 = composeStyles(styled.item, feedback.ring === void 0 ? void 0 : styled.focused, isDisabled ? styled.disabled : void 0, style);
|
|
229
|
+
let t11;
|
|
230
|
+
if ($[13] !== children) {
|
|
231
|
+
t11 = children ?? /* @__PURE__ */ jsx(ColorSwatch, {});
|
|
232
|
+
$[13] = children;
|
|
233
|
+
$[14] = t11;
|
|
234
|
+
} else t11 = $[14];
|
|
235
|
+
let t12;
|
|
236
|
+
if ($[15] !== color || $[16] !== t11) {
|
|
237
|
+
t12 = /* @__PURE__ */ jsx(View, {
|
|
238
|
+
"aria-hidden": true,
|
|
239
|
+
children: /* @__PURE__ */ jsx(SwatchColorContext, {
|
|
240
|
+
value: color,
|
|
241
|
+
children: t11
|
|
242
|
+
})
|
|
243
|
+
});
|
|
244
|
+
$[15] = color;
|
|
245
|
+
$[16] = t11;
|
|
246
|
+
$[17] = t12;
|
|
247
|
+
} else t12 = $[17];
|
|
248
|
+
const t13 = ring === void 0 ? null : /* @__PURE__ */ jsx(View, { style: composeStyles(styled.ring, ring) });
|
|
249
|
+
let t14;
|
|
250
|
+
if ($[18] !== T0 || $[19] !== feedback.handlers || $[20] !== isDisabled || $[21] !== isSelected || $[22] !== props || $[23] !== t10 || $[24] !== t12 || $[25] !== t13 || $[26] !== t5 || $[27] !== t8 || $[28] !== t9) {
|
|
251
|
+
t14 = /* @__PURE__ */ jsxs(T0, {
|
|
252
|
+
"aria-checked": isSelected,
|
|
253
|
+
"aria-label": t5,
|
|
254
|
+
role: t6,
|
|
255
|
+
...props,
|
|
256
|
+
...t7,
|
|
257
|
+
disabled: isDisabled,
|
|
258
|
+
hitSlop: t8,
|
|
259
|
+
onPress: t9,
|
|
260
|
+
style: t10,
|
|
261
|
+
children: [t12, t13]
|
|
262
|
+
});
|
|
263
|
+
$[18] = T0;
|
|
264
|
+
$[19] = feedback.handlers;
|
|
265
|
+
$[20] = isDisabled;
|
|
266
|
+
$[21] = isSelected;
|
|
267
|
+
$[22] = props;
|
|
268
|
+
$[23] = t10;
|
|
269
|
+
$[24] = t12;
|
|
270
|
+
$[25] = t13;
|
|
271
|
+
$[26] = t5;
|
|
272
|
+
$[27] = t8;
|
|
273
|
+
$[28] = t9;
|
|
274
|
+
$[29] = t14;
|
|
275
|
+
} else t14 = $[29];
|
|
276
|
+
return t14;
|
|
277
|
+
}
|
|
278
|
+
function ringOf(styled, { hovered, isSelected, pressed }) {
|
|
279
|
+
if (isSelected) return styled.selected;
|
|
280
|
+
if (pressed) return styled.pressed;
|
|
281
|
+
return hovered ? styled.hovered : void 0;
|
|
282
|
+
}
|
|
283
|
+
ColorSwatchPicker.Item = ColorSwatchPickerItem;
|
|
284
|
+
//#endregion
|
|
285
|
+
export { ColorSwatchPicker, ColorSwatchPickerItem };
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","PressableProps","StyleProp","ViewProps","ViewStyle","Color","ColorPickerState","createContext","use","Pressable","StyleSheet","View","useColorPickerState","useLocaleOf","useMessages","hitSlop","usePressFeedback","colorNameOf","colorOf","SwatchColorContext","usePickedColor","useTheme","composeStyles","themedStyles","ColorSwatch","ColorSwatchPickerItemProps","Omit","children","color","isDisabled","ref","style","ColorSwatchPickerLayout","ColorSwatchPickerProps","defaultValue","layout","onChange","value","SWATCH","RING","RING_GAP","FOCUS_OFFSET","PickerContext","styles","create","stack","flexDirection","stylesOf","colors","radii","spacing","stateLayerOpacity","disabled","opacity","disabledContent","focused","outlineColor","primary","outlineOffset","outlineStyle","outlineWidth","hovered","borderColor","outlineVariant","item","borderRadius","xs","picker","alignItems","flexWrap","gap","sm","pressed","outline","ring","Math","min","borderWidth","bottom","left","pointerEvents","position","right","top","selected","REACH","chooseThen","state","isSelected","onPress","event","Parameters","NonNullable","setColor","ColorSwatchPicker","t0","$","_c","ariaLabel","props","t1","undefined","own","messages","picked","t2","label","colorSwatches","T0","t3","t4","t5","t6","ColorSwatchPickerItem","theme","locale","disableRipple","feedback","Error","styled","toString","ringOf","transparent","t7","handlers","t9","t10","t11","t12","t13","t14","t8","ReturnType","Item","_c"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n ViewProps,\n ViewStyle,\n} from 'react-native'\nimport type { Color } from 'react-stately'\nimport type { ColorPickerState } from 'react-stately/useColorPickerState'\n\nimport { createContext, use } from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport { useColorPickerState } from 'react-stately/useColorPickerState'\n\nimport { useLocaleOf, useMessages } from '../../i18n/provider'\nimport { hitSlop, usePressFeedback } from '../../press'\nimport {\n colorNameOf,\n colorOf,\n SwatchColorContext,\n usePickedColor,\n} from '../../swatch'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { ColorSwatch } from '../color-swatch'\n\n// A set of colours to choose one from, as kanso-ui's ColorSwatchPicker draws\n// it: each a swatch, one of them chosen. Material Design carries no page for\n// this either, so what an item looks like when it is chosen is the library's\n// own, and web's choices hold here.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the set, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it. It is 2dp of primary with 2dp clear of the\n// swatch, the border of a view laid around it, so it leaves the colour whole\n// and is not a shadow, which a high-contrast mode drops. Its corner follows\n// the swatch's 4dp further out, and stays square where a scheme squares the\n// swatch.\n//\n// **Hover and press are a ring too, in the place selection takes.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen. So\n// an unchosen swatch takes a ring where the chosen one's would be, in the\n// outline roles rather than primary so it cannot be read as chosen: outline\n// variant under a pointer, and outline while it is pressed.\n//\n// **Focus is an outline further out**, 2dp of primary 6dp from the swatch,\n// so a swatch that is chosen and focused keeps both rings.\n//\n// The value is React Stately's colour picker state, as React Aria's own\n// picker holds it, and an item stands for its colour in hexadecimal with its\n// alpha, so two items of one colour are one choice. A screen reader hears a\n// radio group, named \"Color swatches\" in the locale unless `aria-label` or\n// `aria-labelledby` names it, and each swatch a radio named by its colour and\n// reporting whether it is checked; what the item draws is hidden from it,\n// since the radio's name already says it.\n//\n// Two departures from web. The arrow keys do not move between the swatches:\n// each is a stop of its own for a hardware keyboard, and activating it there\n// chooses it. And `layout` says how the swatches are laid out rather than\n// which keys move between them, since there are none: a grid wraps them onto\n// rows, and a stack lines them up in one column, as React Aria's own stack\n// does.\n\ntype ColorSwatchPickerItemProps = Omit<\n PressableProps,\n 'children' | 'disabled' | 'style'\n> & {\n /**\n * What the item draws. A `ColorSwatch` by default, which draws the item's\n * colour, as any `ColorSwatch` inside it does unless given one of its own.\n */\n readonly children?: ReactNode\n /**\n * The colour the item stands for: a CSS colour string, or a `Color` from\n * `parseColor`. The item is named by it unless given an `aria-label`.\n * @default '#0000'\n */\n readonly color?: Color | string\n /**\n * Rules the colour out, so the swatch cannot be chosen.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n}\n\n/** How a `ColorSwatchPicker` lays out its swatches. */\ntype ColorSwatchPickerLayout = 'grid' | 'stack'\n\ntype ColorSwatchPickerProps = Omit<ViewProps, 'children' | 'style'> & {\n /** The swatches, each a `ColorSwatchPicker.Item` with a `color`. */\n readonly children?: ReactNode\n /**\n * The colour chosen at first, when the picker keeps its own value: a CSS\n * colour string, or a `Color` from `parseColor`.\n */\n readonly defaultValue?: Color | string\n /**\n * Whether the swatches wrap onto rows, or line up in one column.\n * @default 'grid'\n */\n readonly layout?: ColorSwatchPickerLayout\n /** Called with the item's colour when another swatch is chosen. */\n readonly onChange?: (value: Color) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n /** The colour chosen, when the call site holds the value. */\n readonly value?: Color | string\n}\n\n// The swatch's side, which the item's target is brought up to 48dp from, and\n// the ring's width and the room it keeps clear of the swatch.\nconst SWATCH = 40\nconst RING = 2\nconst RING_GAP = 2\nconst FOCUS_OFFSET = 6\n\nconst PickerContext = createContext<ColorPickerState | null>(null)\n\nconst styles = StyleSheet.create({\n stack: {\n flexDirection: 'column',\n },\n})\n\nconst stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>\n StyleSheet.create({\n disabled: {\n opacity: stateLayerOpacity.disabledContent,\n },\n focused: {\n outlineColor: colors.primary,\n outlineOffset: FOCUS_OFFSET,\n outlineStyle: 'solid',\n outlineWidth: RING,\n },\n hovered: {\n borderColor: colors.outlineVariant,\n },\n item: {\n borderRadius: radii.xs,\n },\n picker: {\n alignItems: 'flex-start',\n flexDirection: 'row',\n flexWrap: 'wrap',\n gap: spacing.sm,\n },\n pressed: {\n borderColor: colors.outline,\n },\n ring: {\n borderRadius: radii.xs + Math.min(radii.xs, RING + RING_GAP),\n borderWidth: RING,\n bottom: -(RING + RING_GAP),\n left: -(RING + RING_GAP),\n pointerEvents: 'none',\n position: 'absolute',\n right: -(RING + RING_GAP),\n top: -(RING + RING_GAP),\n },\n selected: {\n borderColor: colors.primary,\n },\n }),\n)\n\nconst REACH = hitSlop(SWATCH, SWATCH)\n\n// A press on a swatch: the call site's own `onPress`, then the choice, which\n// the chosen swatch leaves as it is, as React Aria's picker keeps its one\n// choice. Built by a call rather than declared in the component, which is\n// what react-perf's jsx-no-new-function-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction chooseThen(\n state: ColorPickerState,\n color: Color,\n isSelected: boolean,\n onPress: PressableProps['onPress'],\n) {\n return (event: Parameters<NonNullable<PressableProps['onPress']>>[0]) => {\n onPress?.(event)\n\n if (!isSelected) {\n state.setColor(color)\n }\n }\n}\n\n/**\n * A set of colours to choose one from, drawn as swatches. Pass `value` with\n * `onChange` to control it, or `defaultValue`, as a CSS colour string or a\n * `Color` from `parseColor`, which this package re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * The chosen swatch carries a ring. A screen reader hears a radio group\n * named by `aria-label` or `aria-labelledby`, and \"Color swatches\" in the\n * `I18nProvider`'s locale otherwise. `style`, `ref` and `testID` land on the\n * set as a whole, which is the element a layout positions.\n *\n * Inside a `ColorPicker` it takes the picker's colour where it is given no\n * `value`, and reports a change to the picker before its own `onChange`.\n */\nfunction ColorSwatchPicker({\n 'aria-label': ariaLabel,\n children,\n defaultValue,\n layout = 'grid',\n onChange,\n style,\n value,\n ...props\n}: ColorSwatchPickerProps) {\n const own = stylesOf(useTheme())\n const messages = useMessages()\n const picked = usePickedColor(value, onChange)\n const state = useColorPickerState({\n defaultValue,\n onChange: picked.onChange,\n value: picked.value,\n })\n const label =\n ariaLabel ??\n (props['aria-labelledby'] === undefined\n ? messages.colorSwatches\n : undefined)\n\n return (\n <View\n {...props}\n aria-label={label}\n role=\"radiogroup\"\n style={composeStyles<ViewStyle>(\n own.picker,\n layout === 'stack' ? styles.stack : undefined,\n style,\n )}\n >\n <PickerContext value={state}>{children}</PickerContext>\n </View>\n )\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}, which chooses its `color` when\n * pressed. Draws a `ColorSwatch` of that colour unless given other children,\n * and is named by the colour in the picker's locale.\n *\n * `style`, `ref` and `testID` land on the pressable item around the swatch.\n */\nfunction ColorSwatchPickerItem({\n 'aria-label': ariaLabel,\n children,\n color: own = '#0000',\n isDisabled = false,\n onPress,\n style,\n ...props\n}: ColorSwatchPickerItemProps) {\n const theme = useTheme()\n const state = use(PickerContext)\n const locale = useLocaleOf(undefined)\n const messages = useMessages()\n const color = colorOf(own)\n const feedback = usePressFeedback({\n color: theme.colors.primary,\n disabled: isDisabled,\n disableRipple: true,\n })\n\n if (state === null) {\n throw new Error(\n 'A ColorSwatchPicker.Item is drawn inside a ColorSwatchPicker, which holds its value.',\n )\n }\n\n const styled = stylesOf(theme)\n const isSelected = state.color.toString('hexa') === color.toString('hexa')\n const ring = ringOf(styled, {\n hovered: feedback.hovered,\n isSelected,\n pressed: feedback.pressed,\n })\n\n return (\n <Pressable\n aria-checked={isSelected}\n aria-label={ariaLabel ?? colorNameOf(color, locale, messages.transparent)}\n role=\"radio\"\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n hitSlop={REACH}\n onPress={chooseThen(state, color, isSelected, onPress)}\n style={composeStyles<ViewStyle>(\n styled.item,\n feedback.ring === undefined ? undefined : styled.focused,\n isDisabled ? styled.disabled : undefined,\n style,\n )}\n >\n <View aria-hidden>\n <SwatchColorContext value={color}>\n {children ?? <ColorSwatch />}\n </SwatchColorContext>\n </View>\n {ring === undefined ? null : (\n <View style={composeStyles<ViewStyle>(styled.ring, ring)} />\n )}\n </Pressable>\n )\n}\n\n// The ring a swatch draws, if any: primary while chosen, which the pointer\n// cannot take away, else outline while pressed and outline variant while a\n// pointer is over it. A disabled swatch reports neither.\nfunction ringOf(\n styled: ReturnType<typeof stylesOf>,\n {\n hovered,\n isSelected,\n pressed,\n }: { hovered: boolean; isSelected: boolean; pressed: boolean },\n): undefined | ViewStyle {\n if (isSelected) {\n return styled.selected\n }\n if (pressed) {\n return styled.pressed\n }\n return hovered ? styled.hovered : undefined\n}\n\nColorSwatchPicker.Item = ColorSwatchPickerItem\n\nexport { ColorSwatchPicker, ColorSwatchPickerItem }\nexport type {\n ColorSwatchPickerItemProps,\n ColorSwatchPickerLayout,\n ColorSwatchPickerProps,\n}\n"],"mappings":";;;;;;;;;;;;AAmHA,MAAMwC,SAAS;AACf,MAAMC,OAAO;AAEb,MAAME,eAAe;AAErB,MAAMC,gBAAgBnC,cAAuC,IAAI;AAEjE,MAAMoC,SAASjC,WAAWkC,OAAO,EAC/BC,OAAO,EACLC,eAAe,SACjB,EACF,CAAC;AAED,MAAMC,WAAWxB,cAAc,EAAEyB,QAAQC,OAAOC,SAASC,wBACvDzC,WAAWkC,OAAO;CAChBQ,UAAU,EACRC,SAASF,kBAAkBG,gBAC7B;CACAC,SAAS;EACPC,cAAcR,OAAOS;EACrBC,eAAejB;EACfkB,cAAc;EACdC,cAAcrB;CAChB;CACAsB,SAAS,EACPC,aAAad,OAAOe,eACtB;CACAC,MAAM,EACJC,cAAchB,MAAMiB,GACtB;CACAC,QAAQ;EACNC,YAAY;EACZtB,eAAe;EACfuB,UAAU;EACVC,KAAKpB,QAAQqB;CACf;CACAC,SAAS,EACPV,aAAad,OAAOyB,QACtB;CACAC,MAAM;EACJT,cAAchB,MAAMiB,KAAKS,KAAKC,I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react";
|
|
3
|
+
import { Color } from "react-stately";
|
|
4
|
+
//#region src/components/color-wheel/index.d.ts
|
|
5
|
+
type ColorWheelProps = {
|
|
6
|
+
/** What a screen reader calls the wheel, in place of "Hue". */
|
|
7
|
+
readonly 'aria-label'?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The colour the wheel starts at, when it keeps its own: a CSS colour
|
|
10
|
+
* string in any notation, or a `Color` from `parseColor`. Red when neither
|
|
11
|
+
* this nor `value` is given.
|
|
12
|
+
*/
|
|
13
|
+
readonly defaultValue?: Color | string;
|
|
14
|
+
/**
|
|
15
|
+
* Draws the wheel disabled, and takes no presses, drags or screen reader
|
|
16
|
+
* actions.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
readonly isDisabled?: boolean;
|
|
20
|
+
/** Called with the colour as its hue moves. */
|
|
21
|
+
readonly onChange?: (value: Color) => void;
|
|
22
|
+
/** Called with the colour once a drag, a press or an action has ended. */
|
|
23
|
+
readonly onChangeEnd?: (value: Color) => void;
|
|
24
|
+
/**
|
|
25
|
+
* How far the ring reaches from the centre, in dp. The wheel is twice this
|
|
26
|
+
* across.
|
|
27
|
+
* @default 100
|
|
28
|
+
*/
|
|
29
|
+
readonly outerRadius?: number;
|
|
30
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
31
|
+
/** Lands on the wheel. Its size comes from `outerRadius`. */
|
|
32
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
33
|
+
readonly testID?: string;
|
|
34
|
+
/**
|
|
35
|
+
* How wide the band is, in dp. The inner radius is this in from
|
|
36
|
+
* `outerRadius`, so the two cannot disagree.
|
|
37
|
+
* @default 16
|
|
38
|
+
*/
|
|
39
|
+
readonly thickness?: number;
|
|
40
|
+
/** The colour, for a call site holding it itself with `onChange`. */
|
|
41
|
+
readonly value?: Color | string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Hue as a ring, with a handle on it. Its state is React Stately's, as web's
|
|
45
|
+
* is: pass `value` with `onChange` to control it, or `defaultValue`, as a
|
|
46
|
+
* CSS colour string or a `Color` from `parseColor`, which this package
|
|
47
|
+
* re-exports.
|
|
48
|
+
*
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <ColorWheel defaultValue="hsl(200, 100%, 50%)" />
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* A wheel moves hue and nothing else, so unlike `ColorSlider` and
|
|
54
|
+
* `ColorArea` it names no channel and there is no space for one to be
|
|
55
|
+
* missing from: a hex value works here.
|
|
56
|
+
*
|
|
57
|
+
* The middle is empty rather than filled, so a `ColorArea` or a
|
|
58
|
+
* `ColorSwatch` can sit inside one. A press on the ring moves the handle
|
|
59
|
+
* there, and a drag carries it round. A screen reader hears "Hue", or
|
|
60
|
+
* `aria-label`, with the value. `style`, `ref` and `testID` land on the
|
|
61
|
+
* wheel, whose size comes from `outerRadius`. With a `testID`, the drag and
|
|
62
|
+
* the press are registered with Gesture Handler as `<testID>-pan` and
|
|
63
|
+
* `<testID>-tap`, which its `getByGestureTestId` finds in a test.
|
|
64
|
+
*
|
|
65
|
+
* Inside a `ColorPicker` it takes the picker's colour where it is given no
|
|
66
|
+
* `value`, and reports a change to the picker before its own `onChange`.
|
|
67
|
+
*/
|
|
68
|
+
declare function ColorWheel({ 'aria-label': ariaLabel, defaultValue, isDisabled, onChange, onChangeEnd, outerRadius, ref, style, testID, thickness, value }: ColorWheelProps): import("react").JSX.Element;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { ColorWheel, type ColorWheelProps };
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|