@kanso-labs/react-native-kanso-ui 0.9.0 → 0.10.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 +1331 -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/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/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/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/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 +78 -0
- package/dist/components/search-view/index.js +570 -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/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/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/tooltip/index.d.ts +101 -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 +310 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +9 -0
- 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 +92 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +20 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1394 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +35 -3
- package/dist/index.js +34 -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":["Calendar","ComponentRef","Dispatch","Ref","RefObject","SetStateAction","AccessibilityActionEvent","AccessibilityActionInfo","HostInstance","PressableProps","StyleProp","TextStyle","ViewStyle","DateFieldState","DateSegment","DateSegmentType","CalendarDate","DateFormatter","toCalendar","useEffect","useEffectEvent","useId","useImperativeHandle","useRef","useState","I18nManager","Text","NativeText","Platform","Pressable","StyleSheet","TextInput","FieldDescriptionPart","Focusable","LibraryMessages","startsWithIn","descriptionOf","FieldSegments","messagesFor","NumberParser","useTheme","composeStyles","useTypeRole","segmentStylesOf","DateSegmentsProps","described","drawing","SegmentDrawing","holding","isInvalid","label","locale","onActiveChange","type","onBeforeStart","onBlur","onEdit","onFocus","onPastEnd","ref","SegmentsHandle","state","Focusing","Pick","SegmentLineProps","Moves","away","next","previous","box","isActive","literal","parts","ReadonlySet","raisesKeyboard","text","Omit","active","entered","input","inside","nodes","Map","setActive","focusLast","focusOn","keyboard","Step","WebSegmentProps","ADJUSTABLE","name","INVISIBLE","SENTINEL","AFTER_SENTINEL","end","length","start","NUMERIC","Set","styles","create","height","opacity","position","top","width","notDrawn","display","actionOf","line","segment","event","actionName","nativeEvent","stepKey","arrivedIn","current","changedOf","segments","find","each","undefined","eraseKey","point","replace","codePointAt","typeKey","String","fromCodePoint","commonPrefixLength","texts","sorted","toSorted","first","at","last","DateSegments","t0","$","_c","props","t1","Symbol","for","t2","reportActive","t3","t4","t5","focus","typedInto","focusTo","findLast","segment_0","type_0","t6","dayPeriodsOf","formatter","hour","hour12","periodAt","hours","date","Date","setHours","formatToParts","part","value","drawn","replaceAll","has","edited","changed","eraseFrom","moves","isDisabled","isReadOnly","placeholder","parser","maximumFractionDigits","isValidPartialNumber","isPlaceholder","shortened","slice","parsed","parse","kept","clearSegment","setSegment","movesFrom","erasOf","calendar","era","timeZone","year","eras","getEras","map","set","day","month","toDate","formatted","prefix","OS","get","blur","hidesEra","identifier","inputFocusedOf","inputOf","node","leftOf","confirmPlaceholder","editable","filter","findIndex","to","index","beyond","nameOf","nodeOf","delete","pressOf","relatedTargetOf","relatedTarget","SegmentLine","id","theme","own","role","words","valueOf","valueId","canEdit","T0","isEditable","textDisabled","textMuted","focused","describes","webPropsOf","webStateOf","maxValue","minValue","valueTextOf","empty","segmentFocused","textStyleOf","stepBy","by","ReturnType","textFocused","typeInto","key","startsWith","typed","number","Number","isNaN","over","am","pm","matched","written","formatValue","maxGranularity","selectedTime","selectedDate","dateFormatter","resolvedOptions","format","dateValue","step","erase","keys","isRTL","values","some","onKeyDown","altKey","ctrlKey","metaKey","handler","preventDefault","isRequired","_c","NativeText"],"sources":["../../src/segments/index.tsx"],"sourcesContent":["import type { Calendar } from '@internationalized/date'\nimport type {\n ComponentRef,\n Dispatch,\n Ref,\n RefObject,\n SetStateAction,\n} from 'react'\nimport type {\n AccessibilityActionEvent,\n AccessibilityActionInfo,\n HostInstance,\n PressableProps,\n StyleProp,\n TextStyle,\n ViewStyle,\n} from 'react-native'\nimport type {\n DateFieldState,\n DateSegment,\n DateSegmentType,\n} from 'react-stately/useDateFieldState'\n\nimport {\n CalendarDate,\n DateFormatter,\n toCalendar,\n} from '@internationalized/date'\nimport {\n useEffect,\n useEffectEvent,\n useId,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react'\nimport {\n I18nManager,\n Text as NativeText,\n Platform,\n Pressable,\n StyleSheet,\n TextInput,\n} from 'react-native'\n\nimport type { FieldDescriptionPart } from '../field'\nimport type { Focusable } from '../form'\nimport type { LibraryMessages } from '../i18n/messages'\n\nimport { startsWithIn } from '../autocomplete'\nimport { descriptionOf, FieldSegments } from '../field'\nimport { messagesFor } from '../i18n'\nimport { NumberParser } from '../number/parser'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { segmentStylesOf } from './styles'\n\n// The segments a date or a time is typed into, one part of the value each, as\n// web's src/segments draws them. React Stately's date field state decides\n// what the parts are, how many, in what order and what each may hold, from\n// the locale and the granularity, so a field built on it draws them from that\n// state rather than writing any of them out. What is here is how a person\n// types into them and how a screen reader reads them, which is React Aria's\n// useDateSegment ported, since React Aria does not run on native.\n//\n// **Typing is React Aria's, digit for digit.** A digit goes into the segment\n// after the ones typed before it, and moves on to the next segment once no\n// further digit could fit, so `9` in a month moves on and `1` waits for a\n// second. A letter picks a day period or an era by the start of its name in\n// the locale, backspace takes a digit off the end, and on an empty segment\n// moves back to the one before it.\n//\n// **On iOS and Android one hidden input takes the keys.** A view cannot raise\n// the keyboard, so a press on a segment makes it the one being typed and\n// focuses a text input no one sees or reads, which holds one space and hands\n// over each key typed after it. Its keyboard is a number pad for a segment of\n// digits and the full one for a day period or an era. A screen reader reaches\n// each segment as an adjustable element instead, which a swipe steps up or\n// down, and which opens the keyboard when activated.\n//\n// **Under React Native Web each segment is its own focus stop**, as web's\n// are, read as a spin button and typed into with the keys a browser hands\n// it: digits and letters, backspace, the arrow keys up and down to step, and\n// left and right to move between segments, which follow the direction the\n// page reads in.\n//\n// **A drawing of their own replaces a field's line**, for segments that are\n// not a field's: a box per part, the text inside it and the punctuation\n// between them, each the caller's, as a time picker's modal draws its hour\n// and minute. It names the parts it draws, and focus passes the others by,\n// so a day period a selector beside the boxes stands for is never typed into.\n// Punctuation is drawn only where it holds something to see, since a\n// locale's literals carry bidirectional marks and spaces beside it.\n\ntype DateSegmentsProps = {\n /** What describes the field after the value it holds: the line under it. */\n readonly described: readonly FieldDescriptionPart[]\n /** How the segments are drawn where they are not a field's line. */\n readonly drawing?: SegmentDrawing\n /**\n * What the segments are read as holding, after their own names: the date\n * or the time written out, unless a range picker around them reads its\n * whole range here instead. `''` reads nothing.\n */\n readonly holding?: string\n /** Whether the field shows an error, which every segment then says. */\n readonly isInvalid: boolean\n /** The field's label, which each segment's name ends in. */\n readonly label: string\n /** The locale the field writes in: its `useLocaleOf`. */\n readonly locale: string\n /**\n * Called with the segment in focus as it changes, and with `null` as focus\n * leaves them.\n */\n readonly onActiveChange?: (type: DateSegmentType | null) => void\n /**\n * Called where focus would move back from the first segment, as a\n * backspace on it does, which a range picker sends on to the start's last.\n */\n readonly onBeforeStart?: () => void\n /** Called as focus leaves the segments, once they fill in what they can. */\n readonly onBlur?: () => void\n /** Called after each edit a person makes, typed or stepped. */\n readonly onEdit?: () => void\n /** Called as focus arrives in the segments from outside them. */\n readonly onFocus?: () => void\n /**\n * Called where focus would move on from the last segment, as a full one\n * does, which a range picker sends on to the end's first.\n */\n readonly onPastEnd?: () => void\n /** What focuses the segments: the first, or the last. */\n readonly ref?: Ref<SegmentsHandle>\n readonly state: DateFieldState\n}\n\n// What moving focus to a segment reaches for.\ntype Focusing = Pick<\n SegmentLineProps,\n 'entered' | 'input' | 'nodes' | 'setActive' | 'state'\n>\n\ntype Moves = {\n // Where focus goes from a segment that stops being drawn, as React Aria's\n // goes from one it removes: the one before it, or the one after it where it\n // was the first.\n readonly away: () => void\n readonly next: () => void\n readonly previous: () => void\n}\n\n/**\n * How segments are drawn in place of a field's line of body large text, each\n * style chosen for whether its part is the one in focus.\n */\ntype SegmentDrawing = {\n /** The box a part a person types into is drawn in. */\n readonly box: (\n type: DateSegmentType,\n isActive: boolean,\n ) => StyleProp<ViewStyle>\n /** The punctuation between two parts. */\n readonly literal: StyleProp<TextStyle>\n /** The parts drawn. The rest are left out, and focus passes them by. */\n readonly parts: ReadonlySet<DateSegmentType>\n /**\n * Whether a press on a part raises the keyboard on iOS and Android, as a\n * field's does, rather than only making it the one in focus.\n */\n readonly raisesKeyboard: boolean\n /** The text inside a part's box. */\n readonly text: (\n type: DateSegmentType,\n isActive: boolean,\n ) => StyleProp<TextStyle>\n}\n\n// The segments' own props, with what the component around them keeps for\n// them: which one is being typed, what has been typed into it, whether focus\n// is among them, the hidden input and each segment's element.\ntype SegmentLineProps = Omit<DateSegmentsProps, 'ref'> & {\n readonly active: DateSegmentType | null\n readonly entered: RefObject<string>\n readonly input: RefObject<ComponentRef<typeof TextInput> | null>\n readonly inside: RefObject<boolean>\n readonly nodes: RefObject<Map<DateSegmentType, HostInstance>>\n readonly setActive: Dispatch<SetStateAction<DateSegmentType | null>>\n}\n\n/**\n * What focuses a field's segments: `focus` the first, unless focus is among\n * them already, `focusLast` the last, and `focusOn` the one of `type`, with\n * the keyboard raised on iOS and Android or put away.\n */\ntype SegmentsHandle = Focusable & {\n readonly focusLast: () => void\n readonly focusOn: (type: DateSegmentType, keyboard: boolean) => void\n}\n\n// A step a spin button takes, each one a method of the field's state.\ntype Step =\n | 'decrement'\n | 'decrementPage'\n | 'decrementToMin'\n | 'increment'\n | 'incrementPage'\n | 'incrementToMax'\n\n// What a segment is handed under React Native Web, which takes keys and focus\n// on any element.\ntype WebSegmentProps = Pick<PressableProps, 'onBlur' | 'onFocus' | 'onKeyDown'>\n\n// What a screen reader can ask of a segment: a step up, or a step down.\nconst ADJUSTABLE: readonly AccessibilityActionInfo[] = [\n { name: 'increment' },\n { name: 'decrement' },\n]\n\n// What a literal holds besides what it is drawn for: the spaces, and the\n// marks a locale sets a direction with.\nconst INVISIBLE = /[\\s\\u061C\\u200E\\u200F\\u202A-\\u202E\\u2066-\\u2069]/gu\n\n// The text the hidden input holds, which a backspace has something to take\n// from and which every key typed lands after.\nconst SENTINEL = ' '\n\n// Where the hidden input's caret stays: after the space.\nconst AFTER_SENTINEL = { end: SENTINEL.length, start: SENTINEL.length }\n\n// The segments a number is typed into, which the number pad serves.\nconst NUMERIC = new Set<DateSegmentType>([\n 'day',\n 'hour',\n 'minute',\n 'month',\n 'second',\n 'year',\n])\n\nconst styles = StyleSheet.create({\n // The input no one sees, which is there to raise the keyboard and take its\n // keys. Still laid out, since an input with no size takes no focus.\n input: {\n height: 1,\n opacity: 0,\n position: 'absolute',\n start: 0,\n top: 0,\n width: 1,\n },\n // The date written out, in the document under React Native Web for the\n // first segment to point at, and drawn nowhere.\n notDrawn: {\n display: 'none',\n },\n})\n\n// What a screen reader's swipe up or down does to a segment.\nfunction actionOf(line: SegmentLineProps, segment: DateSegment) {\n return (event: AccessibilityActionEvent) => {\n const { actionName } = event.nativeEvent\n if (actionName === 'increment' || actionName === 'decrement') {\n stepKey(line, segment, actionName)\n }\n }\n}\n\n// Where focus goes once a person is in the segments: what the field calls on\n// arriving, which it hears once however many segments focus passes through.\nfunction arrivedIn({ inside, onFocus }: SegmentLineProps) {\n if (!inside.current) {\n inside.current = true\n onFocus?.()\n }\n}\n\n// What the hidden input does with each change to its text: a shorter text is\n// a backspace, and a longer one a key typed after the space.\nfunction changedOf(line: SegmentLineProps) {\n return (text: string) => {\n const segment = line.state.segments.find(\n (each) => each.type === line.active,\n )\n\n if (segment === undefined) {\n return\n }\n\n if (text.length < SENTINEL.length) {\n eraseKey(line, segment)\n return\n }\n\n // One key at a time, the first typed after the space: a second handed\n // over in the same change would be written over by the first, since\n // both are set from the value this render holds.\n const point = text.replace(SENTINEL, '').codePointAt(0)\n\n if (point !== undefined) {\n typeKey(line, segment, String.fromCodePoint(point))\n }\n }\n}\n\n// The number of characters at the start of every one of `texts` that they\n// share, which an era's name is typed after, as React Aria finds it.\nfunction commonPrefixLength(texts: readonly string[]) {\n const sorted = texts.toSorted()\n const first = sorted.at(0) ?? ''\n const last = sorted.at(-1) ?? ''\n let length = 0\n\n while (length < first.length && first[length] === last[length]) {\n length++\n }\n\n return length\n}\n\n/**\n * A date or a time's segments, inside a field's box, from React Stately's\n * date field state: each part of the value typed or stepped on its own, the\n * one being typed drawn as a filled shape and the empty ones in their\n * placeholders, muted.\n */\nfunction DateSegments({ onActiveChange, ref, ...props }: DateSegmentsProps) {\n const [active, setActive] = useState<DateSegmentType | null>(null)\n // What has been typed into the segment in focus since it took focus, which\n // the next digit is read after.\n const entered = useRef('')\n // Whether focus is in the segments, which a press on the box around them\n // leaves where it is.\n const inside = useRef(false)\n const input = useRef<ComponentRef<typeof TextInput>>(null)\n // Each segment's element under React Native Web, which focus moves to.\n const nodes = useRef(new Map<DateSegmentType, HostInstance>())\n const { drawing, state } = props\n const reportActive = useEffectEvent((type: DateSegmentType | null) => {\n onActiveChange?.(type)\n })\n\n useEffect(() => {\n reportActive(active)\n }, [active])\n\n useImperativeHandle(ref, () => ({\n focus: () => {\n const first = state.segments.find((segment) =>\n typedInto(drawing, segment),\n )\n if (!inside.current && first !== undefined) {\n focusTo({ entered, input, nodes, setActive, state }, first.type)\n }\n },\n focusLast: () => {\n const last = state.segments.findLast((segment) =>\n typedInto(drawing, segment),\n )\n if (last !== undefined) {\n focusTo({ entered, input, nodes, setActive, state }, last.type)\n }\n },\n focusOn: (type, keyboard) => {\n focusTo({ entered, input, nodes, setActive, state }, type, keyboard)\n },\n }))\n\n return (\n <SegmentLine\n {...props}\n active={active}\n entered={entered}\n input={input}\n inside={inside}\n nodes={nodes}\n setActive={setActive}\n />\n )\n}\n\n// What the locale calls the morning and the afternoon, which a key picks\n// between by the start of each.\nfunction dayPeriodsOf(locale: string): readonly [string, string] {\n const formatter = new DateFormatter(locale, { hour: 'numeric', hour12: true })\n const periodAt = (hours: number) => {\n const date = new Date()\n date.setHours(hours)\n return (\n formatter.formatToParts(date).find((part) => part.type === 'dayPeriod')\n ?.value ?? ''\n )\n }\n\n return [periodAt(0), periodAt(12)]\n}\n\n// Whether a segment is drawn: every one on a field's line, and in a drawing\n// of its own the parts it names and the punctuation that holds something to\n// see.\nfunction drawn(drawing: SegmentDrawing | undefined, segment: DateSegment) {\n if (drawing === undefined) {\n return true\n }\n\n return segment.type === 'literal'\n ? segment.text.replaceAll(INVISIBLE, '') !== ''\n : drawing.parts.has(segment.type)\n}\n\nfunction edited({ onEdit }: SegmentLineProps, changed: boolean) {\n if (changed) {\n onEdit?.()\n }\n}\n\n// Takes a digit off the end of a segment, as backspace does in React Aria's,\n// and clears a day period or an era outright. On a segment already empty it\n// moves to the one before. Whether it changed the value.\nfunction eraseFrom(\n state: DateFieldState,\n segment: DateSegment,\n locale: string,\n entered: RefObject<string>,\n moves: Moves,\n): boolean {\n if (state.isDisabled || state.isReadOnly) {\n return false\n }\n\n if (segment.text === segment.placeholder) {\n moves.previous()\n }\n\n const parser = new NumberParser(locale, { maximumFractionDigits: 0 })\n\n if (parser.isValidPartialNumber(segment.text) && !segment.isPlaceholder) {\n const shortened = segment.text.slice(0, -1)\n const parsed = parser.parse(shortened)\n const kept = parsed === 0 ? '' : shortened\n\n if (kept === '') {\n state.clearSegment(segment.type)\n } else {\n state.setSegment(segment.type, parsed)\n }\n entered.current = kept\n return true\n }\n\n if (segment.type === 'dayPeriod' || segment.type === 'era') {\n state.clearSegment(segment.type)\n return true\n }\n\n return false\n}\n\nfunction eraseKey(line: SegmentLineProps, segment: DateSegment) {\n edited(\n line,\n eraseFrom(\n line.state,\n segment,\n line.locale,\n line.entered,\n movesFrom(line, segment.type),\n ),\n )\n}\n\n// The calendar's eras with the names a key picks them by: each era's name in\n// the locale, less what every name begins with, so a calendar whose eras are\n// ERA0 and ERA1 is typed with 0 and 1, as React Aria's is.\nfunction erasOf(calendar: Calendar, locale: string) {\n const formatter = new DateFormatter(locale, {\n era: 'narrow',\n timeZone: 'UTC',\n year: 'numeric',\n })\n const first = toCalendar(new CalendarDate(1, 1, 1), calendar)\n const eras = calendar.getEras().map((era) => {\n const date = first.set({ day: 1, era, month: 1, year: 1 }).toDate('UTC')\n\n return {\n era,\n // An era with no name in the locale is typed by its identifier.\n formatted:\n formatter.formatToParts(date).find((part) => part.type === 'era')\n ?.value ?? era,\n }\n })\n const prefix = commonPrefixLength(eras.map((era) => era.formatted))\n\n return eras.map(({ era, formatted }) => ({\n era,\n formatted: formatted.slice(prefix),\n }))\n}\n\n// Moves focus to the segment of `type`: the segment's own element under React\n// Native Web, and on iOS and Android the hidden input, with the segment made\n// the one it types into. A read-only field raises no keyboard, and nor does a\n// move that puts the keyboard away, which makes the segment the one in focus\n// and takes focus off the input.\nfunction focusTo(\n { entered, input, nodes, setActive, state }: Focusing,\n type: DateSegmentType,\n keyboard = true,\n) {\n entered.current = ''\n\n if (Platform.OS === 'web') {\n nodes.current.get(type)?.focus()\n return\n }\n\n if (!keyboard) {\n setActive(type)\n input.current?.blur()\n return\n }\n\n if (state.isReadOnly) {\n return\n }\n\n setActive(type)\n input.current?.focus()\n}\n\n// Whether setting the era to `era` stops the era segment being drawn, which\n// React Stately draws in a Gregorian calendar only while the date is BC.\nfunction hidesEra(state: DateFieldState, era: string) {\n return state.calendar.identifier === 'gregory' && era !== 'BC'\n}\n\n// What the hidden input does on taking focus: types into the segment it was\n// focused for, or the first where it was focused some other way.\nfunction inputFocusedOf(line: SegmentLineProps) {\n return () => {\n const first =\n line.state.segments.find((segment) => typedInto(line.drawing, segment))\n ?.type ?? null\n line.setActive((current) => current ?? first)\n arrivedIn(line)\n }\n}\n\n// Keeps the hidden input, which focus is moved to on iOS and Android.\nfunction inputOf({ input }: SegmentLineProps) {\n return (node: ComponentRef<typeof TextInput> | null) => {\n input.current = node\n }\n}\n\n// What focus leaving the segments does: fills in what the placeholder can,\n// as React Aria's field does on blur, then tells the field.\nfunction leftOf({\n entered,\n inside,\n onBlur,\n setActive,\n state,\n}: SegmentLineProps) {\n return () => {\n inside.current = false\n entered.current = ''\n setActive(null)\n state.confirmPlaceholder()\n onBlur?.()\n }\n}\n\n// The segments on either side of the one of `type`, among those a person\n// types into, which a full segment moves on to and a backspace back to. Past\n// either end it is the field's to say, as a range picker's focus moves on\n// from one date's segments to the other's.\nfunction movesFrom(line: SegmentLineProps, type: DateSegmentType): Moves {\n const editable = line.state.segments.filter((segment) =>\n typedInto(line.drawing, segment),\n )\n const at = editable.findIndex((segment) => segment.type === type)\n const to = (index: number, beyond?: () => void) => () => {\n const segment = index < 0 ? undefined : editable.at(index)\n if (segment === undefined) {\n beyond?.()\n } else {\n focusTo(line, segment.type)\n }\n }\n\n return {\n away: to(at > 0 ? at - 1 : at + 1),\n next: to(at + 1, line.onPastEnd),\n previous: to(at - 1, line.onBeforeStart),\n }\n}\n\n// The name a segment of `type` is read by. A literal is never read, and is\n// named as a day only to keep the lookup total.\nfunction nameOf(\n type: DateSegmentType,\n): keyof Omit<\n LibraryMessages['segments'],\n 'empty' | 'selectedDate' | 'selectedTime'\n> {\n return type === 'literal' ? 'day' : type\n}\n\n// Keeps each segment's element, which focus is moved to under React Native\n// Web, for as long as it is drawn.\nfunction nodeOf({ nodes }: SegmentLineProps, type: DateSegmentType) {\n return (node: HostInstance | null) => {\n if (node === null) {\n return undefined\n }\n\n nodes.current.set(type, node)\n return () => {\n nodes.current.delete(type)\n }\n }\n}\n\n// What a press on a segment does on iOS and Android: makes it the one typed\n// into, and raises the keyboard, unless the drawing says a press only makes\n// it the one in focus.\nfunction pressOf(line: SegmentLineProps, type: DateSegmentType) {\n return () => {\n focusTo(line, type, line.drawing?.raisesKeyboard ?? true)\n }\n}\n\n// The element focus moved to, off a browser's blur event.\nfunction relatedTargetOf(event: unknown): unknown {\n return typeof event === 'object' && event !== null && 'relatedTarget' in event\n ? event.relatedTarget\n : undefined\n}\n\n// The segments themselves, drawn from the field's state.\nfunction SegmentLine(line: SegmentLineProps) {\n const { active, described, drawing, isInvalid, label, locale, state } = line\n const id = useId()\n const theme = useTheme()\n const own = segmentStylesOf(theme)\n const role = useTypeRole('bodyLarge')\n const words = messagesFor(locale).segments\n const first = state.segments.find((segment) => typedInto(drawing, segment))\n const value = line.holding ?? valueOf(state, words)\n const valueId = `${id}-value`\n const parts =\n value === '' ? described : [{ id: valueId, text: value }, ...described]\n const canEdit = !state.isDisabled && !state.isReadOnly\n\n return (\n <FieldSegments>\n {state.segments.map((segment, index) => {\n if (!drawn(drawing, segment)) {\n return null\n }\n\n if (!segment.isEditable) {\n return (\n <NativeText\n aria-hidden={segment.type === 'literal'}\n // A segment's place is its key, and a literal's its index, since\n // a locale can put the same punctuation between several.\n // oxlint-disable-next-line react/no-array-index-key -- see above\n key={`${segment.type}-${index}`}\n style={\n drawing === undefined\n ? composeStyles<TextStyle>(\n role,\n segment.type === 'literal' ? undefined : own.segment,\n state.isDisabled\n ? own.textDisabled\n : segment.type === 'literal'\n ? own.textMuted\n : own.text,\n )\n : drawing.literal\n }\n >\n {segment.text}\n </NativeText>\n )\n }\n\n const focused = segment.type === active\n // The field's description is said on the first segment alone, so it\n // is not heard again at every step, unless the field has an error.\n const describes = isInvalid || segment.type === first?.type\n\n return (\n <Pressable\n {...(Platform.OS === 'web' ? webPropsOf(line, segment) : undefined)}\n {...(describes ? descriptionOf(parts) : undefined)}\n {...webStateOf(isInvalid, state)}\n accessibilityActions={canEdit ? ADJUSTABLE : undefined}\n accessibilityRole={Platform.OS === 'web' ? undefined : 'adjustable'}\n aria-disabled={state.isDisabled}\n aria-label={`${words[nameOf(segment.type)]}, ${label}`}\n aria-valuemax={segment.maxValue}\n aria-valuemin={segment.minValue}\n aria-valuenow={segment.value ?? undefined}\n aria-valuetext={valueTextOf(segment, state, locale, words.empty)}\n disabled={state.isDisabled}\n key={segment.type}\n onAccessibilityAction={actionOf(line, segment)}\n onPress={\n Platform.OS === 'web' ? undefined : pressOf(line, segment.type)\n }\n ref={nodeOf(line, segment.type)}\n role={Platform.OS === 'web' ? 'spinbutton' : undefined}\n style={\n drawing === undefined\n ? composeStyles<ViewStyle>(\n own.segment,\n focused ? own.segmentFocused : undefined,\n )\n : drawing.box(segment.type, focused)\n }\n >\n <NativeText\n style={\n drawing === undefined\n ? composeStyles<TextStyle>(\n role,\n textStyleOf(own, segment, focused, state.isDisabled),\n )\n : drawing.text(segment.type, focused)\n }\n >\n {segment.text}\n </NativeText>\n </Pressable>\n )\n })}\n {Platform.OS === 'web' ? (\n value === '' ? null : (\n <NativeText id={valueId} style={styles.notDrawn}>\n {value}\n </NativeText>\n )\n ) : (\n <TextInput\n aria-hidden\n autoCapitalize=\"none\"\n autoComplete=\"off\"\n autoCorrect={false}\n caretHidden\n contextMenuHidden\n editable={canEdit}\n importantForAutofill=\"no\"\n keyboardType={\n active === null || NUMERIC.has(active) ? 'number-pad' : 'default'\n }\n onBlur={leftOf(line)}\n onChangeText={changedOf(line)}\n onFocus={inputFocusedOf(line)}\n ref={inputOf(line)}\n selection={AFTER_SENTINEL}\n spellCheck={false}\n style={styles.input}\n value={SENTINEL}\n />\n )}\n </FieldSegments>\n )\n}\n\n// Steps a segment, as an arrow key or a swipe does, which starts what is\n// typed into it again. Whether it changed the value.\nfunction stepBy(\n state: DateFieldState,\n segment: DateSegment,\n by: Step,\n entered: RefObject<string>,\n): boolean {\n if (state.isDisabled || state.isReadOnly) {\n return false\n }\n\n entered.current = ''\n state[by](segment.type)\n return true\n}\n\nfunction stepKey(line: SegmentLineProps, segment: DateSegment, by: Step) {\n const changed = stepBy(line.state, segment, by, line.entered)\n\n // A Gregorian era is drawn only while it is BC, so a step, which can only\n // take it to AD, takes the segment away, and focus with it where it is the\n // segment in focus. A screen reader's swipe moves no focus of ours, and\n // raises no keyboard.\n if (\n changed &&\n segment.type === 'era' &&\n line.active === 'era' &&\n hidesEra(line.state, 'AD')\n ) {\n movesFrom(line, 'era').away()\n }\n edited(line, changed)\n}\n\nfunction textStyleOf(\n own: ReturnType<typeof segmentStylesOf>,\n segment: DateSegment,\n focused: boolean,\n isDisabled: boolean,\n) {\n if (isDisabled) {\n return own.textDisabled\n }\n\n if (focused) {\n return own.textFocused\n }\n\n return segment.isPlaceholder ? own.textMuted : own.text\n}\n\n// Whether a person types into `segment`: one they can edit, which the\n// drawing, where there is one, draws.\nfunction typedInto(drawing: SegmentDrawing | undefined, segment: DateSegment) {\n return segment.isEditable && drawn(drawing, segment)\n}\n\n// Types `key` into a segment, as React Aria's segment takes a key typed into\n// it, and moves on once the segment can take no more. Whether it changed the\n// value.\nfunction typeInto(\n state: DateFieldState,\n segment: DateSegment,\n key: string,\n locale: string,\n entered: RefObject<string>,\n moves: Moves,\n): boolean {\n if (state.isDisabled || state.isReadOnly) {\n return false\n }\n\n const startsWith = startsWithIn(locale)\n\n switch (segment.type) {\n case 'day':\n case 'hour':\n case 'minute':\n case 'month':\n case 'second':\n case 'year': {\n const parser = new NumberParser(locale, { maximumFractionDigits: 0 })\n const typed = entered.current + key\n\n if (!parser.isValidPartialNumber(typed)) {\n return false\n }\n\n const number = parser.parse(typed)\n\n if (Number.isNaN(number)) {\n return false\n }\n\n const { maxValue } = segment\n const over = maxValue !== undefined && number > maxValue\n\n // A number past the segment's largest starts again from the key alone,\n // so 13 in a month is a 3.\n state.setSegment(segment.type, over ? parser.parse(key) : number)\n\n if (\n maxValue !== undefined &&\n (Number(`${number}0`) > maxValue ||\n typed.length >= String(maxValue).length)\n ) {\n entered.current = ''\n moves.next()\n } else {\n entered.current = typed\n }\n return true\n }\n case 'dayPeriod': {\n const [am, pm] = dayPeriodsOf(locale)\n\n if (startsWith(am, key)) {\n state.setSegment('dayPeriod', 0)\n } else if (startsWith(pm, key)) {\n state.setSegment('dayPeriod', 1)\n } else {\n return false\n }\n moves.next()\n return true\n }\n case 'era': {\n const matched = erasOf(state.calendar, locale).find((era) =>\n startsWith(era.formatted, key),\n )\n\n if (matched === undefined) {\n return false\n }\n state.setSegment('era', matched.era)\n\n if (hidesEra(state, matched.era)) {\n moves.away()\n } else {\n moves.next()\n }\n return true\n }\n case 'literal':\n case 'timeZoneName': {\n break\n }\n }\n\n // A literal and a time zone are written by the locale and the value, and\n // nothing typed reaches them.\n return false\n}\n\nfunction typeKey(line: SegmentLineProps, segment: DateSegment, key: string) {\n edited(\n line,\n typeInto(\n line.state,\n segment,\n key,\n line.locale,\n line.entered,\n movesFrom(line, segment.type),\n ),\n )\n}\n\n// The date or the time a field holds, written out, which describes the\n// field after its segments, as React Aria describes it. Nothing while the\n// field is empty.\nfunction valueOf(state: DateFieldState, words: LibraryMessages['segments']) {\n if (state.value === null) {\n return ''\n }\n\n const written = state.formatValue({ month: 'long' })\n\n return state.maxGranularity === 'hour'\n ? words.selectedTime.replace('{time}', written)\n : words.selectedDate.replace('{date}', written)\n}\n\n// What a segment's value reads as, as React Aria writes it: a month with its\n// name beside its number, an hour with its day period, and an empty segment\n// as empty.\nfunction valueTextOf(\n segment: DateSegment,\n state: DateFieldState,\n locale: string,\n empty: string,\n) {\n if (segment.isPlaceholder) {\n return empty\n }\n\n const { hour12, timeZone } = state.dateFormatter.resolvedOptions()\n\n if (segment.type === 'month') {\n const month = new DateFormatter(locale, { month: 'long', timeZone }).format(\n state.dateValue,\n )\n return month === segment.text ? month : `${segment.text} – ${month}`\n }\n\n if (segment.type === 'hour') {\n return new DateFormatter(locale, {\n hour: 'numeric',\n hour12,\n timeZone,\n }).format(state.dateValue)\n }\n\n return segment.text\n}\n\n// What a segment takes under React Native Web: focus, and the keys a browser\n// hands it.\nfunction webPropsOf(\n line: SegmentLineProps,\n segment: DateSegment,\n): WebSegmentProps {\n const moves = movesFrom(line, segment.type)\n const step = (by: Step) => () => {\n stepKey(line, segment, by)\n }\n const erase = () => {\n eraseKey(line, segment)\n }\n // The arrow keys move along the line as it reads, so left is the next\n // segment in a right-to-left page.\n const keys = new Map<string, () => void>([\n ['ArrowDown', step('decrement')],\n ['ArrowLeft', I18nManager.isRTL ? moves.next : moves.previous],\n ['ArrowRight', I18nManager.isRTL ? moves.previous : moves.next],\n ['ArrowUp', step('increment')],\n ['Backspace', erase],\n ['Delete', erase],\n ['End', step('incrementToMax')],\n ['Home', step('decrementToMin')],\n ['PageDown', step('decrementPage')],\n ['PageUp', step('incrementPage')],\n ])\n\n return {\n // Focus moving to another segment stays in the field, and only focus\n // leaving the segments altogether is the field's blur.\n onBlur: (event) => {\n const to = relatedTargetOf(event.nativeEvent)\n if (![...line.nodes.current.values()].some((node) => node === to)) {\n leftOf(line)()\n }\n },\n onFocus: () => {\n line.entered.current = ''\n line.setActive(segment.type)\n arrivedIn(line)\n },\n onKeyDown: (event) => {\n const { altKey, ctrlKey, key, metaKey } = event.nativeEvent\n const handler = keys.get(key)\n\n if (handler !== undefined) {\n event.preventDefault()\n handler()\n return\n }\n\n // A key that types one character, rather than one held with a key that\n // makes it a shortcut, is typed into the segment.\n const point = key.codePointAt(0)\n\n if (\n point !== undefined &&\n String.fromCodePoint(point) === key &&\n !altKey &&\n !ctrlKey &&\n !metaKey\n ) {\n event.preventDefault()\n typeKey(line, segment, key)\n }\n },\n }\n}\n\n// What a browser reads off a segment that React Native has no prop for.\nfunction webStateOf(isInvalid: boolean, state: DateFieldState) {\n if (Platform.OS !== 'web') {\n return undefined\n }\n\n return {\n ...(isInvalid ? { 'aria-invalid': true } : undefined),\n ...(state.isReadOnly ? { 'aria-readonly': true } : undefined),\n ...(state.isRequired ? { 'aria-required': true } : undefined),\n }\n}\n\nexport { DateSegments }\nexport type { DateSegmentsProps, SegmentDrawing, SegmentsHandle }\n"],"mappings":";;;;;;;;;;;;;;AAuNA,MAAMyF,aAAiD,CACrD,EAAEC,MAAM,YAAY,GACpB,EAAEA,MAAM,YAAY,CAAC;AAKvB,MAAMC,YAAY;AAIlB,MAAMC,WAAW;AAGjB,MAAMC,iBAAiB;CAAEC,KAAKF;CAAiBI,OAAOJ;AAAgB;AAGtE,MAAMK,0BAAU,IAAIC,IAAqB;CACvC;CACA;CACA;CACA;CACA;CACA;AAAM,CACP;AAED,MAAMC,SAASrE,WAAWsE,OAAO;CAG/BrB,OAAO;EACLsB,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVP,OAAO;EACPQ,KAAK;EACLC,OAAO;CACT;CAGAC,UAAU,EACRC,SAAS,OACX;AACF,CAAC;AAGD,SAASC,SAASC,MAAwBC,SAAsB;CAC9D,QAAQC,UAAoC;EAC1C,MAAM,EAAEC,eAAeD,MA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;GAE5B,IAAI6B,YAAYlK,KAAAA,GAAW;IACzBV,MAAM6K,eAAe;IACrBD,QAAQ;IACR;GACF;GAIA,MAAMhK,QAAQmI,IAAIjI,YAAY,CAAC;GAE/B,IACEF,UAAUF,KAAAA,KACVM,OAAOC,cAAcL,KAAK,MAAMmI,OAChC,CAAC0B,UACD,CAACC,WACD,CAACC,SACD;IACA3K,MAAM6K,eAAe;IACrB9J,QAAQjB,MAAMC,SAASgJ,GAAG;GAC5B;EACF;CACF;AACF;AAGA,SAASZ,WAAWjM,WAAoBY,OAAuB;CAC7D,IAAIjC,SAASgL,OAAO,OAClB;CAGF,OAAO;EACL,GAAI3J,YAAY,EAAE,gBAAgB,KAAK,IAAIwE,KAAAA;EAC3C,GAAI5D,MAAMmH,aAAa,EAAE,iBAAiB,KAAK,IAAIvD,KAAAA;EACnD,GAAI5D,MAAMgO,aAAa,EAAE,iBAAiB,KAAK,IAAIpK,KAAAA;CACrD;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { themedStyles } from "../theme/styles.js";
|
|
2
|
+
import { withOpacity } from "../theme/color.js";
|
|
3
|
+
import { Platform, StyleSheet } from "react-native";
|
|
4
|
+
//#region src/segments/styles.ts
|
|
5
|
+
const segmentStylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) => StyleSheet.create({
|
|
6
|
+
segment: {
|
|
7
|
+
borderRadius: radii.xs,
|
|
8
|
+
paddingHorizontal: spacing.xxs,
|
|
9
|
+
...Platform.OS === "web" ? {
|
|
10
|
+
outlineStyle: "solid",
|
|
11
|
+
outlineWidth: 0
|
|
12
|
+
} : void 0
|
|
13
|
+
},
|
|
14
|
+
segmentFocused: { backgroundColor: colors.primary },
|
|
15
|
+
separator: { marginHorizontal: spacing.sm },
|
|
16
|
+
text: { color: colors.onSurface },
|
|
17
|
+
textDisabled: { color: withOpacity(colors.onSurface, stateLayerOpacity.disabledContent) },
|
|
18
|
+
textFocused: { color: colors.onPrimary },
|
|
19
|
+
textMuted: { color: colors.onSurfaceVariant }
|
|
20
|
+
}));
|
|
21
|
+
//#endregion
|
|
22
|
+
export { segmentStylesOf };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","names":["Platform","StyleSheet","withOpacity","themedStyles","segmentStylesOf","colors","radii","spacing","stateLayerOpacity","create","segment","borderRadius","xs","paddingHorizontal","xxs","OS","outlineStyle","outlineWidth","undefined","segmentFocused","backgroundColor","primary","separator","marginHorizontal","sm","text","color","onSurface","textDisabled","disabledContent","textFocused","onPrimary","textMuted","onSurfaceVariant"],"sources":["../../src/segments/styles.ts"],"sourcesContent":["import { Platform, StyleSheet } from 'react-native'\n\nimport { withOpacity } from '../theme/color'\nimport { themedStyles } from '../theme/styles'\n\n// The segments a date or a time is typed into, apart from the fields drawing\n// them so the two cannot drift, as web keeps them in its own src/segments.\n\nconst segmentStylesOf = themedStyles(\n ({ colors, radii, spacing, stateLayerOpacity }) =>\n StyleSheet.create({\n // One segment, its own place to type. The filled shape below is its\n // focus, so a browser's own ring would be a second treatment for one\n // focus: solid and no width, as a field's control draws it.\n segment: {\n borderRadius: radii.xs,\n paddingHorizontal: spacing.xxs,\n ...(Platform.OS === 'web'\n ? { outlineStyle: 'solid', outlineWidth: 0 }\n : undefined),\n },\n // The one being typed. The caret is hidden, so the segment is what says\n // which of them has focus, and it says so the way a selected row does.\n segmentFocused: {\n backgroundColor: colors.primary,\n },\n // The dash between a range's two dates, with the gap web's picker\n // keeps either side of it.\n separator: {\n marginHorizontal: spacing.sm,\n },\n // A segment holding a value, and the time zone a field shows after its\n // time, which is part of the value rather than punctuation.\n text: {\n color: colors.onSurface,\n },\n // Faded with the rest of the field, literals included, at the opacity\n // every disabled control here takes.\n textDisabled: {\n color: withOpacity(colors.onSurface, stateLayerOpacity.disabledContent),\n },\n textFocused: {\n color: colors.onPrimary,\n },\n // A segment with nothing in it yet, showing its own placeholder, and a\n // literal, the slash or the colon the locale puts between two segments,\n // both of which a half-typed date reads past.\n textMuted: {\n color: colors.onSurfaceVariant,\n },\n }),\n)\n\nexport { segmentStylesOf }\n"],"mappings":";;;;AAQA,MAAMI,kBAAkBD,cACrB,EAAEE,QAAQC,OAAOC,SAASC,wBACzBP,WAAWQ,OAAO;CAIhBC,SAAS;EACPC,cAAcL,MAAMM;EACpBC,mBAAmBN,QAAQO;EAC3B,GAAId,SAASe,OAAO,QAChB;GAAEC,cAAc;GAASC,cAAc;EAAE,IACzCC,KAAAA;CACN;CAGAC,gBAAgB,EACdC,iBAAiBf,OAAOgB,QAC1B;CAGAC,WAAW,EACTC,kBAAkBhB,QAAQiB,GAC5B;CAGAC,MAAM,EACJC,OAAOrB,OAAOsB,UAChB;CAGAC,cAAc,EACZF,OAAOxB,YAAYG,OAAOsB,WAAWnB,kBAAkBqB,eAAe,EACxE;CACAC,aAAa,EACXJ,OAAOrB,OAAO0B,UAChB;CAIAC,WAAW,EACTN,OAAOrB,OAAO4B,iBAChB;AACF,CAAC,CACL"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { I18nManager, StyleSheet } from "react-native";
|
|
3
|
+
import { useSharedValue } from "react-native-reanimated";
|
|
4
|
+
import { Gesture } from "react-native-gesture-handler";
|
|
5
|
+
//#region src/slider/index.ts
|
|
6
|
+
const SLOP = 10;
|
|
7
|
+
const SLOP_RANGE = [-10, SLOP];
|
|
8
|
+
const TARGET = 48;
|
|
9
|
+
const ADJUSTABLE = [{ name: "increment" }, { name: "decrement" }];
|
|
10
|
+
const seats = StyleSheet.create({
|
|
11
|
+
seat: {
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
bottom: 0,
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
marginStart: -24,
|
|
16
|
+
position: "absolute",
|
|
17
|
+
top: 0,
|
|
18
|
+
width: TARGET
|
|
19
|
+
},
|
|
20
|
+
seatVertical: {
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
end: 0,
|
|
23
|
+
height: TARGET,
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
marginBottom: -24,
|
|
26
|
+
position: "absolute",
|
|
27
|
+
start: 0
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
function adjustOf(state, index) {
|
|
31
|
+
return (event) => {
|
|
32
|
+
const { actionName } = event.nativeEvent;
|
|
33
|
+
if (actionName !== "increment" && actionName !== "decrement") return;
|
|
34
|
+
state.setThumbDragging(index, true);
|
|
35
|
+
if (actionName === "increment") state.incrementThumb(index);
|
|
36
|
+
else state.decrementThumb(index);
|
|
37
|
+
state.setThumbDragging(index, false);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function closestThumb(values, value) {
|
|
41
|
+
const split = values.findIndex((each) => value - each < 0);
|
|
42
|
+
if (split === 0) return 0;
|
|
43
|
+
if (split === -1) return values.length - 1;
|
|
44
|
+
const lastBefore = values[split - 1] ?? value;
|
|
45
|
+
const firstPast = values[split] ?? value;
|
|
46
|
+
return Math.abs(lastBefore - value) < Math.abs(firstPast - value) ? split - 1 : split;
|
|
47
|
+
}
|
|
48
|
+
function lengthTo(set, vertical) {
|
|
49
|
+
return ({ nativeEvent }) => {
|
|
50
|
+
set(vertical ? nativeEvent.layout.height : nativeEvent.layout.width);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function percentOf(fraction) {
|
|
54
|
+
return `${fraction * 100}%`;
|
|
55
|
+
}
|
|
56
|
+
function seatPlaceOf(fraction, vertical) {
|
|
57
|
+
return vertical ? { bottom: percentOf(fraction) } : { start: percentOf(fraction) };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The track's pan and tap. Each reads a press's place as a fraction of the
|
|
61
|
+
* track, from the start or, vertical, from the bottom, and moves the handle
|
|
62
|
+
* nearest it there. The pan holds that handle as dragged until it lets go,
|
|
63
|
+
* which is what brings up its indicator and narrows it, and what
|
|
64
|
+
* `onChangeEnd` waits for; the tap moves it and lets it go at once.
|
|
65
|
+
*
|
|
66
|
+
* Both run on the JavaScript thread, since every move sets React state.
|
|
67
|
+
*/
|
|
68
|
+
function useTrackGesture(t0) {
|
|
69
|
+
const $ = c(8);
|
|
70
|
+
const { isDisabled, length, state, testID, vertical } = t0;
|
|
71
|
+
const dragged = useSharedValue(-1);
|
|
72
|
+
let t1;
|
|
73
|
+
if ($[0] !== length || $[1] !== vertical) {
|
|
74
|
+
t1 = function fractionAt(x, y) {
|
|
75
|
+
if (length <= 0) return null;
|
|
76
|
+
const along = (vertical ? y : x) / length;
|
|
77
|
+
if (vertical) return 1 - along;
|
|
78
|
+
return I18nManager.isRTL ? 1 - along : along;
|
|
79
|
+
};
|
|
80
|
+
$[0] = length;
|
|
81
|
+
$[1] = vertical;
|
|
82
|
+
$[2] = t1;
|
|
83
|
+
} else t1 = $[2];
|
|
84
|
+
const fractionAt = t1;
|
|
85
|
+
const grab = function grab(x_0, y_0) {
|
|
86
|
+
const fraction = fractionAt(x_0, y_0);
|
|
87
|
+
if (fraction === null) return;
|
|
88
|
+
const index = closestThumb(state.values, state.getPercentValue(fraction));
|
|
89
|
+
dragged.set(index);
|
|
90
|
+
state.setThumbDragging(index, true);
|
|
91
|
+
state.setThumbPercent(index, fraction);
|
|
92
|
+
};
|
|
93
|
+
const move = function move(x_1, y_1) {
|
|
94
|
+
const index_0 = dragged.get();
|
|
95
|
+
const fraction_0 = fractionAt(x_1, y_1);
|
|
96
|
+
if (index_0 >= 0 && fraction_0 !== null) state.setThumbPercent(index_0, fraction_0);
|
|
97
|
+
};
|
|
98
|
+
const release = function release() {
|
|
99
|
+
const index_1 = dragged.get();
|
|
100
|
+
if (index_1 >= 0) {
|
|
101
|
+
dragged.set(-1);
|
|
102
|
+
state.setThumbDragging(index_1, false);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
let t2;
|
|
106
|
+
if ($[3] !== fractionAt || $[4] !== state) {
|
|
107
|
+
t2 = function jump(x_2, y_2) {
|
|
108
|
+
const fraction_1 = fractionAt(x_2, y_2);
|
|
109
|
+
if (fraction_1 === null) return;
|
|
110
|
+
const index_2 = closestThumb(state.values, state.getPercentValue(fraction_1));
|
|
111
|
+
state.setThumbDragging(index_2, true);
|
|
112
|
+
state.setThumbPercent(index_2, fraction_1);
|
|
113
|
+
state.setThumbDragging(index_2, false);
|
|
114
|
+
};
|
|
115
|
+
$[3] = fractionAt;
|
|
116
|
+
$[4] = state;
|
|
117
|
+
$[5] = t2;
|
|
118
|
+
} else t2 = $[5];
|
|
119
|
+
const jump = t2;
|
|
120
|
+
const drag = Gesture.Pan();
|
|
121
|
+
const pan = (vertical ? drag.activeOffsetY(SLOP_RANGE).failOffsetX(SLOP_RANGE) : drag.activeOffsetX(SLOP_RANGE).failOffsetY(SLOP_RANGE)).enabled(!isDisabled).runOnJS(true).onStart((t3) => {
|
|
122
|
+
const { x: x_3, y: y_3 } = t3;
|
|
123
|
+
grab(x_3, y_3);
|
|
124
|
+
}).onUpdate((t4) => {
|
|
125
|
+
const { x: x_4, y: y_4 } = t4;
|
|
126
|
+
move(x_4, y_4);
|
|
127
|
+
}).onFinalize(() => {
|
|
128
|
+
release();
|
|
129
|
+
});
|
|
130
|
+
let t5;
|
|
131
|
+
if ($[6] !== jump) {
|
|
132
|
+
t5 = (t6, success) => {
|
|
133
|
+
const { x: x_5, y: y_5 } = t6;
|
|
134
|
+
if (success) jump(x_5, y_5);
|
|
135
|
+
};
|
|
136
|
+
$[6] = jump;
|
|
137
|
+
$[7] = t5;
|
|
138
|
+
} else t5 = $[7];
|
|
139
|
+
const tap = Gesture.Tap().maxDistance(SLOP).enabled(!isDisabled).runOnJS(true).onEnd(t5);
|
|
140
|
+
return Gesture.Race(testID === void 0 ? pan : pan.withTestId(`${testID}-pan`), testID === void 0 ? tap : tap.withTestId(`${testID}-tap`));
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { ADJUSTABLE, adjustOf, closestThumb, lengthTo, percentOf, seatPlaceOf, seats, useTrackGesture };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["AccessibilityActionEvent","AccessibilityActionInfo","DimensionValue","LayoutChangeEvent","ViewStyle","SharedValue","SliderState","I18nManager","StyleSheet","Gesture","useSharedValue","SLOP","SLOP_RANGE","TARGET","ADJUSTABLE","name","seats","create","seat","alignItems","bottom","justifyContent","marginStart","position","top","width","seatVertical","end","height","marginBottom","start","adjustOf","state","index","event","actionName","nativeEvent","setThumbDragging","incrementThumb","decrementThumb","closestThumb","values","value","split","findIndex","each","length","lastBefore","firstPast","Math","abs","lengthTo","set","vertical","layout","percentOf","fraction","seatPlaceOf","useTrackGesture","t0","$","_c","isDisabled","testID","dragged","t1","fractionAt","x","y","along","isRTL","grab","x_0","y_0","getPercentValue","setThumbPercent","move","x_1","y_1","index_0","get","fraction_0","release","index_1","t2","jump","x_2","y_2","fraction_1","index_2","drag","Pan","oriented","activeOffsetY","failOffsetX","activeOffsetX","failOffsetY","pan","enabled","runOnJS","onStart","t3","x_3","y_3","onUpdate","t4","x_4","y_4","onFinalize","t5","t6","success","x_5","y_5","tap","Tap","maxDistance","onEnd","Race","undefined","withTestId","_c"],"sources":["../../src/slider/index.ts"],"sourcesContent":["import type {\n AccessibilityActionEvent,\n AccessibilityActionInfo,\n DimensionValue,\n LayoutChangeEvent,\n ViewStyle,\n} from 'react-native'\nimport type { SharedValue } from 'react-native-reanimated'\nimport type { SliderState } from 'react-stately/useSliderState'\n\nimport { I18nManager, StyleSheet } from 'react-native'\nimport { Gesture } from 'react-native-gesture-handler'\nimport { useSharedValue } from 'react-native-reanimated'\n\n// What a slider and a colour slider share: the press and the drag along the\n// track, the frame a screen reader adjusts a handle in and the steps it asks\n// for. Both keep React Stately's slider state, a colour slider's being one\n// over a channel, so each reads and moves its value the same way.\n\n// How far a press moves along the track before it is a drag rather than a\n// tap, and across it before it is someone scrolling past: Gesture Handler's\n// own default distance for a pan.\nconst SLOP = 10\nconst SLOP_RANGE: [number, number] = [-SLOP, SLOP]\n\n// The width a screen reader frames a handle in, the page's 48dp target,\n// centred on the handle. Presses reach the track rather than this frame, so\n// it decides nothing but what a screen reader outlines.\nconst TARGET = 48\n\n// What a screen reader can ask of a handle: a step up, or a step down.\nconst ADJUSTABLE: readonly AccessibilityActionInfo[] = [\n { name: 'increment' },\n { name: 'decrement' },\n]\n\nconst seats = StyleSheet.create({\n // Where a handle sits: a frame the target's width, centred on the value,\n // across the whole strip, with the handle centred in it.\n seat: {\n alignItems: 'center',\n bottom: 0,\n justifyContent: 'center',\n marginStart: -TARGET / 2,\n position: 'absolute',\n top: 0,\n width: TARGET,\n },\n seatVertical: {\n alignItems: 'center',\n end: 0,\n height: TARGET,\n justifyContent: 'center',\n marginBottom: -TARGET / 2,\n position: 'absolute',\n start: 0,\n },\n})\n\n// Runs the step a screen reader asks a handle for, as a move that starts and\n// ends at once, so `onChangeEnd` comes once as it does for a key on web.\nfunction adjustOf(state: SliderState, index: number) {\n return (event: AccessibilityActionEvent) => {\n const { actionName } = event.nativeEvent\n if (actionName !== 'increment' && actionName !== 'decrement') {\n return\n }\n state.setThumbDragging(index, true)\n if (actionName === 'increment') {\n state.incrementThumb(index)\n } else {\n state.decrementThumb(index)\n }\n state.setThumbDragging(index, false)\n }\n}\n\n// The handle nearest a press at `value`, as React Aria picks it on web: the\n// first handle past it or the last before it, whichever is closer, and the\n// one past it when the two are as close.\nfunction closestThumb(values: readonly number[], value: number) {\n const split = values.findIndex((each) => value - each < 0)\n if (split === 0) {\n return 0\n }\n if (split === -1) {\n return values.length - 1\n }\n const lastBefore = values[split - 1] ?? value\n const firstPast = values[split] ?? value\n return Math.abs(lastBefore - value) < Math.abs(firstPast - value)\n ? split - 1\n : split\n}\n\n// Keeps the track's length along its axis as it is laid out.\nfunction lengthTo(set: (length: number) => void, vertical: boolean) {\n return ({ nativeEvent }: LayoutChangeEvent) => {\n set(vertical ? nativeEvent.layout.height : nativeEvent.layout.width)\n }\n}\n\nfunction percentOf(fraction: number): DimensionValue {\n return `${fraction * 100}%`\n}\n\n// Where a handle's frame sits along the track: centred on its value.\nfunction seatPlaceOf(fraction: number, vertical: boolean): ViewStyle {\n return vertical\n ? { bottom: percentOf(fraction) }\n : { start: percentOf(fraction) }\n}\n\n/**\n * The track's pan and tap. Each reads a press's place as a fraction of the\n * track, from the start or, vertical, from the bottom, and moves the handle\n * nearest it there. The pan holds that handle as dragged until it lets go,\n * which is what brings up its indicator and narrows it, and what\n * `onChangeEnd` waits for; the tap moves it and lets it go at once.\n *\n * Both run on the JavaScript thread, since every move sets React state.\n */\nfunction useTrackGesture({\n isDisabled,\n length,\n state,\n testID,\n vertical,\n}: {\n readonly isDisabled: boolean\n readonly length: number\n readonly state: SliderState\n readonly testID: string | undefined\n readonly vertical: boolean\n}) {\n // Which handle the pan holds, or -1. A shared value rather than a ref: the\n // gesture's callbacks are built while rendering, and the React Compiler\n // lets no ref reach them.\n const dragged: SharedValue<number> = useSharedValue(-1)\n\n // A press's place as a fraction of the way along the track, or null\n // before the track has a length to read it against. A press past either\n // end reads past 0 or 1, which React Stately clamps to the slider's ends.\n function fractionAt(x: number, y: number) {\n if (length <= 0) {\n return null\n }\n const along = (vertical ? y : x) / length\n if (vertical) {\n return 1 - along\n }\n return I18nManager.isRTL ? 1 - along : along\n }\n\n function grab(x: number, y: number) {\n const fraction = fractionAt(x, y)\n if (fraction === null) {\n return\n }\n const index = closestThumb(state.values, state.getPercentValue(fraction))\n dragged.set(index)\n state.setThumbDragging(index, true)\n state.setThumbPercent(index, fraction)\n }\n\n function move(x: number, y: number) {\n const index = dragged.get()\n const fraction = fractionAt(x, y)\n if (index >= 0 && fraction !== null) {\n state.setThumbPercent(index, fraction)\n }\n }\n\n function release() {\n const index = dragged.get()\n if (index >= 0) {\n dragged.set(-1)\n state.setThumbDragging(index, false)\n }\n }\n\n function jump(x: number, y: number) {\n const fraction = fractionAt(x, y)\n if (fraction === null) {\n return\n }\n const index = closestThumb(state.values, state.getPercentValue(fraction))\n state.setThumbDragging(index, true)\n state.setThumbPercent(index, fraction)\n state.setThumbDragging(index, false)\n }\n\n // Gesture Handler 3 deprecates these builders for hooks that version 2 does\n // not have, and the peer range admits both, so the builders stay while it\n // does.\n // oxlint-disable-next-line react/capitalized-calls, typescript/no-deprecated -- a builder named after its gesture, not a component; see above\n const drag = Gesture.Pan()\n // Taken once it moves along the track, and let go to a scroll view once\n // it moves across it first.\n const oriented = vertical\n ? drag.activeOffsetY(SLOP_RANGE).failOffsetX(SLOP_RANGE)\n : drag.activeOffsetX(SLOP_RANGE).failOffsetY(SLOP_RANGE)\n const pan = oriented\n .enabled(!isDisabled)\n .runOnJS(true)\n .onStart(({ x, y }) => {\n grab(x, y)\n })\n .onUpdate(({ x, y }) => {\n move(x, y)\n })\n .onFinalize(() => {\n release()\n })\n // oxlint-disable-next-line react/capitalized-calls, typescript/no-deprecated -- as above\n const tap = Gesture.Tap()\n .maxDistance(SLOP)\n .enabled(!isDisabled)\n .runOnJS(true)\n .onEnd(({ x, y }, success) => {\n if (success) {\n jump(x, y)\n }\n })\n\n // oxlint-disable-next-line react/capitalized-calls, typescript/no-deprecated -- as above\n return Gesture.Race(\n testID === undefined ? pan : pan.withTestId(`${testID}-pan`),\n testID === undefined ? tap : tap.withTestId(`${testID}-tap`),\n )\n}\n\nexport {\n ADJUSTABLE,\n adjustOf,\n closestThumb,\n lengthTo,\n percentOf,\n seatPlaceOf,\n seats,\n useTrackGesture,\n}\n"],"mappings":";;;;;AAsBA,MAAMW,OAAO;AACb,MAAMC,aAA+B,CAAC,KAAOD,IAAI;AAKjD,MAAME,SAAS;AAGf,MAAMC,aAAiD,CACrD,EAAEC,MAAM,YAAY,GACpB,EAAEA,MAAM,YAAY,CAAC;AAGvB,MAAMC,QAAQR,WAAWS,OAAO;CAG9BC,MAAM;EACJC,YAAY;EACZC,QAAQ;EACRC,gBAAg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,CAAC,CAAAC,YACVzG,IAAI,CAAC,CAAAuF,QACT,CAACpC,UAAU,CAAC,CAAAqC,QACZ,IAAI,CAAC,CAAAkB,MACPR,EAIN;CAAC,OAGGpG,QAAO6G,KACZvD,WAAWwD,KAAAA,IAAXtB,MAA6BA,IAAGuB,WAAY,GAAGzD,OAAM,KAAM,GAC3DA,WAAWwD,KAAAA,IAAXL,MAA6BA,IAAGM,WAAY,GAAGzD,OAAM,KAAM,CAC7D;AAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createContext, use } from "react";
|
|
2
|
+
import { parseColor } from "react-stately";
|
|
3
|
+
//#region src/swatch/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The colour of the ColorPicker around a control, which ColorArea,
|
|
6
|
+
* ColorField, ColorSlider, ColorSwatch, ColorSwatchPicker and ColorWheel take
|
|
7
|
+
* where they are given no value of their own.
|
|
8
|
+
*/
|
|
9
|
+
const PickedColorContext = createContext(null);
|
|
10
|
+
/**
|
|
11
|
+
* The colour of the ColorSwatchPicker item a swatch is drawn in, which the
|
|
12
|
+
* swatch draws when it is given no `color` of its own, as React Aria's swatch
|
|
13
|
+
* reads its item's colour on web.
|
|
14
|
+
*/
|
|
15
|
+
const SwatchColorContext = createContext(void 0);
|
|
16
|
+
/**
|
|
17
|
+
* What a colour is called in the locale, "light vibrant cyan blue, 60%
|
|
18
|
+
* transparent", or `transparent`, the library's word for it, when it has no
|
|
19
|
+
* alpha left, since there is then no colour left to name.
|
|
20
|
+
*/
|
|
21
|
+
function colorNameOf(color, locale, transparent) {
|
|
22
|
+
return color.getChannelValue("alpha") === 0 ? transparent : color.getColorName(locale);
|
|
23
|
+
}
|
|
24
|
+
/** A colour as React Stately's `Color`, parsed when it is a CSS string. */
|
|
25
|
+
function colorOf(color) {
|
|
26
|
+
return typeof color === "string" ? parseColor(color) : color;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A control's value and change handler inside the ColorPicker around it, as
|
|
30
|
+
* React Aria merges a control's props over its context: the control's own
|
|
31
|
+
* `value` where it is given one, else the picker's, and the picker's handler
|
|
32
|
+
* called ahead of the control's own. Outside a picker, the control's own two.
|
|
33
|
+
*/
|
|
34
|
+
function usePickedColor(value, onChange) {
|
|
35
|
+
const picker = use(PickedColorContext);
|
|
36
|
+
if (picker === null) return {
|
|
37
|
+
onChange,
|
|
38
|
+
value
|
|
39
|
+
};
|
|
40
|
+
const chained = (color) => {
|
|
41
|
+
picker.onChange(color);
|
|
42
|
+
onChange?.(color);
|
|
43
|
+
};
|
|
44
|
+
if (value !== void 0) return {
|
|
45
|
+
onChange: chained,
|
|
46
|
+
value
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
onChange: chained,
|
|
50
|
+
value: picker.value
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { PickedColorContext, SwatchColorContext, colorNameOf, colorOf, usePickedColor };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Color","createContext","use","parseColor","PickedColor","onChange","color","value","PickedColorContext","SwatchColorContext","undefined","colorNameOf","locale","transparent","getChannelValue","getColorName","colorOf","usePickedColor","Value","Changed","picker","chained"],"sources":["../../src/swatch/index.ts"],"sourcesContent":["import type { Color } from 'react-stately'\n\nimport { createContext, use } from 'react'\nimport { parseColor } from 'react-stately'\n\n// What the colour components share: the colour a ColorSwatchPicker item hands\n// the swatch inside it, the colour a ColorPicker hands every control on its\n// surface, how a colour given as a string is read, and what a colour is\n// called.\n\n/**\n * The colour a ColorPicker holds, and what a control on its surface reports a\n * change through, as React Aria's picker hands its value to the context of\n * each colour control on web. A change to `null`, an emptied field's, keeps\n * the colour, as React Stately's picker state does.\n */\ntype PickedColor = {\n readonly onChange: (color: Color | null) => void\n readonly value: Color\n}\n\n/**\n * The colour of the ColorPicker around a control, which ColorArea,\n * ColorField, ColorSlider, ColorSwatch, ColorSwatchPicker and ColorWheel take\n * where they are given no value of their own.\n */\nconst PickedColorContext = createContext<null | PickedColor>(null)\n\n/**\n * The colour of the ColorSwatchPicker item a swatch is drawn in, which the\n * swatch draws when it is given no `color` of its own, as React Aria's swatch\n * reads its item's colour on web.\n */\nconst SwatchColorContext = createContext<Color | undefined>(undefined)\n\n/**\n * What a colour is called in the locale, \"light vibrant cyan blue, 60%\n * transparent\", or `transparent`, the library's word for it, when it has no\n * alpha left, since there is then no colour left to name.\n */\nfunction colorNameOf(color: Color, locale: string, transparent: string) {\n return color.getChannelValue('alpha') === 0\n ? transparent\n : color.getColorName(locale)\n}\n\n/** A colour as React Stately's `Color`, parsed when it is a CSS string. */\nfunction colorOf(color: Color | string): Color {\n return typeof color === 'string' ? parseColor(color) : color\n}\n\n/**\n * A control's value and change handler inside the ColorPicker around it, as\n * React Aria merges a control's props over its context: the control's own\n * `value` where it is given one, else the picker's, and the picker's handler\n * called ahead of the control's own. Outside a picker, the control's own two.\n */\nfunction usePickedColor<Value, Changed extends Color | null>(\n value: undefined | Value,\n onChange: ((color: Changed) => void) | undefined,\n) {\n const picker = use(PickedColorContext)\n\n if (picker === null) {\n return { onChange, value }\n }\n\n const chained = (color: Changed) => {\n picker.onChange(color)\n onChange?.(color)\n }\n\n // Kept where it is null, a field emptied on purpose, as React Aria keeps\n // any value but a missing one.\n if (value !== undefined) {\n return { onChange: chained, value }\n }\n return { onChange: chained, value: picker.value }\n}\n\nexport {\n colorNameOf,\n colorOf,\n PickedColorContext,\n SwatchColorContext,\n usePickedColor,\n}\nexport type { PickedColor }\n"],"mappings":";;;;;;;;AA0BA,MAAMQ,qBAAqBP,cAAkC,IAAI;;;;;;AAOjE,MAAMQ,qBAAqBR,cAAiCS,KAAAA,CAAS;;;;;;AAOrE,SAASC,YAAYL,OAAcM,QAAgBC,aAAqB;CACtE,OAAOP,MAAMQ,gBAAgB,OAAO,MAAM,IACtCD,cACAP,MAAMS,aAAaH,MAAM;AAC/B;;AAGA,SAASI,QAAQV,OAA8B;CAC7C,OAAO,OAAOA,UAAU,WAAWH,WAAWG,KAAK,IAAIA;AACzD;;;;;;;AAQA,SAASW,eACPV,OACAF,UACA;CACA,MAAMe,SAASlB,IAAIM,kBAAkB;CAErC,IAAIY,WAAW,MACb,OAAO;EAAEf;EAAUE;CAAM;CAG3B,MAAMc,WAAWf,UAAmB;EAClCc,OAAOf,SAASC,KAAK;EACrBD,WAAWC,KAAK;CAClB;CAIA,IAAIC,UAAUG,KAAAA,GACZ,OAAO;EAAEL,UAAUgB;EAASd;CAAM;CAEpC,OAAO;EAAEF,UAAUgB;EAASd,OAAOa,OAAOb;CAAM;AAClD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanso-labs/react-native-kanso-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Kanso UI's Material Design components for React Native, themed through the same --kui-* design tokens as the web library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -111,20 +111,29 @@
|
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|
|
113
113
|
"expo-clipboard": ">=57.0.0",
|
|
114
|
+
"expo-document-picker": ">=57.0.0",
|
|
114
115
|
"expo-font": ">=57.0.0",
|
|
116
|
+
"expo-image-picker": ">=57.0.0",
|
|
115
117
|
"react": ">=19.2.0",
|
|
116
118
|
"react-native": ">=0.86.0",
|
|
117
119
|
"react-native-gesture-handler": "^2.32.0 || ^3.0.0",
|
|
118
120
|
"react-native-reanimated": "^4.5.0",
|
|
119
121
|
"react-native-safe-area-context": "^5.0.0",
|
|
120
|
-
"react-native-svg": "^15.15.0"
|
|
122
|
+
"react-native-svg": "^15.15.0",
|
|
123
|
+
"react-native-worklets": ">=0.10.0"
|
|
121
124
|
},
|
|
122
125
|
"peerDependenciesMeta": {
|
|
123
126
|
"expo-clipboard": {
|
|
124
127
|
"optional": true
|
|
125
128
|
},
|
|
129
|
+
"expo-document-picker": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
126
132
|
"expo-font": {
|
|
127
133
|
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"expo-image-picker": {
|
|
136
|
+
"optional": true
|
|
128
137
|
}
|
|
129
138
|
},
|
|
130
139
|
"overrides": {
|