@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.
Files changed (217) hide show
  1. package/README.md +4 -3
  2. package/dist/autocomplete/index.js +15 -1
  3. package/dist/autocomplete/index.js.map +1 -1
  4. package/dist/button/group.d.ts +5 -0
  5. package/dist/button/group.js +115 -0
  6. package/dist/button/group.js.map +1 -0
  7. package/dist/button/index.d.ts +4 -1
  8. package/dist/button/index.js +44 -22
  9. package/dist/button/index.js.map +1 -1
  10. package/dist/button/slots.js +2 -1
  11. package/dist/button/slots.js.map +1 -1
  12. package/dist/calendar/index.js +351 -182
  13. package/dist/calendar/index.js.map +1 -1
  14. package/dist/calendar/styles.js +33 -2
  15. package/dist/calendar/styles.js.map +1 -1
  16. package/dist/carousel/arrangement.d.ts +5 -0
  17. package/dist/carousel/arrangement.js +123 -0
  18. package/dist/carousel/arrangement.js.map +1 -0
  19. package/dist/chequer/index.js +95 -0
  20. package/dist/chequer/index.js.map +1 -0
  21. package/dist/collection/index.d.ts +157 -0
  22. package/dist/collection/index.js +1358 -0
  23. package/dist/collection/index.js.map +1 -0
  24. package/dist/color-thumb/index.js +56 -0
  25. package/dist/color-thumb/index.js.map +1 -0
  26. package/dist/components/button/index.d.ts +4 -2
  27. package/dist/components/button/index.js +227 -188
  28. package/dist/components/button/index.js.map +1 -1
  29. package/dist/components/button-group/index.d.ts +87 -0
  30. package/dist/components/button-group/index.js +275 -0
  31. package/dist/components/button-group/index.js.map +1 -0
  32. package/dist/components/calendar/index.d.ts +11 -3
  33. package/dist/components/calendar/index.js +60 -45
  34. package/dist/components/calendar/index.js.map +1 -1
  35. package/dist/components/carousel/index.d.ts +72 -0
  36. package/dist/components/carousel/index.js +496 -0
  37. package/dist/components/carousel/index.js.map +1 -0
  38. package/dist/components/checkbox-group/index.d.ts +3 -4
  39. package/dist/components/checkbox-group/index.js +1 -1
  40. package/dist/components/checkbox-group/index.js.map +1 -1
  41. package/dist/components/chip/index.d.ts +4 -1
  42. package/dist/components/chip/index.js +229 -161
  43. package/dist/components/chip/index.js.map +1 -1
  44. package/dist/components/color-area/index.d.ts +85 -0
  45. package/dist/components/color-area/index.js +630 -0
  46. package/dist/components/color-area/index.js.map +1 -0
  47. package/dist/components/color-field/index.d.ts +144 -0
  48. package/dist/components/color-field/index.js +516 -0
  49. package/dist/components/color-field/index.js.map +1 -0
  50. package/dist/components/color-picker/index.d.ts +74 -0
  51. package/dist/components/color-picker/index.js +317 -0
  52. package/dist/components/color-picker/index.js.map +1 -0
  53. package/dist/components/color-slider/index.d.ts +82 -0
  54. package/dist/components/color-slider/index.js +456 -0
  55. package/dist/components/color-slider/index.js.map +1 -0
  56. package/dist/components/color-swatch/index.d.ts +46 -0
  57. package/dist/components/color-swatch/index.js +127 -0
  58. package/dist/components/color-swatch/index.js.map +1 -0
  59. package/dist/components/color-swatch-picker/index.d.ts +81 -0
  60. package/dist/components/color-swatch-picker/index.js +287 -0
  61. package/dist/components/color-swatch-picker/index.js.map +1 -0
  62. package/dist/components/color-wheel/index.d.ts +71 -0
  63. package/dist/components/color-wheel/index.js +407 -0
  64. package/dist/components/color-wheel/index.js.map +1 -0
  65. package/dist/components/combo-box/index.d.ts +193 -0
  66. package/dist/components/combo-box/index.js +616 -0
  67. package/dist/components/combo-box/index.js.map +1 -0
  68. package/dist/components/date-field/index.d.ts +120 -0
  69. package/dist/components/date-field/index.js +111 -0
  70. package/dist/components/date-field/index.js.map +1 -0
  71. package/dist/components/date-picker/index.d.ts +130 -0
  72. package/dist/components/date-picker/index.js +310 -0
  73. package/dist/components/date-picker/index.js.map +1 -0
  74. package/dist/components/date-range-picker/index.d.ts +139 -0
  75. package/dist/components/date-range-picker/index.js +421 -0
  76. package/dist/components/date-range-picker/index.js.map +1 -0
  77. package/dist/components/dialog/index.d.ts +5 -5
  78. package/dist/components/dialog/index.js +5 -5
  79. package/dist/components/dialog/index.js.map +1 -1
  80. package/dist/components/disclosure/index.d.ts +94 -0
  81. package/dist/components/disclosure/index.js +365 -0
  82. package/dist/components/disclosure/index.js.map +1 -0
  83. package/dist/components/disclosure-group/index.d.ts +61 -0
  84. package/dist/components/disclosure-group/index.js +100 -0
  85. package/dist/components/disclosure-group/index.js.map +1 -0
  86. package/dist/components/drop-zone/index.d.ts +113 -0
  87. package/dist/components/drop-zone/index.js +304 -0
  88. package/dist/components/drop-zone/index.js.map +1 -0
  89. package/dist/components/fab/index.d.ts +1 -1
  90. package/dist/components/fab/index.js +91 -76
  91. package/dist/components/fab/index.js.map +1 -1
  92. package/dist/components/form/index.d.ts +3 -2
  93. package/dist/components/form/index.js.map +1 -1
  94. package/dist/components/icon-button/index.d.ts +4 -2
  95. package/dist/components/icon-button/index.js +204 -171
  96. package/dist/components/icon-button/index.js.map +1 -1
  97. package/dist/components/list/index.d.ts +15 -158
  98. package/dist/components/list/index.js +21 -1047
  99. package/dist/components/list/index.js.map +1 -1
  100. package/dist/components/list-box/index.d.ts +73 -0
  101. package/dist/components/list-box/index.js +82 -0
  102. package/dist/components/list-box/index.js.map +1 -0
  103. package/dist/components/loading-indicator/index.d.ts +32 -0
  104. package/dist/components/loading-indicator/index.js +174 -0
  105. package/dist/components/loading-indicator/index.js.map +1 -0
  106. package/dist/components/menu/index.d.ts +3 -3
  107. package/dist/components/menu/index.js +3 -3
  108. package/dist/components/menu/index.js.map +1 -1
  109. package/dist/components/navigation-tree/index.d.ts +117 -0
  110. package/dist/components/navigation-tree/index.js +135 -0
  111. package/dist/components/navigation-tree/index.js.map +1 -0
  112. package/dist/components/number-field/index.js +132 -143
  113. package/dist/components/number-field/index.js.map +1 -1
  114. package/dist/components/popover/index.d.ts +2 -2
  115. package/dist/components/popover/index.js +2 -2
  116. package/dist/components/popover/index.js.map +1 -1
  117. package/dist/components/range-calendar/index.d.ts +69 -0
  118. package/dist/components/range-calendar/index.js +144 -0
  119. package/dist/components/range-calendar/index.js.map +1 -0
  120. package/dist/components/search-view/index.d.ts +79 -0
  121. package/dist/components/search-view/index.js +571 -0
  122. package/dist/components/search-view/index.js.map +1 -0
  123. package/dist/components/select/index.d.ts +152 -0
  124. package/dist/components/select/index.js +419 -0
  125. package/dist/components/select/index.js.map +1 -0
  126. package/dist/components/sheet/index.d.ts +16 -7
  127. package/dist/components/sheet/index.js +157 -152
  128. package/dist/components/sheet/index.js.map +1 -1
  129. package/dist/components/slider/index.d.ts +111 -0
  130. package/dist/components/slider/index.js +673 -0
  131. package/dist/components/slider/index.js.map +1 -0
  132. package/dist/components/split-button/index.d.ts +77 -0
  133. package/dist/components/split-button/index.js +354 -0
  134. package/dist/components/split-button/index.js.map +1 -0
  135. package/dist/components/table/index.d.ts +391 -0
  136. package/dist/components/table/index.js +1708 -0
  137. package/dist/components/table/index.js.map +1 -0
  138. package/dist/components/tabs/index.d.ts +196 -0
  139. package/dist/components/tabs/index.js +1137 -0
  140. package/dist/components/tabs/index.js.map +1 -0
  141. package/dist/components/time-field/index.d.ts +43 -0
  142. package/dist/components/time-field/index.js +107 -0
  143. package/dist/components/time-field/index.js.map +1 -0
  144. package/dist/components/time-picker/index.d.ts +65 -0
  145. package/dist/components/time-picker/index.js +1168 -0
  146. package/dist/components/time-picker/index.js.map +1 -0
  147. package/dist/components/token-field/index.d.ts +105 -0
  148. package/dist/components/token-field/index.js +574 -0
  149. package/dist/components/token-field/index.js.map +1 -0
  150. package/dist/components/tooltip/index.d.ts +102 -0
  151. package/dist/components/tooltip/index.js +223 -0
  152. package/dist/components/tooltip/index.js.map +1 -0
  153. package/dist/components/tree/index.d.ts +112 -0
  154. package/dist/components/tree/index.js +157 -0
  155. package/dist/components/tree/index.js.map +1 -0
  156. package/dist/disclosure/chevron.js +75 -0
  157. package/dist/disclosure/chevron.js.map +1 -0
  158. package/dist/disclosure/index.js +7 -0
  159. package/dist/disclosure/index.js.map +1 -0
  160. package/dist/drop/index.d.ts +54 -0
  161. package/dist/drop/index.js +161 -0
  162. package/dist/drop/index.js.map +1 -0
  163. package/dist/field/chevron.js +74 -0
  164. package/dist/field/chevron.js.map +1 -0
  165. package/dist/field/index.d.ts +2 -1
  166. package/dist/field/index.js +359 -154
  167. package/dist/field/index.js.map +1 -1
  168. package/dist/field/styles.js +18 -1
  169. package/dist/field/styles.js.map +1 -1
  170. package/dist/files/index.d.ts +18 -0
  171. package/dist/files/index.js +107 -0
  172. package/dist/files/index.js.map +1 -0
  173. package/dist/form/index.d.ts +5 -2
  174. package/dist/form/index.js +64 -85
  175. package/dist/form/index.js.map +1 -1
  176. package/dist/glyphs/index.js +128 -1
  177. package/dist/glyphs/index.js.map +1 -1
  178. package/dist/i18n/index.js +36 -1
  179. package/dist/i18n/index.js.map +1 -1
  180. package/dist/i18n/messages.js +1734 -34
  181. package/dist/i18n/messages.js.map +1 -1
  182. package/dist/index.d.ts +37 -3
  183. package/dist/index.js +36 -3
  184. package/dist/indicator/paths.js +23 -1
  185. package/dist/indicator/paths.js.map +1 -1
  186. package/dist/modal/index.js +92 -77
  187. package/dist/modal/index.js.map +1 -1
  188. package/dist/number/keyboard.js +16 -0
  189. package/dist/number/keyboard.js.map +1 -0
  190. package/dist/overlay/anchored.js +68 -38
  191. package/dist/overlay/anchored.js.map +1 -1
  192. package/dist/overlay/keyboard.js +57 -0
  193. package/dist/overlay/keyboard.js.map +1 -0
  194. package/dist/overlay/panel.js +173 -19
  195. package/dist/overlay/panel.js.map +1 -1
  196. package/dist/overlay/placement.js +13 -1
  197. package/dist/overlay/placement.js.map +1 -1
  198. package/dist/picker/index.js +322 -0
  199. package/dist/picker/index.js.map +1 -0
  200. package/dist/press/index.d.ts +2 -0
  201. package/dist/press/index.js +102 -100
  202. package/dist/press/index.js.map +1 -1
  203. package/dist/row/index.js +77 -69
  204. package/dist/row/index.js.map +1 -1
  205. package/dist/row/styles.js +13 -2
  206. package/dist/row/styles.js.map +1 -1
  207. package/dist/segments/field.js +277 -0
  208. package/dist/segments/field.js.map +1 -0
  209. package/dist/segments/index.js +574 -0
  210. package/dist/segments/index.js.map +1 -0
  211. package/dist/segments/styles.js +24 -0
  212. package/dist/segments/styles.js.map +1 -0
  213. package/dist/slider/index.js +145 -0
  214. package/dist/slider/index.js.map +1 -0
  215. package/dist/swatch/index.js +56 -0
  216. package/dist/swatch/index.js.map +1 -0
  217. package/package.json +11 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","LayoutChangeEvent","StyleProp","ViewStyle","AnimatedStyle","Key","DisclosureGroupState","DisclosureState","createContext","use","useCallback","useEffect","useId","useMemo","useState","Pressable","StyleSheet","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","useDisclosureState","ResolvedTheme","DisclosureGroupStateContext","ExpandChevron","usePressFeedback","RowContent","rowContentColor","rowStyleOf","rowStyles","useTheme","composeStyles","themedStyles","stylesOf","spacing","create","inner","paddingBottom","lg","paddingHorizontal","styles","clip","overflow","closed","display","DisclosureContextValue","header","isDisabled","state","DisclosureHeaderProps","children","leading","ref","style","supporting","testID","DisclosurePanelProps","role","DisclosureProps","defaultExpanded","id","isExpanded","onExpandedChange","DisclosureContext","chevronFor","Disclosure","t0","$","_c","t1","undefined","group","fallback","key","t2","expandedKeys","has","t3","expandedChangeOf","t4","disabled","t5","value","t6","t7","DisclosureHeader","useDisclosure","theme","color","feedback","toggleOf","handlers","ring","layer","t8","t9","t10","DisclosurePanel","own","motion","reduceMotion","shown","setShown","openness","height","event","set","nativeEvent","layout","measure","target","duration","durationMedium2","easing","bezier","easingEmphasized","timer","setTimeout","clearTimeout","measured","get","progress","T0","expanded","toggleKey","toggle","part","Error","Header","Panel","_c"],"sources":["../../../src/components/disclosure/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\nimport type { Key } from 'react-stately'\nimport type { DisclosureGroupState } from 'react-stately/useDisclosureGroupState'\nimport type { DisclosureState } from 'react-stately/useDisclosureState'\n\nimport {\n createContext,\n use,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated'\nimport { useDisclosureState } from 'react-stately/useDisclosureState'\n\nimport type { ResolvedTheme } from '../../theme/scope'\n\nimport { DisclosureGroupStateContext } from '../../disclosure'\nimport { ExpandChevron } from '../../disclosure/chevron'\nimport { usePressFeedback } from '../../press'\nimport { RowContent, rowContentColor, rowStyleOf, rowStyles } from '../../row'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\n\n// kanso-ui's Disclosure: a section that opens to show what is under it, and\n// closes again. The header is the row every list here draws, src/row, shared\n// with ListItem and every menu item, so its 56dp floor, 72dp with a\n// supporting line, body-large headline, body-medium supporting line and\n// state layers are that module's, and a header above a list cannot drift\n// from the rows below it. A 24dp chevron in its trailing slot turns a quarter\n// to point down once the section is open, over the short3 duration on the\n// standard curve, as web's does, and mirrors under right-to-left. The panel\n// holds its content 16dp in, lined up with the headline above it.\n//\n// **The header is a button and not a heading.** Web renders the button\n// inside a heading at `headingLevel`; React Native's screen readers have no\n// heading levels, so the prop is dropped, as AppBar drops it. The button\n// reports whether the section is expanded.\n//\n// **The panel moves its height on Reanimated**, from nothing to the height\n// its content reports through `onLayout`, over the medium2 duration on the\n// emphasised curve, web's. Under reduced motion it opens and closes at once.\n// It closes the same way it opens, which web does not: there the collapsed\n// panel takes React Aria's `hidden=\"until-found\"`, which stops its content\n// being laid out at once and leaves nothing to shrink, and native has no\n// counterpart to it. Once closed, its content is laid out no longer, so\n// nothing in it is reached by a press, a key or a screen reader, and it is\n// hidden from a screen reader while it closes.\n//\n// The state is React Stately's `useDisclosureState`, the one web's React Aria\n// keeps, handed to the two parts through context. Inside a DisclosureGroup\n// the group's keys say whether the section is open, under its `id`, and the\n// group's `isDisabled` disables it as its own does, as React Aria's do.\n\nconst stylesOf = themedStyles(({ spacing }: ResolvedTheme) =>\n StyleSheet.create({\n inner: {\n paddingBottom: spacing.lg,\n paddingHorizontal: spacing.lg,\n },\n }),\n)\n\nconst styles = StyleSheet.create({\n // What the panel's height moves inside: its content lays out at its own\n // height whatever the clip is, which is what `onLayout` measures.\n clip: {\n overflow: 'hidden',\n },\n // A closed panel's content, which takes no part in layout, presses, keys\n // or a screen reader once its close has run.\n closed: {\n display: 'none',\n },\n})\n\ntype DisclosureContextValue = {\n readonly header: string\n readonly isDisabled: boolean\n readonly state: DisclosureState\n}\n\ntype DisclosureHeaderProps = {\n /** The header's headline, what the section is about. */\n readonly children?: ReactNode\n /** Content before the headline: an avatar, an icon. */\n readonly leading?: ReactNode\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n /** A second line under the headline, in the muted role. */\n readonly supporting?: ReactNode\n readonly testID?: string\n}\n\ntype DisclosurePanelProps = {\n /** What the section shows while it is open. */\n readonly children?: ReactNode\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * `region` names the panel as a landmark, for a section a reader should be\n * able to jump to, where `group` only gathers what is in it.\n * @default 'group'\n */\n readonly role?: 'group' | 'region'\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\ntype DisclosureProps = {\n /** A `Disclosure.Header` and a `Disclosure.Panel`. */\n readonly children?: ReactNode\n /** Whether the section starts open, when it keeps its own state. */\n readonly defaultExpanded?: boolean\n /**\n * The section's key in a `DisclosureGroup`, which the group reports as\n * expanded. Outside a group it does nothing.\n */\n readonly id?: Key\n /**\n * Keeps the section from opening or closing, and draws its header\n * disabled.\n * @default false\n */\n readonly isDisabled?: boolean\n /** Whether the section is open, when the call site holds the state. */\n readonly isExpanded?: boolean\n /** Called with the new state as the section opens or closes. */\n readonly onExpandedChange?: (isExpanded: boolean) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\nconst DisclosureContext = createContext<DisclosureContextValue | null>(null)\n\n// The chevron, turned or not. A call rather than JSX written at the prop,\n// which is what react-perf's jsx-no-jsx-as-prop is after; the React Compiler\n// memoises the result on `isExpanded`.\nfunction chevronFor(isExpanded: boolean) {\n return <ExpandChevron isExpanded={isExpanded} />\n}\n\n/**\n * A section that opens to show what is under it. Pass `isExpanded` with\n * `onExpandedChange` to hold whether it is open, or `defaultExpanded` to let\n * it keep its own.\n *\n * ```tsx\n * <Disclosure>\n * <Disclosure.Header>Headline</Disclosure.Header>\n * <Disclosure.Panel>\n * <Text>Supporting line</Text>\n * </Disclosure.Panel>\n * </Disclosure>\n * ```\n *\n * The header is the row every list here draws, so a section above a list of\n * rows lines up with them. The panel opens to whatever height its content\n * reports, and opens and closes at once under reduced motion.\n *\n * Inside a `DisclosureGroup`, give it an `id`, the key the group reports.\n *\n * `style`, `ref` and `testID` land on the section's own view, as they do on\n * each part's.\n */\nfunction Disclosure({\n children,\n defaultExpanded,\n id,\n isDisabled = false,\n isExpanded,\n onExpandedChange,\n ref,\n style,\n testID,\n}: DisclosureProps) {\n const group = use(DisclosureGroupStateContext)\n const fallback = useId()\n const key = id ?? fallback\n const state = useDisclosureState({\n defaultExpanded,\n isExpanded: group === null ? isExpanded : group.expandedKeys.has(key),\n onExpandedChange: expandedChangeOf(group, key, onExpandedChange),\n })\n const header = useId()\n const disabled = isDisabled || (group?.isDisabled ?? false)\n const value = useMemo<DisclosureContextValue>(\n () => ({ header, isDisabled: disabled, state }),\n [disabled, header, state],\n )\n\n return (\n <DisclosureContext value={value}>\n <View ref={ref} style={style} testID={testID}>\n {children}\n </View>\n </DisclosureContext>\n )\n}\n\n/**\n * The row that opens and closes the section: a button announced as expanded\n * or collapsed, drawing the shared row's slots with a chevron in the\n * trailing one.\n */\nfunction DisclosureHeader({\n children,\n leading,\n ref,\n style,\n supporting,\n testID,\n}: DisclosureHeaderProps) {\n const { header, isDisabled, state } = useDisclosure('Disclosure.Header')\n const theme = useTheme()\n const feedback = usePressFeedback({\n color: rowContentColor(theme, { isDisabled }),\n disabled: isDisabled,\n })\n\n return (\n <Pressable\n aria-expanded={state.isExpanded}\n id={header}\n onPress={toggleOf(state)}\n ref={ref}\n role=\"button\"\n testID={testID}\n {...feedback.handlers}\n disabled={isDisabled}\n style={composeStyles<ViewStyle>(\n rowStyleOf(theme, { supporting }),\n feedback.ring,\n feedback.ring === undefined ? undefined : rowStyles.ring,\n style,\n )}\n >\n {feedback.layer}\n <RowContent\n isDisabled={isDisabled}\n leading={leading}\n supporting={supporting}\n trailing={chevronFor(state.isExpanded)}\n >\n {children}\n </RowContent>\n </Pressable>\n )\n}\n\n/**\n * What the section shows while it is open. Its content sits 16dp in, lined\n * up with the headline above it, and it is named by the header.\n */\nfunction DisclosurePanel({\n children,\n ref,\n role = 'group',\n style,\n testID,\n}: DisclosurePanelProps) {\n const { header, state } = useDisclosure('Disclosure.Panel')\n const { isExpanded } = state\n const theme = useTheme()\n const own = stylesOf(theme)\n const { motion } = theme\n const reduceMotion = useReducedMotion()\n // Whether the content is laid out: from the moment the section opens until\n // its close has run.\n const [shown, setShown] = useState(isExpanded)\n const openness = useSharedValue(isExpanded ? 1 : 0)\n // The content's own height, once it has reported one while laid out. A\n // closed panel's content reports nothing worth keeping, and the handler is\n // there from the start all the same: React Native Web watches a view's size\n // only if it had a handler when it mounted.\n const height = useSharedValue(-1)\n const measure = useCallback(\n (event: LayoutChangeEvent) => {\n if (shown) {\n height.set(event.nativeEvent.layout.height)\n }\n },\n [height, shown],\n )\n\n // Laid out the moment it opens, and at once no longer when it closes with\n // no motion to run.\n if (isExpanded && !shown) {\n setShown(true)\n } else if (!isExpanded && shown && reduceMotion) {\n setShown(false)\n }\n\n useEffect(() => {\n const target = isExpanded ? 1 : 0\n\n if (reduceMotion) {\n openness.set(target)\n return undefined\n }\n\n openness.set(\n withTiming(target, {\n duration: motion.durationMedium2,\n easing: Easing.bezier(...motion.easingEmphasized),\n }),\n )\n if (isExpanded) {\n return undefined\n }\n\n const timer = setTimeout(() => {\n setShown(false)\n }, motion.durationMedium2)\n\n return () => {\n clearTimeout(timer)\n }\n }, [isExpanded, motion, openness, reduceMotion])\n\n // Open before the content has reported a height, the panel takes the\n // content's own, so a section that starts open draws it on the first\n // frame; otherwise it is the share of that height the motion has reached.\n const clip = useAnimatedStyle(() => {\n 'worklet'\n const measured = height.get()\n const progress = openness.get()\n\n if (measured < 0) {\n return progress === 1 ? {} : { height: 0 }\n }\n\n return { height: measured * progress }\n })\n\n return (\n <Animated.View\n aria-hidden={!isExpanded}\n aria-labelledby={header}\n ref={ref}\n role={role}\n style={composeStyles<AnimatedStyle<ViewStyle>>(styles.clip, clip, style)}\n testID={testID}\n >\n <View\n onLayout={measure}\n style={composeStyles<ViewStyle>(\n own.inner,\n shown ? undefined : styles.closed,\n )}\n >\n {children}\n </View>\n </Animated.View>\n )\n}\n\n// What a section calls as it opens or closes: inside a group, the group's\n// toggle of its key first, then the call site's own handler either way.\nfunction expandedChangeOf(\n group: DisclosureGroupState | null,\n key: Key,\n onExpandedChange: ((isExpanded: boolean) => void) | undefined,\n) {\n return (expanded: boolean) => {\n group?.toggleKey(key)\n onExpandedChange?.(expanded)\n }\n}\n\n// A press's toggle. Built by a call rather than declared in the component,\n// which is what react-perf's jsx-no-new-function-as-prop is after; the React\n// Compiler memoises the result on its input.\nfunction toggleOf(state: DisclosureState) {\n return () => {\n state.toggle()\n }\n}\n\nfunction useDisclosure(part: string): DisclosureContextValue {\n const value = use(DisclosureContext)\n if (value === null) {\n throw new Error(`${part} is drawn inside Disclosure.`)\n }\n return value\n}\n\nDisclosure.Header = DisclosureHeader\nDisclosure.Panel = DisclosurePanel\n\nexport { Disclosure, DisclosureHeader, DisclosurePanel }\nexport type { DisclosureHeaderProps, DisclosurePanelProps, DisclosureProps }\n"],"mappings":";;;;;;;;;;;;;;AAiEA,MAAMsC,WAAWD,cAAc,EAAEE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+D,SAAS3C;AACpBpB,WAAWgE,QAAQhC"}
@@ -0,0 +1,61 @@
1
+ import { StyleProp, View, ViewStyle } from "react-native";
2
+ import { ComponentRef, ReactNode, Ref } from "react";
3
+ import { Key } from "react-stately";
4
+ //#region src/components/disclosure-group/index.d.ts
5
+ type DisclosureGroupProps = {
6
+ /**
7
+ * Whether several sections may be open at once. Otherwise opening one
8
+ * closes the one that was open.
9
+ * @default false
10
+ */
11
+ readonly allowsMultipleExpanded?: boolean;
12
+ /** The sections, as `Disclosure` elements each given an `id`. */
13
+ readonly children?: ReactNode;
14
+ /** The keys of the sections open at first, when the group keeps its own. */
15
+ readonly defaultExpandedKeys?: Iterable<Key>;
16
+ /**
17
+ * Whether a rule is drawn between the sections. There is never one above
18
+ * the first or below the last.
19
+ * @default true
20
+ */
21
+ readonly divided?: boolean;
22
+ /** The keys of the open sections, when the call site holds them. */
23
+ readonly expandedKeys?: Iterable<Key>;
24
+ /**
25
+ * Keeps every section from opening or closing, and draws their headers
26
+ * disabled.
27
+ * @default false
28
+ */
29
+ readonly isDisabled?: boolean;
30
+ /** Called with the keys of the open sections as one opens or closes. */
31
+ readonly onExpandedChange?: (keys: Set<Key>) => void;
32
+ readonly ref?: Ref<ComponentRef<typeof View>>;
33
+ readonly style?: StyleProp<ViewStyle>;
34
+ readonly testID?: string;
35
+ };
36
+ /**
37
+ * A stack of `Disclosure` sections that agree about what is open. Pass
38
+ * `expandedKeys` with `onExpandedChange` to hold which are open, or
39
+ * `defaultExpandedKeys` to let the group keep its own.
40
+ *
41
+ * ```tsx
42
+ * <DisclosureGroup defaultExpandedKeys={FIRST}>
43
+ * <Disclosure id="first">
44
+ * <Disclosure.Header>Headline</Disclosure.Header>
45
+ * <Disclosure.Panel>
46
+ * <Text>Supporting line</Text>
47
+ * </Disclosure.Panel>
48
+ * </Disclosure>
49
+ * </DisclosureGroup>
50
+ * ```
51
+ *
52
+ * One section opens at a time unless `allowsMultipleExpanded` says otherwise.
53
+ * Give every section an `id`, which is the key the group reports.
54
+ *
55
+ * `style`, `ref` and `testID` land on the group's own view, the one a layout
56
+ * positions.
57
+ */
58
+ declare function DisclosureGroup({ allowsMultipleExpanded, children, defaultExpandedKeys, divided, expandedKeys, isDisabled, onExpandedChange, ref, style, testID }: DisclosureGroupProps): import("react").JSX.Element;
59
+ //#endregion
60
+ export { DisclosureGroup, type DisclosureGroupProps };
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,100 @@
1
+ import { DisclosureGroupStateContext } from "../../disclosure/index.js";
2
+ import { Separator } from "../separator/index.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { View } from "react-native";
5
+ import { Children, Fragment, isValidElement } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useDisclosureGroupState } from "react-stately/useDisclosureGroupState";
8
+ //#region src/components/disclosure-group/index.tsx
9
+ /**
10
+ * A stack of `Disclosure` sections that agree about what is open. Pass
11
+ * `expandedKeys` with `onExpandedChange` to hold which are open, or
12
+ * `defaultExpandedKeys` to let the group keep its own.
13
+ *
14
+ * ```tsx
15
+ * <DisclosureGroup defaultExpandedKeys={FIRST}>
16
+ * <Disclosure id="first">
17
+ * <Disclosure.Header>Headline</Disclosure.Header>
18
+ * <Disclosure.Panel>
19
+ * <Text>Supporting line</Text>
20
+ * </Disclosure.Panel>
21
+ * </Disclosure>
22
+ * </DisclosureGroup>
23
+ * ```
24
+ *
25
+ * One section opens at a time unless `allowsMultipleExpanded` says otherwise.
26
+ * Give every section an `id`, which is the key the group reports.
27
+ *
28
+ * `style`, `ref` and `testID` land on the group's own view, the one a layout
29
+ * positions.
30
+ */
31
+ function DisclosureGroup(t0) {
32
+ const $ = c(17);
33
+ const { allowsMultipleExpanded, children, defaultExpandedKeys, divided: t1, expandedKeys, isDisabled, onExpandedChange, ref, style, testID } = t0;
34
+ const divided = t1 === void 0 ? true : t1;
35
+ let t2;
36
+ if ($[0] !== allowsMultipleExpanded || $[1] !== defaultExpandedKeys || $[2] !== expandedKeys || $[3] !== isDisabled || $[4] !== onExpandedChange) {
37
+ t2 = {
38
+ allowsMultipleExpanded,
39
+ defaultExpandedKeys,
40
+ expandedKeys,
41
+ isDisabled,
42
+ onExpandedChange
43
+ };
44
+ $[0] = allowsMultipleExpanded;
45
+ $[1] = defaultExpandedKeys;
46
+ $[2] = expandedKeys;
47
+ $[3] = isDisabled;
48
+ $[4] = onExpandedChange;
49
+ $[5] = t2;
50
+ } else t2 = $[5];
51
+ const state = useDisclosureGroupState(t2);
52
+ let t3;
53
+ if ($[6] !== children || $[7] !== divided) {
54
+ t3 = divided ? dividedChildren(children) : children;
55
+ $[6] = children;
56
+ $[7] = divided;
57
+ $[8] = t3;
58
+ } else t3 = $[8];
59
+ let t4;
60
+ if ($[9] !== ref || $[10] !== style || $[11] !== t3 || $[12] !== testID) {
61
+ t4 = /* @__PURE__ */ jsx(View, {
62
+ ref,
63
+ style,
64
+ testID,
65
+ children: t3
66
+ });
67
+ $[9] = ref;
68
+ $[10] = style;
69
+ $[11] = t3;
70
+ $[12] = testID;
71
+ $[13] = t4;
72
+ } else t4 = $[13];
73
+ let t5;
74
+ if ($[14] !== state || $[15] !== t4) {
75
+ t5 = /* @__PURE__ */ jsx(DisclosureGroupStateContext, {
76
+ value: state,
77
+ children: t4
78
+ });
79
+ $[14] = state;
80
+ $[15] = t4;
81
+ $[16] = t5;
82
+ } else t5 = $[16];
83
+ return t5;
84
+ }
85
+ function dividedChildren(children) {
86
+ return flatten(children).map((section, index) => /* @__PURE__ */ jsxs(Fragment, { children: [index === 0 ? null : /* @__PURE__ */ jsx(Separator, {}), section] }, keyOf(section, index)));
87
+ }
88
+ function flatten(children) {
89
+ return Children.toArray(children).flatMap((child) => {
90
+ if (isValidElement(child) && child.type === Fragment) return flatten(child.props.children);
91
+ return [child];
92
+ });
93
+ }
94
+ function keyOf(section, index) {
95
+ return isValidElement(section) && section.key !== null ? section.key : String(index);
96
+ }
97
+ //#endregion
98
+ export { DisclosureGroup };
99
+
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","StyleProp","ViewStyle","Key","Children","Fragment","isValidElement","View","useDisclosureGroupState","DisclosureGroupStateContext","Separator","DisclosureGroupProps","allowsMultipleExpanded","children","defaultExpandedKeys","Iterable","divided","expandedKeys","isDisabled","onExpandedChange","keys","Set","ref","style","testID","DisclosureGroup","t0","$","_c","t1","undefined","t2","state","t3","dividedChildren","t4","t5","flatten","map","section","index","keyOf","toArray","flatMap","child","type","props","key","String","_c"],"sources":["../../../src/components/disclosure-group/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type { StyleProp, ViewStyle } from 'react-native'\nimport type { Key } from 'react-stately'\n\nimport { Children, Fragment, isValidElement } from 'react'\nimport { View } from 'react-native'\nimport { useDisclosureGroupState } from 'react-stately/useDisclosureGroupState'\n\nimport { DisclosureGroupStateContext } from '../../disclosure'\nimport { Separator } from '../separator'\n\n// kanso-ui's DisclosureGroup: a stack of Disclosures that agree with each\n// other about what is open, the lists page's accordion. The sections are the\n// library's own `Disclosure`, unchanged: this adds only the agreement between\n// them and the rule that divides them.\n//\n// Give each section an `id`, which is the key the group reports as expanded.\n// Whether one opens at a time or several is `allowsMultipleExpanded`, and the\n// keys are React Stately's `useDisclosureGroupState`, the state web's React\n// Aria keeps, handed to the sections through context.\n//\n// **A rule between the sections, and none at the ends.** The group draws the\n// library's `Separator` between each pair rather than asking each section to\n// draw a border, so a section drawn on its own and a section in a group stay\n// the same component. `divided={false}` leaves them undivided, for a stack\n// sitting on cards of its own.\n//\n// **Nothing else is added.** The group draws no container, no corner and no\n// colour: an accordion inside a card and one running down a screen want\n// different surroundings, and the screen is what knows which it is.\n\ntype DisclosureGroupProps = {\n /**\n * Whether several sections may be open at once. Otherwise opening one\n * closes the one that was open.\n * @default false\n */\n readonly allowsMultipleExpanded?: boolean\n /** The sections, as `Disclosure` elements each given an `id`. */\n readonly children?: ReactNode\n /** The keys of the sections open at first, when the group keeps its own. */\n readonly defaultExpandedKeys?: Iterable<Key>\n /**\n * Whether a rule is drawn between the sections. There is never one above\n * the first or below the last.\n * @default true\n */\n readonly divided?: boolean\n /** The keys of the open sections, when the call site holds them. */\n readonly expandedKeys?: Iterable<Key>\n /**\n * Keeps every section from opening or closing, and draws their headers\n * disabled.\n * @default false\n */\n readonly isDisabled?: boolean\n /** Called with the keys of the open sections as one opens or closes. */\n readonly onExpandedChange?: (keys: Set<Key>) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\n/**\n * A stack of `Disclosure` sections that agree about what is open. Pass\n * `expandedKeys` with `onExpandedChange` to hold which are open, or\n * `defaultExpandedKeys` to let the group keep its own.\n *\n * ```tsx\n * <DisclosureGroup defaultExpandedKeys={FIRST}>\n * <Disclosure id=\"first\">\n * <Disclosure.Header>Headline</Disclosure.Header>\n * <Disclosure.Panel>\n * <Text>Supporting line</Text>\n * </Disclosure.Panel>\n * </Disclosure>\n * </DisclosureGroup>\n * ```\n *\n * One section opens at a time unless `allowsMultipleExpanded` says otherwise.\n * Give every section an `id`, which is the key the group reports.\n *\n * `style`, `ref` and `testID` land on the group's own view, the one a layout\n * positions.\n */\nfunction DisclosureGroup({\n allowsMultipleExpanded,\n children,\n defaultExpandedKeys,\n divided = true,\n expandedKeys,\n isDisabled,\n onExpandedChange,\n ref,\n style,\n testID,\n}: DisclosureGroupProps) {\n const state = useDisclosureGroupState({\n allowsMultipleExpanded,\n defaultExpandedKeys,\n expandedKeys,\n isDisabled,\n onExpandedChange,\n })\n\n return (\n <DisclosureGroupStateContext value={state}>\n <View ref={ref} style={style} testID={testID}>\n {divided ? dividedChildren(children) : children}\n </View>\n </DisclosureGroupStateContext>\n )\n}\n\n// The sections with a rule between each pair, and none at the ends.\nfunction dividedChildren(children: ReactNode) {\n return flatten(children).map((section, index) => (\n <Fragment key={keyOf(section, index)}>\n {index === 0 ? null : <Separator />}\n {section}\n </Fragment>\n ))\n}\n\n// The sections, with any fragment around them opened up first.\n// `Children.toArray` flattens arrays but hands back a fragment as one child,\n// and a call site that writes its sections inside one, or maps over data and\n// wraps the result, would otherwise get a single entry and no rules at all.\n// Recursive, since a fragment may hold another.\nfunction flatten(children: ReactNode): ReactNode[] {\n return Children.toArray(children).flatMap((child) => {\n if (\n isValidElement<{ children?: ReactNode }>(child) &&\n child.type === Fragment\n ) {\n return flatten(child.props.children)\n }\n return [child]\n })\n}\n\n// The key `Children.toArray` put on each element, or the entry's position for\n// anything that is not one.\nfunction keyOf(section: ReactNode, index: number) {\n return isValidElement(section) && section.key !== null\n ? section.key\n : String(index)\n}\n\nexport { DisclosureGroup }\nexport type { DisclosureGroupProps }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAA2B,gBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAyB,MAAA,EAAAhB,wBAAAC,UAAAC,qBAAAE,SAAAa,IAAAZ,cAAAC,YAAAC,kBAAAG,KAAAC,OAAAC,WAAAE;CAIvB,MAAAV,UAAAa,OAAAC,KAAAA,IAAA,OAAAD;CAAc,IAAAE;CAAA,IAAAJ,EAAA,OAAAf,0BAAAe,EAAA,OAAAb,uBAAAa,EAAA,OAAAV,gBAAAU,EAAA,OAAAT,cAAAS,EAAA,OAAAR,kBAAA;EAQwBY,KAAA;GAAAnB;GAAAE;GAAAG;GAAAC;GAAAC;EAMtC;EAACQ,EAAA,KAAAf;EAAAe,EAAA,KAAAb;EAAAa,EAAA,KAAAV;EAAAU,EAAA,KAAAT;EAAAS,EAAA,KAAAR;EAAAQ,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAND,MAAAK,QAAcxB,wBAAwBuB,EAMrC;CAAC,IAAAE;CAAA,IAAAN,EAAA,OAAAd,YAAAc,EAAA,OAAAX,SAAA;EAKKiB,KAAAjB,UAAUkB,gBAAgBrB,QAAm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C,OAAOR,KAAK;AAClB"}
@@ -0,0 +1,113 @@
1
+ import { PickedFile } from "../../files/index.js";
2
+ import { DragTypes, DropEnterEvent, DropEvent, DropExitEvent, DropOperation } from "../../drop/index.js";
3
+ import { StyleProp, View, ViewStyle } from "react-native";
4
+ import { ComponentRef, ReactNode, Ref } from "react";
5
+ //#region src/components/drop-zone/index.d.ts
6
+ type DropZoneProps = {
7
+ /**
8
+ * Names the target without drawing anything, for a page that already says
9
+ * what it takes. Beats `label` as the name.
10
+ */
11
+ readonly 'aria-label'?: string;
12
+ /** What the target holds beside its label, such as a FileTrigger. */
13
+ readonly children?: ReactNode;
14
+ /**
15
+ * What a drop of these types would do, from the operations the drag
16
+ * allows: `cancel` refuses it. A pick on iOS and Android allows `copy`
17
+ * alone. Left out, the first the drag allows.
18
+ */
19
+ readonly getDropOperation?: (types: DragTypes, allowedOperations: readonly DropOperation[]) => DropOperation;
20
+ /**
21
+ * Takes nothing: no drop, and on iOS and Android no press, drawn faded.
22
+ * @default false
23
+ */
24
+ readonly isDisabled?: boolean;
25
+ /**
26
+ * What the target says it is for, drawn inside it and used as its name. A
27
+ * string rather than a node, since it is what names the target; anything
28
+ * richer goes in `children`.
29
+ */
30
+ readonly label?: string;
31
+ /**
32
+ * Called with what landed: what was dropped under React Native Web, what
33
+ * was picked on iOS and Android.
34
+ */
35
+ readonly onDrop?: (event: DropEvent) => void;
36
+ /** Called once something the target takes comes over it. Under React Native Web alone. */
37
+ readonly onDropEnter?: (event: DropEnterEvent) => void;
38
+ /** Called once what came over it leaves, or lands. Under React Native Web alone. */
39
+ readonly onDropExit?: (event: DropExitEvent) => void;
40
+ readonly ref?: Ref<ComponentRef<typeof View>>;
41
+ readonly style?: StyleProp<ViewStyle>;
42
+ readonly testID?: string;
43
+ };
44
+ type FileTriggerProps = {
45
+ /** The MIME types the chooser offers, such as `image/png` or `image/*`. Every type when left out. */
46
+ readonly acceptedFileTypes?: readonly string[];
47
+ /** Whether more than one file can be picked. @default false */
48
+ readonly allowsMultiple?: boolean;
49
+ /** The Button, IconButton, Fab or Chip that opens the chooser. */
50
+ readonly children?: ReactNode;
51
+ /**
52
+ * Opens the camera rather than the chooser, facing away from the person
53
+ * for `environment` or towards them for `user`, as web's `capture` does.
54
+ * It takes one photo, or a video where `acceptedFileTypes` names a video
55
+ * type.
56
+ */
57
+ readonly defaultCamera?: 'environment' | 'user';
58
+ /** Called with what was picked. Not called when the person backs out. */
59
+ readonly onSelect?: (files: readonly PickedFile[]) => void;
60
+ };
61
+ /**
62
+ * A place to drop files. Under React Native Web it takes HTML5 drag and drop,
63
+ * as kanso-ui's does; on iOS and Android, which hand an app no drag from
64
+ * another, pressing it opens the file chooser, and `onDrop` is handed what
65
+ * was picked. Either way `onDrop` is handed the items, which
66
+ * `isFileDropItem` and `isTextDropItem` pick apart.
67
+ *
68
+ * ```tsx
69
+ * <DropZone label="Drop here" onDrop={handleDrop}>
70
+ * <FileTrigger onSelect={handleSelect}>
71
+ * <Button variant="outlined">Label</Button>
72
+ * </FileTrigger>
73
+ * </DropZone>
74
+ * ```
75
+ *
76
+ * It is drawn from the outlined card, with a dashed rule rather than a solid
77
+ * one, and fills with the primary container while something is over it.
78
+ * `label` both draws the words and names the target; `aria-label` names it
79
+ * without drawing anything.
80
+ *
81
+ * The chooser is expo-document-picker's, which an app installs alongside the
82
+ * library. Without it a press writes to the console that the package is
83
+ * missing, and nothing opens.
84
+ *
85
+ * `style`, `ref` and `testID` land on the target itself, which is what a
86
+ * layout places.
87
+ */
88
+ declare function DropZone({ 'aria-label': ariaLabel, children, getDropOperation, isDisabled, label, onDrop, onDropEnter, onDropExit, ref, style, testID }: DropZoneProps): import("react").JSX.Element;
89
+ /**
90
+ * Opens the file chooser from the button it wraps, and hands `onSelect`
91
+ * what was picked.
92
+ *
93
+ * ```tsx
94
+ * <FileTrigger acceptedFileTypes={['image/*']} onSelect={handleSelect}>
95
+ * <Button>Label</Button>
96
+ * </FileTrigger>
97
+ * ```
98
+ *
99
+ * It renders nothing of its own, so it takes no `style`: what is seen is the
100
+ * Button, IconButton, Fab or Chip it wraps, which opens the chooser after its
101
+ * own `onPress`. `allowsMultiple` takes more than one file, and `defaultCamera`
102
+ * opens the camera instead. kanso-ui's `acceptDirectory` is not here, since
103
+ * neither iOS's chooser nor Android's picks a folder.
104
+ *
105
+ * The chooser is expo-document-picker's and the camera expo-image-picker's,
106
+ * which an app installs alongside the library, the second only for
107
+ * `defaultCamera`. Without the one it needs, a press writes to the console
108
+ * which package is missing, and nothing opens.
109
+ */
110
+ declare function FileTrigger({ acceptedFileTypes, allowsMultiple, children, defaultCamera, onSelect }: FileTriggerProps): import("react").JSX.Element;
111
+ //#endregion
112
+ export { DropZone, type DropZoneProps, FileTrigger, type FileTriggerProps };
113
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,304 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { usePressFeedback } from "../../press/index.js";
4
+ import { useTypeRole } from "../../typography/roles.js";
5
+ import { withOpacity } from "../../theme/color.js";
6
+ import { refsOf } from "../../ref/index.js";
7
+ import { ButtonSlotContext } from "../../button/slots.js";
8
+ import { fileItemOf, isDropTarget, operationOf, typesOf, watchDrops } from "../../drop/index.js";
9
+ import { pickThen, preparePicker } from "../../files/index.js";
10
+ import { c } from "react/compiler-runtime";
11
+ import { Platform, Pressable, StyleSheet, Text, View } from "react-native";
12
+ import { useEffect, useEffectEvent, useRef, useState } from "react";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ //#region src/components/drop-zone/index.tsx
15
+ const MIN_HEIGHT = 160;
16
+ const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) => {
17
+ const disabled = withOpacity(colors.onSurface, stateLayerOpacity.disabledContent);
18
+ return StyleSheet.create({
19
+ label: {
20
+ color: colors.onSurfaceVariant,
21
+ textAlign: "center"
22
+ },
23
+ labelBox: { pointerEvents: "none" },
24
+ labelDisabled: { color: disabled },
25
+ labelOver: { color: colors.onPrimaryContainer },
26
+ press: { borderRadius: radii.md },
27
+ ring: { outlineOffset: -1 },
28
+ root: {
29
+ alignItems: "center",
30
+ backgroundColor: colors.surface,
31
+ borderColor: colors.outlineVariant,
32
+ borderRadius: radii.md,
33
+ borderStyle: "dashed",
34
+ borderWidth: 1,
35
+ boxSizing: "border-box",
36
+ gap: spacing.md,
37
+ justifyContent: "center",
38
+ minHeight: MIN_HEIGHT,
39
+ padding: spacing.xl
40
+ },
41
+ rootDisabled: { borderColor: disabled },
42
+ rootOver: {
43
+ backgroundColor: colors.primaryContainer,
44
+ borderColor: colors.primary,
45
+ borderStyle: "solid"
46
+ }
47
+ });
48
+ });
49
+ /**
50
+ * A place to drop files. Under React Native Web it takes HTML5 drag and drop,
51
+ * as kanso-ui's does; on iOS and Android, which hand an app no drag from
52
+ * another, pressing it opens the file chooser, and `onDrop` is handed what
53
+ * was picked. Either way `onDrop` is handed the items, which
54
+ * `isFileDropItem` and `isTextDropItem` pick apart.
55
+ *
56
+ * ```tsx
57
+ * <DropZone label="Drop here" onDrop={handleDrop}>
58
+ * <FileTrigger onSelect={handleSelect}>
59
+ * <Button variant="outlined">Label</Button>
60
+ * </FileTrigger>
61
+ * </DropZone>
62
+ * ```
63
+ *
64
+ * It is drawn from the outlined card, with a dashed rule rather than a solid
65
+ * one, and fills with the primary container while something is over it.
66
+ * `label` both draws the words and names the target; `aria-label` names it
67
+ * without drawing anything.
68
+ *
69
+ * The chooser is expo-document-picker's, which an app installs alongside the
70
+ * library. Without it a press writes to the console that the package is
71
+ * missing, and nothing opens.
72
+ *
73
+ * `style`, `ref` and `testID` land on the target itself, which is what a
74
+ * layout places.
75
+ */
76
+ function DropZone(t0) {
77
+ const $ = c(30);
78
+ const { "aria-label": ariaLabel, children, getDropOperation, isDisabled: t1, label, onDrop, onDropEnter, onDropExit, ref, style, testID } = t0;
79
+ const isDisabled = t1 === void 0 ? false : t1;
80
+ const theme = useTheme();
81
+ const { colors, radii } = theme;
82
+ const styles = stylesOf(theme);
83
+ const bodyMedium = useTypeRole("bodyMedium");
84
+ const [isOver, setOver] = useState(false);
85
+ const node = useRef(null);
86
+ const web = Platform.OS === "web";
87
+ let t2;
88
+ if ($[0] !== radii.md) {
89
+ t2 = { borderRadius: radii.md };
90
+ $[0] = radii.md;
91
+ $[1] = t2;
92
+ } else t2 = $[1];
93
+ let t3;
94
+ if ($[2] !== colors.onSurface || $[3] !== isDisabled || $[4] !== t2) {
95
+ t3 = {
96
+ color: colors.onSurface,
97
+ corners: t2,
98
+ disabled: isDisabled
99
+ };
100
+ $[2] = colors.onSurface;
101
+ $[3] = isDisabled;
102
+ $[4] = t2;
103
+ $[5] = t3;
104
+ } else t3 = $[5];
105
+ const feedback = usePressFeedback(t3);
106
+ let t4;
107
+ if ($[6] !== getDropOperation || $[7] !== onDrop || $[8] !== onDropEnter || $[9] !== onDropExit) {
108
+ t4 = () => ({
109
+ getDropOperation,
110
+ onDrop,
111
+ onDropEnter,
112
+ onDropExit
113
+ });
114
+ $[6] = getDropOperation;
115
+ $[7] = onDrop;
116
+ $[8] = onDropEnter;
117
+ $[9] = onDropExit;
118
+ $[10] = t4;
119
+ } else t4 = $[10];
120
+ const handlersNow = useEffectEvent(t4);
121
+ let t5;
122
+ if ($[11] !== isDisabled) {
123
+ t5 = () => isDisabled;
124
+ $[11] = isDisabled;
125
+ $[12] = t5;
126
+ } else t5 = $[12];
127
+ const disabledNow = useEffectEvent(t5);
128
+ const name = ariaLabel ?? label;
129
+ const over = isOver && !isDisabled;
130
+ let t6;
131
+ if ($[13] !== disabledNow || $[14] !== handlersNow) {
132
+ t6 = () => {
133
+ if (!web) {
134
+ preparePicker({});
135
+ return;
136
+ }
137
+ const target = node.current;
138
+ if (!isDropTarget(target)) return;
139
+ return watchDrops(target, () => handlersNow(), () => disabledNow(), setOver);
140
+ };
141
+ $[13] = disabledNow;
142
+ $[14] = handlersNow;
143
+ $[15] = t6;
144
+ } else t6 = $[15];
145
+ let t7;
146
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
147
+ t7 = [web];
148
+ $[16] = t7;
149
+ } else t7 = $[16];
150
+ useEffect(t6, t7);
151
+ const T0 = View;
152
+ const t8 = web && isDisabled ? true : void 0;
153
+ const t9 = web ? name : void 0;
154
+ let t10;
155
+ if ($[17] !== ref) {
156
+ t10 = refsOf(ref, node);
157
+ $[17] = ref;
158
+ $[18] = t10;
159
+ } else t10 = $[18];
160
+ const t11 = web && name !== void 0 ? "group" : void 0;
161
+ const t12 = composeStyles(styles.root, over ? styles.rootOver : void 0, isDisabled ? styles.rootDisabled : void 0, style);
162
+ const t13 = web ? null : /* @__PURE__ */ jsx(Pressable, {
163
+ ...feedback.handlers,
164
+ "aria-label": name,
165
+ disabled: isDisabled,
166
+ onPress: pressOf(getDropOperation, onDrop),
167
+ role: "button",
168
+ style: composeStyles(StyleSheet.absoluteFill, styles.press, feedback.ring, feedback.ring === void 0 ? void 0 : styles.ring),
169
+ children: feedback.layer
170
+ });
171
+ const t14 = label === void 0 ? null : /* @__PURE__ */ jsx(View, {
172
+ "aria-hidden": true,
173
+ style: styles.labelBox,
174
+ children: /* @__PURE__ */ jsx(Text, {
175
+ style: composeStyles(bodyMedium, styles.label, over ? styles.labelOver : void 0, isDisabled ? styles.labelDisabled : void 0),
176
+ children: label
177
+ })
178
+ });
179
+ let t15;
180
+ if ($[19] !== T0 || $[20] !== children || $[21] !== t10 || $[22] !== t11 || $[23] !== t12 || $[24] !== t13 || $[25] !== t14 || $[26] !== t8 || $[27] !== t9 || $[28] !== testID) {
181
+ t15 = /* @__PURE__ */ jsxs(T0, {
182
+ "aria-disabled": t8,
183
+ "aria-label": t9,
184
+ ref: t10,
185
+ role: t11,
186
+ style: t12,
187
+ testID,
188
+ children: [
189
+ t13,
190
+ t14,
191
+ children
192
+ ]
193
+ });
194
+ $[19] = T0;
195
+ $[20] = children;
196
+ $[21] = t10;
197
+ $[22] = t11;
198
+ $[23] = t12;
199
+ $[24] = t13;
200
+ $[25] = t14;
201
+ $[26] = t8;
202
+ $[27] = t9;
203
+ $[28] = testID;
204
+ $[29] = t15;
205
+ } else t15 = $[29];
206
+ return t15;
207
+ }
208
+ /**
209
+ * Opens the file chooser from the button it wraps, and hands `onSelect`
210
+ * what was picked.
211
+ *
212
+ * ```tsx
213
+ * <FileTrigger acceptedFileTypes={['image/*']} onSelect={handleSelect}>
214
+ * <Button>Label</Button>
215
+ * </FileTrigger>
216
+ * ```
217
+ *
218
+ * It renders nothing of its own, so it takes no `style`: what is seen is the
219
+ * Button, IconButton, Fab or Chip it wraps, which opens the chooser after its
220
+ * own `onPress`. `allowsMultiple` takes more than one file, and `defaultCamera`
221
+ * opens the camera instead. kanso-ui's `acceptDirectory` is not here, since
222
+ * neither iOS's chooser nor Android's picks a folder.
223
+ *
224
+ * The chooser is expo-document-picker's and the camera expo-image-picker's,
225
+ * which an app installs alongside the library, the second only for
226
+ * `defaultCamera`. Without the one it needs, a press writes to the console
227
+ * which package is missing, and nothing opens.
228
+ */
229
+ function FileTrigger(t0) {
230
+ const $ = c(13);
231
+ const { acceptedFileTypes, allowsMultiple, children, defaultCamera, onSelect } = t0;
232
+ let t1;
233
+ let t2;
234
+ if ($[0] !== defaultCamera) {
235
+ t1 = () => {
236
+ preparePicker({ defaultCamera });
237
+ };
238
+ t2 = [defaultCamera];
239
+ $[0] = defaultCamera;
240
+ $[1] = t1;
241
+ $[2] = t2;
242
+ } else {
243
+ t1 = $[1];
244
+ t2 = $[2];
245
+ }
246
+ useEffect(t1, t2);
247
+ let t3;
248
+ if ($[3] !== acceptedFileTypes || $[4] !== allowsMultiple || $[5] !== defaultCamera || $[6] !== onSelect) {
249
+ t3 = () => {
250
+ pickThen({
251
+ acceptedFileTypes,
252
+ allowsMultiple,
253
+ defaultCamera
254
+ }, (files) => {
255
+ onSelect?.(files);
256
+ });
257
+ };
258
+ $[3] = acceptedFileTypes;
259
+ $[4] = allowsMultiple;
260
+ $[5] = defaultCamera;
261
+ $[6] = onSelect;
262
+ $[7] = t3;
263
+ } else t3 = $[7];
264
+ const pick = t3;
265
+ let t4;
266
+ if ($[8] !== pick) {
267
+ t4 = slotsOf(pick);
268
+ $[8] = pick;
269
+ $[9] = t4;
270
+ } else t4 = $[9];
271
+ let t5;
272
+ if ($[10] !== children || $[11] !== t4) {
273
+ t5 = /* @__PURE__ */ jsx(ButtonSlotContext, {
274
+ value: t4,
275
+ children
276
+ });
277
+ $[10] = children;
278
+ $[11] = t4;
279
+ $[12] = t5;
280
+ } else t5 = $[12];
281
+ return t5;
282
+ }
283
+ function pressOf(getDropOperation, onDrop) {
284
+ return (event) => {
285
+ const { locationX: x, locationY: y } = event.nativeEvent;
286
+ pickThen({ allowsMultiple: true }, (files) => {
287
+ const dropOperation = operationOf({ getDropOperation }, typesOf(files.map((file) => file.type)), ["copy"]);
288
+ if (dropOperation !== "cancel") onDrop?.({
289
+ dropOperation,
290
+ items: files.map(fileItemOf),
291
+ type: "drop",
292
+ x,
293
+ y
294
+ });
295
+ });
296
+ };
297
+ }
298
+ function slotsOf(pick) {
299
+ return { default: pick };
300
+ }
301
+ //#endregion
302
+ export { DropZone, FileTrigger };
303
+
304
+ //# sourceMappingURL=index.js.map