@kanso-labs/react-native-kanso-ui 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/autocomplete/index.js +15 -1
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/button/group.d.ts +5 -0
- package/dist/button/group.js +115 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/index.d.ts +4 -1
- package/dist/button/index.js +44 -22
- package/dist/button/index.js.map +1 -1
- package/dist/button/slots.js +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/calendar/index.js +351 -182
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +33 -2
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/chequer/index.js +95 -0
- package/dist/chequer/index.js.map +1 -0
- package/dist/collection/index.d.ts +157 -0
- package/dist/collection/index.js +1358 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/color-thumb/index.js +56 -0
- package/dist/color-thumb/index.js.map +1 -0
- package/dist/components/button/index.d.ts +4 -2
- package/dist/components/button/index.js +227 -188
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +87 -0
- package/dist/components/button-group/index.js +275 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +11 -3
- package/dist/components/calendar/index.js +60 -45
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +72 -0
- package/dist/components/carousel/index.js +496 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/checkbox-group/index.d.ts +3 -4
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +4 -1
- package/dist/components/chip/index.js +229 -161
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +85 -0
- package/dist/components/color-area/index.js +630 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-field/index.d.ts +144 -0
- package/dist/components/color-field/index.js +516 -0
- package/dist/components/color-field/index.js.map +1 -0
- package/dist/components/color-picker/index.d.ts +74 -0
- package/dist/components/color-picker/index.js +317 -0
- package/dist/components/color-picker/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +82 -0
- package/dist/components/color-slider/index.js +456 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +46 -0
- package/dist/components/color-swatch/index.js +127 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +81 -0
- package/dist/components/color-swatch-picker/index.js +287 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/color-wheel/index.d.ts +71 -0
- package/dist/components/color-wheel/index.js +407 -0
- package/dist/components/color-wheel/index.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +193 -0
- package/dist/components/combo-box/index.js +616 -0
- package/dist/components/combo-box/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +120 -0
- package/dist/components/date-field/index.js +111 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +130 -0
- package/dist/components/date-picker/index.js +310 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +139 -0
- package/dist/components/date-range-picker/index.js +421 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/dialog/index.d.ts +5 -5
- package/dist/components/dialog/index.js +5 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +94 -0
- package/dist/components/disclosure/index.js +365 -0
- package/dist/components/disclosure/index.js.map +1 -0
- package/dist/components/disclosure-group/index.d.ts +61 -0
- package/dist/components/disclosure-group/index.js +100 -0
- package/dist/components/disclosure-group/index.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +113 -0
- package/dist/components/drop-zone/index.js +304 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js +91 -76
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +4 -2
- package/dist/components/icon-button/index.js +204 -171
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.d.ts +15 -158
- package/dist/components/list/index.js +21 -1047
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +73 -0
- package/dist/components/list-box/index.js +82 -0
- package/dist/components/list-box/index.js.map +1 -0
- package/dist/components/loading-indicator/index.d.ts +32 -0
- package/dist/components/loading-indicator/index.js +174 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +117 -0
- package/dist/components/navigation-tree/index.js +135 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/number-field/index.js +132 -143
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +69 -0
- package/dist/components/range-calendar/index.js +144 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/search-view/index.d.ts +79 -0
- package/dist/components/search-view/index.js +571 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/select/index.d.ts +152 -0
- package/dist/components/select/index.js +419 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/sheet/index.d.ts +16 -7
- package/dist/components/sheet/index.js +157 -152
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +111 -0
- package/dist/components/slider/index.js +673 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/split-button/index.d.ts +77 -0
- package/dist/components/split-button/index.js +354 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/table/index.d.ts +391 -0
- package/dist/components/table/index.js +1708 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +196 -0
- package/dist/components/tabs/index.js +1137 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +43 -0
- package/dist/components/time-field/index.js +107 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-picker/index.d.ts +65 -0
- package/dist/components/time-picker/index.js +1168 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/token-field/index.d.ts +105 -0
- package/dist/components/token-field/index.js +574 -0
- package/dist/components/token-field/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +102 -0
- package/dist/components/tooltip/index.js +223 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +112 -0
- package/dist/components/tree/index.js +157 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/disclosure/chevron.js +75 -0
- package/dist/disclosure/chevron.js.map +1 -0
- package/dist/disclosure/index.js +7 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/drop/index.d.ts +54 -0
- package/dist/drop/index.js +161 -0
- package/dist/drop/index.js.map +1 -0
- package/dist/field/chevron.js +74 -0
- package/dist/field/chevron.js.map +1 -0
- package/dist/field/index.d.ts +2 -1
- package/dist/field/index.js +359 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/files/index.d.ts +18 -0
- package/dist/files/index.js +107 -0
- package/dist/files/index.js.map +1 -0
- package/dist/form/index.d.ts +5 -2
- package/dist/form/index.js +64 -85
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/index.js +128 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +36 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1734 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +37 -3
- package/dist/index.js +36 -3
- package/dist/indicator/paths.js +23 -1
- package/dist/indicator/paths.js.map +1 -1
- package/dist/modal/index.js +92 -77
- package/dist/modal/index.js.map +1 -1
- package/dist/number/keyboard.js +16 -0
- package/dist/number/keyboard.js.map +1 -0
- package/dist/overlay/anchored.js +68 -38
- package/dist/overlay/anchored.js.map +1 -1
- package/dist/overlay/keyboard.js +57 -0
- package/dist/overlay/keyboard.js.map +1 -0
- package/dist/overlay/panel.js +173 -19
- package/dist/overlay/panel.js.map +1 -1
- package/dist/overlay/placement.js +13 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/picker/index.js +322 -0
- package/dist/picker/index.js.map +1 -0
- package/dist/press/index.d.ts +2 -0
- package/dist/press/index.js +102 -100
- package/dist/press/index.js.map +1 -1
- package/dist/row/index.js +77 -69
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +13 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/field.js +277 -0
- package/dist/segments/field.js.map +1 -0
- package/dist/segments/index.js +574 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +24 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/slider/index.js +145 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/swatch/index.js +56 -0
- package/dist/swatch/index.js.map +1 -0
- package/package.json +11 -2
package/dist/row/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","StyleProp","TextStyle","ViewStyle","useMemo","Text","NativeText","View","IconStyle","ResolvedTheme","RowVariant","IconStyleContext","useTheme","composeStyles","useTypeRole","rowContentColor","rowStyles","rowStylesOf","ICON_SIZE","RowContentProps","children","isDisabled","isSelected","leading","overline","supporting","trailing","variant","hasContent","node","undefined","RowContent","t0","$","_c","t1","t2","t3","theme","own","headlineRole","overlineRole","supportingRole","t4","color","t5","size","icons","tone","muted","T0","t6","slot","T1","t7","main","t8","t9","t10","t11","t12","t13","t14","rowStyleOf","Pick","lines","base","twoLine","threeLine","_c","NativeText"],"sources":["../../src/row/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { StyleProp, TextStyle, ViewStyle } from 'react-native'\n\nimport { useMemo } from 'react'\nimport { Text as NativeText, View } from 'react-native'\n\nimport type { IconStyle } from '../glyphs/icon-style'\nimport type { ResolvedTheme } from '../theme/scope'\nimport type { RowVariant } from './styles'\n\nimport { IconStyleContext } from '../glyphs/icon-style'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { rowContentColor, rowStyles, rowStylesOf } from './styles'\n\n// The size an icon in either slot is drawn at, the lists and menus pages'.\nconst ICON_SIZE = 24\n\ntype RowContentProps = {\n /** The row's headline, the one thing it is mostly about. */\n readonly children?: ReactNode\n /**\n * Whether the row is disabled. Its headline, slots and lines take the\n * faded on-surface colour, the supporting line included.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Whether the row is selected. Its headline, slots and lines take the\n * selected container's own on-colour, since the muted role is not\n * guaranteed to be readable over it.\n * @default false\n */\n readonly isSelected?: boolean\n /** Content before the headline: an avatar, an icon, a checkbox. */\n readonly leading?: ReactNode\n /** A line above the headline, in label small and the muted role. */\n readonly overline?: ReactNode\n /** A second line under the headline, in body medium and the muted role. */\n readonly supporting?: ReactNode\n /** Content after the headline, such as an amount or a control. */\n readonly trailing?: ReactNode\n /**\n * Which spec page's row this is. A list item's headline is body large and\n * a menu item's label large.\n * @default 'list'\n */\n readonly variant?: RowVariant\n}\n\n/** Whether a slot was given something to draw. */\nfunction hasContent(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== ''\n}\n\n/**\n * The inside of a row: the leading slot, the headline with the lines beside\n * it, and the trailing slot, each drawn only when given. The view around it\n * is the caller's, ListItem's or a menu's item, and takes `rowStyleOf`; this\n * is what each of them puts inside it, so a list and a menu draw the same\n * row. Both slots hand an icon the row's content colour at 24dp, through\n * `useIconStyle()`. Not a component of the library's own and not exported.\n */\nfunction RowContent({\n children,\n isDisabled = false,\n isSelected = false,\n leading,\n overline,\n supporting,\n trailing,\n variant = 'list',\n}: RowContentProps) {\n const theme = useTheme()\n const own = rowStylesOf(theme)\n const headlineRole = useTypeRole(\n variant === 'menu' ? 'labelLarge' : 'bodyLarge',\n )\n const overlineRole = useTypeRole('labelSmall')\n const supportingRole = useTypeRole('bodyMedium')\n const color = rowContentColor(theme, { isDisabled, isSelected, variant })\n const icons = useMemo<IconStyle>(() => ({ color, size: ICON_SIZE }), [color])\n // The muted role on the surface; the row's own colour over a selected\n // container, and on a disabled row, which fades the lines with the rest.\n const tone = isDisabled || isSelected ? { color } : own.muted\n\n return (\n <IconStyleContext value={icons}>\n {hasContent(leading) ? (\n <View style={rowStyles.slot}>{leading}</View>\n ) : null}\n <View style={own.main}>\n {hasContent(overline) ? (\n <NativeText style={composeStyles<TextStyle>(overlineRole, tone)}>\n {overline}\n </NativeText>\n ) : null}\n <NativeText style={composeStyles<TextStyle>(headlineRole, { color })}>\n {children}\n </NativeText>\n {hasContent(supporting) ? (\n <NativeText style={composeStyles<TextStyle>(supportingRole, tone)}>\n {supporting}\n </NativeText>\n ) : null}\n </View>\n {hasContent(trailing) ? (\n <View style={rowStyles.slot}>{trailing}</View>\n ) : null}\n </IconStyleContext>\n )\n}\n\n/**\n * The style of the view around a row's content: the padding and gap, the\n * variant's height, the taller item its lines make it, and the selected\n * container. Which of the lists page's three items a row is comes from its\n * content rather than a prop, so a row holding all three lines already says\n * it is the three-line item. A line that wraps grows the shorter item and\n * keeps its slots centred.\n */\nfunction rowStyleOf(\n theme: ResolvedTheme,\n {\n isSelected = false,\n overline,\n supporting,\n variant = 'list',\n }: Pick<\n RowContentProps,\n 'isSelected' | 'overline' | 'supporting' | 'variant'\n >,\n): StyleProp<ViewStyle> {\n const own = rowStylesOf(theme)\n const lines =\n (hasContent(overline) ? 1 : 0) + (hasContent(supporting) ? 1 : 0)\n\n return composeStyles<ViewStyle>(\n own.base,\n own[variant],\n lines === 1 ? own.twoLine : undefined,\n lines === 2 ? own.threeLine : undefined,\n isSelected\n ? own[variant === 'menu' ? 'selectedMenu' : 'selectedList']\n : undefined,\n )\n}\n\nexport type { RowContentProps, RowVariant }\n\nexport { hasContent, RowContent, rowContentColor, rowStyleOf, rowStyles }\n"],"mappings":";;;;;;;;;;AAiBA,MAAMkB,YAAY;;AAmClB,SAASU,WAAWC,MAA0B;CAC5C,OAAOA,SAASC,KAAAA,KAAaD,SAAS,QAAQA,SAAS,SAASA,SAAS;AAC3E;;;;;;;;;AAUA,SAAAE,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAAd,UAAAC,YAAAc,IAAAb,YAAAc,IAAAb,SAAAC,UAAAC,YAAAC,UAAAC,SAAAU,OAAAL;CAElB,MAAAX,aAAAc,OAAAL,KAAAA,IAAA,QAAAK;CACA,MAAAb,aAAAc,OAAAN,KAAAA,IAAA,QAAAM;CAKA,MAAAT,UAAAU,OAAAP,KAAAA,IAAA,SAAAO;CAEA,MAAAC,QAAc1B,SAAS;CACvB,MAAA2B,MAAYtB,YAAYqB,KAAK;CAC7B,MAAAE,eAAqB1B,YACnBa,YAAY,SAAZ,eAAA,WACF;CACA,MAAAc,eAAqB3B,YAAY,YAAY;CAC7C,MAAA4B,iBAAuB5B,YAAY,YAAY;CAAC,IAAA6B;CAAA,IAAAV,EAAA,OAAAZ,cAAAY,EAAA,OAAAX,cAAAW,EAAA,OAAAK,SAAAL,EAAA,OAAAN,SAAA;EAClCgB,KAAA5B,gBAAgBuB,OAAO;GAAAjB;GAAAC;GAAAK;EAAkC,CAAC;EAACM,EAAA,KAAAZ;EAAAY,EAAA,KAAAX;EAAAW,EAAA,KAAAK;EAAAL,EAAA,KAAAN;EAAAM,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAzE,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,OAAOZ,cACL0B,IAAI2B,MACJ3B,IAAIZ,UACJsC,UAAU,IAAI1B,IAAI4B,UAAUrC,KAAAA,GAC5BmC,UAAU,IAAI1B,IAAI6B,YAAYtC,KAAAA,GAC9BR,aACIiB,IAAIZ,YAAY,SAAS,iBAAiB,kBAC1CG,KAAAA,CACN;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","StyleProp","TextStyle","ViewStyle","useMemo","Text","NativeText","View","IconStyle","ResolvedTheme","RowVariant","IconStyleContext","useTheme","composeStyles","nativeWeight","useTypeRole","rowContentColor","rowStyles","rowStylesOf","ICON_SIZE","SELECTED_CONTAINER","drawer","list","menu","const","Record","RowContentProps","children","isDisabled","isEmphasized","isSelected","leading","overline","supporting","trailing","variant","hasContent","node","undefined","RowContent","t0","$","_c","t1","t2","t3","t4","theme","own","headlineRole","overlineRole","supportingRole","t5","color","t6","size","icons","tone","muted","T0","t7","slot","T1","t8","main","t9","t10","fontWeight","typography","weightBold","t11","t12","t13","t14","t15","rowStyleOf","Pick","lines","base","twoLine","threeLine","_c","NativeText"],"sources":["../../src/row/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { StyleProp, TextStyle, ViewStyle } from 'react-native'\n\nimport { useMemo } from 'react'\nimport { Text as NativeText, View } from 'react-native'\n\nimport type { IconStyle } from '../glyphs/icon-style'\nimport type { ResolvedTheme } from '../theme/scope'\nimport type { RowVariant } from './styles'\n\nimport { IconStyleContext } from '../glyphs/icon-style'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { nativeWeight, useTypeRole } from '../typography/roles'\nimport { rowContentColor, rowStyles, rowStylesOf } from './styles'\n\n// The size an icon in either slot is drawn at, the lists and menus pages'.\nconst ICON_SIZE = 24\n\n// The style of each variant's selected container.\nconst SELECTED_CONTAINER = {\n drawer: 'selectedDrawer',\n list: 'selectedList',\n menu: 'selectedMenu',\n} as const satisfies Record<RowVariant, string>\n\ntype RowContentProps = {\n /** The row's headline, the one thing it is mostly about. */\n readonly children?: ReactNode\n /**\n * Whether the row is disabled. Its headline, slots and lines take the\n * faded on-surface colour, the supporting line included.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Whether the headline is drawn in the bold weight rather than its role's\n * own, for a row marked without the container a selected one takes. The\n * navigation drawer's trail to the current row is what asks for it.\n * @default false\n */\n readonly isEmphasized?: boolean\n /**\n * Whether the row is selected. Its headline, slots and lines take the\n * selected container's own on-colour, since the muted role is not\n * guaranteed to be readable over it.\n * @default false\n */\n readonly isSelected?: boolean\n /** Content before the headline: an avatar, an icon, a checkbox. */\n readonly leading?: ReactNode\n /** A line above the headline, in label small and the muted role. */\n readonly overline?: ReactNode\n /** A second line under the headline, in body medium and the muted role. */\n readonly supporting?: ReactNode\n /** Content after the headline, such as an amount or a control. */\n readonly trailing?: ReactNode\n /**\n * Which spec page's row this is. A list item's headline is body large, and\n * a menu item's and a navigation drawer row's label large.\n * @default 'list'\n */\n readonly variant?: RowVariant\n}\n\n/** Whether a slot was given something to draw. */\nfunction hasContent(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== ''\n}\n\n/**\n * The inside of a row: the leading slot, the headline with the lines beside\n * it, and the trailing slot, each drawn only when given. The view around it\n * is the caller's, ListItem's or a menu's item, and takes `rowStyleOf`; this\n * is what each of them puts inside it, so a list and a menu draw the same\n * row. Both slots hand an icon the row's content colour at 24dp, through\n * `useIconStyle()`. Not a component of the library's own and not exported.\n */\nfunction RowContent({\n children,\n isDisabled = false,\n isEmphasized = false,\n isSelected = false,\n leading,\n overline,\n supporting,\n trailing,\n variant = 'list',\n}: RowContentProps) {\n const theme = useTheme()\n const own = rowStylesOf(theme)\n const headlineRole = useTypeRole(\n variant === 'list' ? 'bodyLarge' : 'labelLarge',\n )\n const overlineRole = useTypeRole('labelSmall')\n const supportingRole = useTypeRole('bodyMedium')\n const color = rowContentColor(theme, { isDisabled, isSelected, variant })\n const icons = useMemo<IconStyle>(() => ({ color, size: ICON_SIZE }), [color])\n // The muted role on the surface; the row's own colour over a selected\n // container, and on a disabled row, which fades the lines with the rest.\n const tone = isDisabled || isSelected ? { color } : own.muted\n\n return (\n <IconStyleContext value={icons}>\n {hasContent(leading) ? (\n <View style={rowStyles.slot}>{leading}</View>\n ) : null}\n <View style={own.main}>\n {hasContent(overline) ? (\n <NativeText style={composeStyles<TextStyle>(overlineRole, tone)}>\n {overline}\n </NativeText>\n ) : null}\n <NativeText\n style={composeStyles<TextStyle>(\n headlineRole,\n { color },\n isEmphasized\n ? { fontWeight: nativeWeight(theme.typography.weightBold) }\n : undefined,\n )}\n >\n {children}\n </NativeText>\n {hasContent(supporting) ? (\n <NativeText style={composeStyles<TextStyle>(supportingRole, tone)}>\n {supporting}\n </NativeText>\n ) : null}\n </View>\n {hasContent(trailing) ? (\n <View style={rowStyles.slot}>{trailing}</View>\n ) : null}\n </IconStyleContext>\n )\n}\n\n/**\n * The style of the view around a row's content: the padding and gap, the\n * variant's height, the taller item its lines make it, and the selected\n * container. Which of the lists page's three items a row is comes from its\n * content rather than a prop, so a row holding all three lines already says\n * it is the three-line item. A line that wraps grows the shorter item and\n * keeps its slots centred.\n */\nfunction rowStyleOf(\n theme: ResolvedTheme,\n {\n isSelected = false,\n overline,\n supporting,\n variant = 'list',\n }: Pick<\n RowContentProps,\n 'isSelected' | 'overline' | 'supporting' | 'variant'\n >,\n): StyleProp<ViewStyle> {\n const own = rowStylesOf(theme)\n const lines =\n (hasContent(overline) ? 1 : 0) + (hasContent(supporting) ? 1 : 0)\n\n return composeStyles<ViewStyle>(\n own.base,\n own[variant],\n lines === 1 ? own.twoLine : undefined,\n lines === 2 ? own.threeLine : undefined,\n isSelected ? own[SELECTED_CONTAINER[variant]] : undefined,\n )\n}\n\nexport type { RowContentProps, RowVariant }\n\nexport { hasContent, RowContent, rowContentColor, rowStyleOf, rowStyles }\n"],"mappings":";;;;;;;;;;AAiBA,MAAMmB,YAAY;AAGlB,MAAMC,qBAAqB;CACzBC,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b,UACJ0C,UAAU,IAAI7B,IAAI+B,UAAUzC,KAAAA,GAC5BuC,UAAU,IAAI7B,IAAIgC,YAAY1C,KAAAA,GAC9BR,aAAakB,IAAI5B,mBAAmBe,YAAYG,KAAAA,CAClD;AACF"}
|
package/dist/row/styles.js
CHANGED
|
@@ -2,7 +2,12 @@ import { themedStyles } from "../theme/styles.js";
|
|
|
2
2
|
import { withOpacity } from "../theme/color.js";
|
|
3
3
|
import { StyleSheet } from "react-native";
|
|
4
4
|
//#region src/row/styles.ts
|
|
5
|
-
const
|
|
5
|
+
const SELECTED_CONTENT = {
|
|
6
|
+
drawer: "onSecondaryContainer",
|
|
7
|
+
list: "onPrimaryContainer",
|
|
8
|
+
menu: "onTertiaryContainer"
|
|
9
|
+
};
|
|
10
|
+
const rowStylesOf = themedStyles(({ colors, radii, sizing, spacing }) => StyleSheet.create({
|
|
6
11
|
base: {
|
|
7
12
|
alignItems: "center",
|
|
8
13
|
flexDirection: "row",
|
|
@@ -10,6 +15,11 @@ const rowStylesOf = themedStyles(({ colors, sizing, spacing }) => StyleSheet.cre
|
|
|
10
15
|
paddingHorizontal: spacing.lg,
|
|
11
16
|
paddingVertical: spacing.md
|
|
12
17
|
},
|
|
18
|
+
drawer: {
|
|
19
|
+
borderRadius: radii.pill,
|
|
20
|
+
marginHorizontal: spacing.md,
|
|
21
|
+
minHeight: sizing.rowSm
|
|
22
|
+
},
|
|
13
23
|
list: { minHeight: sizing.rowSm },
|
|
14
24
|
main: {
|
|
15
25
|
flexGrow: 1,
|
|
@@ -19,6 +29,7 @@ const rowStylesOf = themedStyles(({ colors, sizing, spacing }) => StyleSheet.cre
|
|
|
19
29
|
},
|
|
20
30
|
menu: { minHeight: sizing.rowXs },
|
|
21
31
|
muted: { color: colors.onSurfaceVariant },
|
|
32
|
+
selectedDrawer: { backgroundColor: colors.secondaryContainer },
|
|
22
33
|
selectedList: { backgroundColor: colors.primaryContainer },
|
|
23
34
|
selectedMenu: { backgroundColor: colors.tertiaryContainer },
|
|
24
35
|
threeLine: {
|
|
@@ -42,7 +53,7 @@ const rowStyles = StyleSheet.create({
|
|
|
42
53
|
*/
|
|
43
54
|
function rowContentColor({ colors, stateLayerOpacity }, { isDisabled = false, isSelected = false, variant = "list" }) {
|
|
44
55
|
if (isDisabled) return withOpacity(colors.onSurface, stateLayerOpacity.disabledContent);
|
|
45
|
-
if (isSelected) return variant
|
|
56
|
+
if (isSelected) return colors[SELECTED_CONTENT[variant]];
|
|
46
57
|
return colors.onSurface;
|
|
47
58
|
}
|
|
48
59
|
//#endregion
|
package/dist/row/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["StyleSheet","ResolvedTheme","withOpacity","themedStyles","RowVariant","rowStylesOf","colors","sizing","spacing","create","base","alignItems","flexDirection","gap","lg","paddingHorizontal","paddingVertical","md","
|
|
1
|
+
{"version":3,"file":"styles.js","names":["StyleSheet","ResolvedTheme","withOpacity","themedStyles","RowVariant","SELECTED_CONTENT","drawer","list","menu","const","Record","rowStylesOf","colors","radii","sizing","spacing","create","base","alignItems","flexDirection","gap","lg","paddingHorizontal","paddingVertical","md","borderRadius","pill","marginHorizontal","minHeight","rowSm","main","flexGrow","flexShrink","xxs","minWidth","rowXs","muted","color","onSurfaceVariant","selectedDrawer","backgroundColor","secondaryContainer","selectedList","primaryContainer","selectedMenu","tertiaryContainer","threeLine","rowLg","twoLine","rowMd","rowStyles","ring","outlineOffset","slot","justifyContent","rowContentColor","stateLayerOpacity","isDisabled","isSelected","variant","onSurface","disabledContent"],"sources":["../../src/row/styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\nimport type { ResolvedTheme } from '../theme/scope'\n\nimport { withOpacity } from '../theme/color'\nimport { themedStyles } from '../theme/styles'\n\n// The row every list and menu item draws, as web's src/row draws it: the\n// lists page's 16dp inline and 12dp block padding, 16dp between the slots\n// and the text, and a height per spec page and line count. Each height is a\n// `minHeight`, since the lines inside are set in type roles whose sizes are\n// tokens, and a larger OS text size grows the row rather than clipping it.\n// The navigation drawer page gives its row the lists page's 56dp too, with a\n// menu's label large label, and marks the current one with a secondary\n// container pill held 12dp off each edge, as web's drawer row does.\n\n/**\n * Which spec page's row this is: the lists page's, the menus page's or the\n * navigation drawer page's.\n */\ntype RowVariant = 'drawer' | 'list' | 'menu'\n\n// The on-colour of each variant's selected container.\nconst SELECTED_CONTENT = {\n drawer: 'onSecondaryContainer',\n list: 'onPrimaryContainer',\n menu: 'onTertiaryContainer',\n} as const satisfies Record<RowVariant, keyof ResolvedTheme['colors']>\n\nconst rowStylesOf = themedStyles(\n ({ colors, radii, sizing, spacing }: ResolvedTheme) =>\n StyleSheet.create({\n base: {\n alignItems: 'center',\n flexDirection: 'row',\n gap: spacing.lg,\n paddingHorizontal: spacing.lg,\n paddingVertical: spacing.md,\n },\n // The navigation drawer page's row: the lists page's floor, and a pill\n // held off each edge, since what marks the current row there is a shape\n // as much as a colour. The row hands the same corners to its state layer\n // and ripple, which clip to them.\n drawer: {\n borderRadius: radii.pill,\n marginHorizontal: spacing.md,\n minHeight: sizing.rowSm,\n },\n // The lists page's one-line item.\n list: {\n minHeight: sizing.rowSm,\n },\n // The headline and the lines beside it take what the slots leave and\n // wrap past it, so a long one never runs under the trailing slot.\n // `minWidth: 0` is for React Native Web, where a text in a row keeps\n // CSS's automatic minimum, the width of its longest word.\n main: {\n flexGrow: 1,\n flexShrink: 1,\n gap: spacing.xxs,\n minWidth: 0,\n },\n // The menus page's item.\n menu: {\n minHeight: sizing.rowXs,\n },\n muted: {\n color: colors.onSurfaceVariant,\n },\n // The drawer page's current row, on secondary container rather than the\n // lists page's primary one, which keeps it apart from a selected row in\n // a list beside it.\n selectedDrawer: {\n backgroundColor: colors.secondaryContainer,\n },\n selectedList: {\n backgroundColor: colors.primaryContainer,\n },\n selectedMenu: {\n backgroundColor: colors.tertiaryContainer,\n },\n // The three-line item, the only one whose slots move: they are held\n // level with the overline rather than centred on the three lines.\n threeLine: {\n alignItems: 'flex-start',\n minHeight: sizing.rowLg,\n },\n twoLine: {\n minHeight: sizing.rowMd,\n },\n }),\n)\n\nconst rowStyles = StyleSheet.create({\n // The focus ring, drawn inside the row as web's is, so a container that\n // clips its rows, such as a menu's surface, leaves the whole ring showing.\n ring: {\n outlineOffset: -2,\n },\n slot: {\n alignItems: 'center',\n flexShrink: 0,\n justifyContent: 'center',\n },\n})\n\n/**\n * The colour a row's headline, slots and feedback are drawn in: on surface,\n * the selected container's own on-colour, or on surface faded to the\n * disabled content opacity, which wins over the selected one.\n */\nfunction rowContentColor(\n { colors, stateLayerOpacity }: ResolvedTheme,\n {\n isDisabled = false,\n isSelected = false,\n variant = 'list',\n }: {\n readonly isDisabled?: boolean\n readonly isSelected?: boolean\n readonly variant?: RowVariant\n },\n): string {\n if (isDisabled) {\n return withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n }\n if (isSelected) {\n return colors[SELECTED_CONTENT[variant]]\n }\n return colors.onSurface\n}\n\nexport type { RowVariant }\n\nexport { rowContentColor, rowStyles, rowStylesOf }\n"],"mappings":";;;;AAuBA,MAAMK,mBAAmB;CACvBC,QAAQ;CACRC,MAAM;CACNC,MAAM;AACR;AAEA,MAAMG,cAAcR,cACjB,EAAES,QAAQC,OAAOC,QAAQC,cACxBf,WAAWgB,OAAO;CAChBC,MAAM;EACJC,YAAY;EACZC,eAAe;EACfC,KAAKL,QAAQM;EACbC,mBAAmBP,QAAQM;EAC3BE,iBAAiBR,QAAQS;CAC3B;CAKAlB,QAAQ;EACNmB,cAAcZ,MAAMa;EACpBC,kBAAkBZ,QAAQS;EAC1BI,WAAWd,OAAOe;CACpB;CAEAtB,MAAM,EACJqB,WAAWd,OAAOe,MACpB;CAKAC,MAAM;EACJC,UAAU;EACVC,YAAY;EACZZ,KAAKL,QAAQkB;EACbC,UAAU;CACZ;CAEA1B,MAAM,EACJoB,WAAWd,OAAOqB,MACpB;CACAC,OAAO,EACLC,OAAOzB,OAAO0B,iBAChB;CAIAC,gBAAgB,EACdC,iBAAiB5B,OAAO6B,mBAC1B;CACAC,cAAc,EACZF,iBAAiB5B,OAAO+B,iBAC1B;CACAC,cAAc,EACZJ,iBAAiB5B,OAAOiC,kBAC1B;CAGAC,WAAW;EACT5B,YAAY;EACZU,WAAWd,OAAOiC;CACpB;CACAC,SAAS,EACPpB,WAAWd,OAAOmC,MACpB;AACF,CAAC,CACL;AAEA,MAAMC,YAAYlD,WAAWgB,OAAO;CAGlCmC,MAAM,EACJC,eAAe,GACjB;CACAC,MAAM;EACJnC,YAAY;EACZc,YAAY;EACZsB,gBAAgB;CAClB;AACF,CAAC;;;;;;AAOD,SAASC,gBACP,EAAE3C,QAAQ4C,qBACV,EACEC,aAAa,OACbC,aAAa,OACbC,UAAU,UAMJ;CACR,IAAIF,YACF,OAAOvD,YAAYU,OAAOgD,WAAWJ,kBAAkBK,eAAe;CAExE,IAAIH,YACF,OAAO9C,OAAOP,iBAAiBsD;CAEjC,OAAO/C,OAAOgD;AAChB"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { useTheme } from "../theme/scope.js";
|
|
2
|
+
import { composeStyles } from "../theme/styles.js";
|
|
3
|
+
import { useTypeRole } from "../typography/roles.js";
|
|
4
|
+
import { messagesFor } from "../i18n/index.js";
|
|
5
|
+
import { useFieldValidation } from "../form/index.js";
|
|
6
|
+
import { FieldBox, FieldMessage, FieldSegments, describedBy } from "../field/index.js";
|
|
7
|
+
import { segmentStylesOf } from "./styles.js";
|
|
8
|
+
import { DateSegments } from "./index.js";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { Text, View } from "react-native";
|
|
11
|
+
import { useId, useRef, useState } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
//#region src/segments/field.tsx
|
|
14
|
+
function arrivedOf({ leaving, onFocus, setFocused }) {
|
|
15
|
+
return () => {
|
|
16
|
+
if (leaving.current === void 0) {
|
|
17
|
+
setFocused(true);
|
|
18
|
+
onFocus?.();
|
|
19
|
+
} else clearTimeout(leaving.current);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function backToStart({ control }) {
|
|
23
|
+
return () => {
|
|
24
|
+
control.current?.focusLast();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function FieldLine(line) {
|
|
28
|
+
const $ = c(54);
|
|
29
|
+
const { box, control, description, end, endControl, endName, endSubmitted: t0, error, errors, floatingLabel: t1, focused, holding, isDisabled, isEmpty, isReadOnly, isRequired, label, leadingIcon, locale, name, ref, separator, state, style, submitted, testID, trailingIcon, variant: t2 } = line;
|
|
30
|
+
const endSubmitted = t0 === void 0 ? "" : t0;
|
|
31
|
+
const floatingLabel = t1 === void 0 ? true : t1;
|
|
32
|
+
const variant = t2 === void 0 ? "filled" : t2;
|
|
33
|
+
const id = useId();
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
const own = segmentStylesOf(theme);
|
|
36
|
+
const role = useTypeRole("bodyLarge");
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[0] !== locale) {
|
|
39
|
+
t3 = messagesFor(locale);
|
|
40
|
+
$[0] = locale;
|
|
41
|
+
$[1] = t3;
|
|
42
|
+
} else t3 = $[1];
|
|
43
|
+
const words = t3.segments;
|
|
44
|
+
let t4;
|
|
45
|
+
if ($[2] !== end || $[3] !== endName || $[4] !== endSubmitted) {
|
|
46
|
+
t4 = end === void 0 ? void 0 : [endName, endSubmitted];
|
|
47
|
+
$[2] = end;
|
|
48
|
+
$[3] = endName;
|
|
49
|
+
$[4] = endSubmitted;
|
|
50
|
+
$[5] = t4;
|
|
51
|
+
} else t4 = $[5];
|
|
52
|
+
let t5;
|
|
53
|
+
if ($[6] !== errors) {
|
|
54
|
+
t5 = () => errors;
|
|
55
|
+
$[6] = errors;
|
|
56
|
+
$[7] = t5;
|
|
57
|
+
} else t5 = $[7];
|
|
58
|
+
let t6;
|
|
59
|
+
if ($[8] !== control || $[9] !== error || $[10] !== isDisabled || $[11] !== isEmpty || $[12] !== isReadOnly || $[13] !== isRequired || $[14] !== name || $[15] !== submitted || $[16] !== t4 || $[17] !== t5) {
|
|
60
|
+
t6 = {
|
|
61
|
+
alongside: t4,
|
|
62
|
+
control,
|
|
63
|
+
error,
|
|
64
|
+
isDisabled,
|
|
65
|
+
isEmpty,
|
|
66
|
+
isReadOnly,
|
|
67
|
+
isRequired,
|
|
68
|
+
name,
|
|
69
|
+
submitted,
|
|
70
|
+
validate: t5,
|
|
71
|
+
value: null
|
|
72
|
+
};
|
|
73
|
+
$[8] = control;
|
|
74
|
+
$[9] = error;
|
|
75
|
+
$[10] = isDisabled;
|
|
76
|
+
$[11] = isEmpty;
|
|
77
|
+
$[12] = isReadOnly;
|
|
78
|
+
$[13] = isRequired;
|
|
79
|
+
$[14] = name;
|
|
80
|
+
$[15] = submitted;
|
|
81
|
+
$[16] = t4;
|
|
82
|
+
$[17] = t5;
|
|
83
|
+
$[18] = t6;
|
|
84
|
+
} else t6 = $[18];
|
|
85
|
+
const validation = useFieldValidation(t6);
|
|
86
|
+
const shownError = validation.error;
|
|
87
|
+
let t7;
|
|
88
|
+
if ($[19] !== description || $[20] !== id || $[21] !== shownError) {
|
|
89
|
+
t7 = describedBy(id, {
|
|
90
|
+
description,
|
|
91
|
+
error: shownError
|
|
92
|
+
});
|
|
93
|
+
$[19] = description;
|
|
94
|
+
$[20] = id;
|
|
95
|
+
$[21] = shownError;
|
|
96
|
+
$[22] = t7;
|
|
97
|
+
} else t7 = $[22];
|
|
98
|
+
const described = t7;
|
|
99
|
+
let t8;
|
|
100
|
+
if ($[23] !== line) {
|
|
101
|
+
t8 = arrivedOf(line);
|
|
102
|
+
$[23] = line;
|
|
103
|
+
$[24] = t8;
|
|
104
|
+
} else t8 = $[24];
|
|
105
|
+
const arrived = t8;
|
|
106
|
+
let t9;
|
|
107
|
+
if ($[25] !== line || $[26] !== validation.onBlur) {
|
|
108
|
+
t9 = leftOf(line, validation.onBlur);
|
|
109
|
+
$[25] = line;
|
|
110
|
+
$[26] = validation.onBlur;
|
|
111
|
+
$[27] = t9;
|
|
112
|
+
} else t9 = $[27];
|
|
113
|
+
const left = t9;
|
|
114
|
+
const T0 = View;
|
|
115
|
+
const t10 = "group";
|
|
116
|
+
const T1 = FieldBox;
|
|
117
|
+
const t11 = focused ? void 0 : control;
|
|
118
|
+
const t12 = shownError !== void 0;
|
|
119
|
+
const t13 = true;
|
|
120
|
+
const t14 = end === void 0 ? /* @__PURE__ */ jsx(DateSegments, {
|
|
121
|
+
described,
|
|
122
|
+
holding,
|
|
123
|
+
isInvalid: shownError !== void 0,
|
|
124
|
+
label,
|
|
125
|
+
locale,
|
|
126
|
+
onBlur: left,
|
|
127
|
+
onEdit: validation.onEdit,
|
|
128
|
+
onFocus: arrived,
|
|
129
|
+
ref: control,
|
|
130
|
+
state
|
|
131
|
+
}) : /* @__PURE__ */ jsxs(FieldSegments, { children: [
|
|
132
|
+
/* @__PURE__ */ jsx(DateSegments, {
|
|
133
|
+
described,
|
|
134
|
+
holding,
|
|
135
|
+
isInvalid: shownError !== void 0,
|
|
136
|
+
label: `${words.startDate}, ${label}`,
|
|
137
|
+
locale,
|
|
138
|
+
onBlur: left,
|
|
139
|
+
onEdit: validation.onEdit,
|
|
140
|
+
onFocus: arrived,
|
|
141
|
+
onPastEnd: onToEnd(line),
|
|
142
|
+
ref: control,
|
|
143
|
+
state
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsx(Text, {
|
|
146
|
+
"aria-hidden": true,
|
|
147
|
+
style: composeStyles(role, own.separator, isDisabled ? own.textDisabled : own.textMuted),
|
|
148
|
+
children: separator
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ jsx(DateSegments, {
|
|
151
|
+
described,
|
|
152
|
+
holding,
|
|
153
|
+
isInvalid: shownError !== void 0,
|
|
154
|
+
label: `${words.endDate}, ${label}`,
|
|
155
|
+
locale,
|
|
156
|
+
onBeforeStart: backToStart(line),
|
|
157
|
+
onBlur: left,
|
|
158
|
+
onEdit: validation.onEdit,
|
|
159
|
+
onFocus: arrived,
|
|
160
|
+
ref: endControl,
|
|
161
|
+
state: end
|
|
162
|
+
})
|
|
163
|
+
] });
|
|
164
|
+
let t15;
|
|
165
|
+
if ($[28] !== T1 || $[29] !== box || $[30] !== floatingLabel || $[31] !== focused || $[32] !== isDisabled || $[33] !== isRequired || $[34] !== label || $[35] !== leadingIcon || $[36] !== t11 || $[37] !== t12 || $[38] !== t14 || $[39] !== trailingIcon || $[40] !== variant) {
|
|
166
|
+
t15 = /* @__PURE__ */ jsx(T1, {
|
|
167
|
+
control: t11,
|
|
168
|
+
floatingLabel,
|
|
169
|
+
isDisabled,
|
|
170
|
+
isFocused: focused,
|
|
171
|
+
isInvalid: t12,
|
|
172
|
+
isPopulated: t13,
|
|
173
|
+
isRequired,
|
|
174
|
+
label,
|
|
175
|
+
leading: leadingIcon,
|
|
176
|
+
ref: box,
|
|
177
|
+
trailing: trailingIcon,
|
|
178
|
+
variant,
|
|
179
|
+
children: t14
|
|
180
|
+
});
|
|
181
|
+
$[28] = T1;
|
|
182
|
+
$[29] = box;
|
|
183
|
+
$[30] = floatingLabel;
|
|
184
|
+
$[31] = focused;
|
|
185
|
+
$[32] = isDisabled;
|
|
186
|
+
$[33] = isRequired;
|
|
187
|
+
$[34] = label;
|
|
188
|
+
$[35] = leadingIcon;
|
|
189
|
+
$[36] = t11;
|
|
190
|
+
$[37] = t12;
|
|
191
|
+
$[38] = t14;
|
|
192
|
+
$[39] = trailingIcon;
|
|
193
|
+
$[40] = variant;
|
|
194
|
+
$[41] = t15;
|
|
195
|
+
} else t15 = $[41];
|
|
196
|
+
let t16;
|
|
197
|
+
if ($[42] !== description || $[43] !== id || $[44] !== shownError) {
|
|
198
|
+
t16 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
199
|
+
description,
|
|
200
|
+
error: shownError,
|
|
201
|
+
id
|
|
202
|
+
});
|
|
203
|
+
$[42] = description;
|
|
204
|
+
$[43] = id;
|
|
205
|
+
$[44] = shownError;
|
|
206
|
+
$[45] = t16;
|
|
207
|
+
} else t16 = $[45];
|
|
208
|
+
let t17;
|
|
209
|
+
if ($[46] !== T0 || $[47] !== label || $[48] !== ref || $[49] !== style || $[50] !== t15 || $[51] !== t16 || $[52] !== testID) {
|
|
210
|
+
t17 = /* @__PURE__ */ jsxs(T0, {
|
|
211
|
+
"aria-label": label,
|
|
212
|
+
ref,
|
|
213
|
+
role: t10,
|
|
214
|
+
style,
|
|
215
|
+
testID,
|
|
216
|
+
children: [t15, t16]
|
|
217
|
+
});
|
|
218
|
+
$[46] = T0;
|
|
219
|
+
$[47] = label;
|
|
220
|
+
$[48] = ref;
|
|
221
|
+
$[49] = style;
|
|
222
|
+
$[50] = t15;
|
|
223
|
+
$[51] = t16;
|
|
224
|
+
$[52] = testID;
|
|
225
|
+
$[53] = t17;
|
|
226
|
+
} else t17 = $[53];
|
|
227
|
+
return t17;
|
|
228
|
+
}
|
|
229
|
+
function leftOf({ end, leaving, onBlur, setFocused }, validationBlur) {
|
|
230
|
+
const left = () => {
|
|
231
|
+
leaving.current = void 0;
|
|
232
|
+
setFocused(false);
|
|
233
|
+
onBlur?.();
|
|
234
|
+
};
|
|
235
|
+
return () => {
|
|
236
|
+
validationBlur();
|
|
237
|
+
if (end === void 0) left();
|
|
238
|
+
else leaving.current = setTimeout(left, 0);
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function onToEnd({ endControl }) {
|
|
242
|
+
return () => {
|
|
243
|
+
endControl.current?.focus();
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A field of segments from React Stately's date field state, in the text
|
|
248
|
+
* field's box: the label floated from the start, since the segments always
|
|
249
|
+
* show, and the error what `error` says, else what `errors` says, in React
|
|
250
|
+
* Stately's order and its words. Given an `end` it draws a range.
|
|
251
|
+
*/
|
|
252
|
+
function SegmentedField(props) {
|
|
253
|
+
const $ = c(3);
|
|
254
|
+
const control = useRef(null);
|
|
255
|
+
const endControl = useRef(null);
|
|
256
|
+
const leaving = useRef(void 0);
|
|
257
|
+
const [focused, setFocused] = useState(false);
|
|
258
|
+
let t0;
|
|
259
|
+
if ($[0] !== focused || $[1] !== props) {
|
|
260
|
+
t0 = /* @__PURE__ */ jsx(FieldLine, {
|
|
261
|
+
...props,
|
|
262
|
+
control,
|
|
263
|
+
endControl,
|
|
264
|
+
focused,
|
|
265
|
+
leaving,
|
|
266
|
+
setFocused
|
|
267
|
+
});
|
|
268
|
+
$[0] = focused;
|
|
269
|
+
$[1] = props;
|
|
270
|
+
$[2] = t0;
|
|
271
|
+
} else t0 = $[2];
|
|
272
|
+
return t0;
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
275
|
+
export { SegmentedField };
|
|
276
|
+
|
|
277
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","names":["ComponentRef","ReactNode","Ref","RefObject","HostInstance","StyleProp","TextStyle","ViewStyle","DateFieldState","useId","useRef","useState","Text","View","SegmentsHandle","FieldVariant","DateSegments","describedBy","FieldBox","FieldMessage","FieldSegments","useFieldValidation","messagesFor","useTheme","composeStyles","useTypeRole","segmentStylesOf","FieldLineProps","SegmentedFieldProps","control","endControl","focused","leaving","ReturnType","setTimeout","setFocused","box","description","end","endName","endSubmitted","error","errors","floatingLabel","holding","isDisabled","isEmpty","isReadOnly","isRequired","label","leadingIcon","locale","name","onBlur","onFocus","ref","separator","state","style","submitted","testID","trailingIcon","variant","arrivedOf","current","undefined","clearTimeout","backToStart","focusLast","FieldLine","line","$","_c","t0","t1","t2","id","theme","own","role","t3","words","segments","t4","t5","t6","alongside","validate","value","validation","shownError","t7","described","t8","arrived","t9","leftOf","left","T0","t10","T1","t11","t12","t13","t14","onEdit","startDate","onToEnd","textDisabled","textMuted","endDate","t15","t16","t17","validationBlur","focus","SegmentedField","props","_c"],"sources":["../../src/segments/field.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref, RefObject } from 'react'\nimport type {\n HostInstance,\n StyleProp,\n TextStyle,\n ViewStyle,\n} from 'react-native'\nimport type { DateFieldState } from 'react-stately/useDateFieldState'\n\nimport { useId, useRef, useState } from 'react'\nimport { Text, View } from 'react-native'\n\nimport type { SegmentsHandle } from '.'\nimport type { FieldVariant } from '../field'\n\nimport { DateSegments } from '.'\nimport { describedBy, FieldBox, FieldMessage, FieldSegments } from '../field'\nimport { useFieldValidation } from '../form'\nimport { messagesFor } from '../i18n'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { segmentStylesOf } from './styles'\n\n// The field a date or a time is typed into: src/field's box, label and line\n// under it around the segments, with the value taking part in the Form\n// around it. DateField and TimeField differ in the state they build, and\n// both draw it through this, as web's two draw the same chrome around React\n// Aria's DateInput. DatePicker draws it with the calendar's button in the\n// trailing slot, and DateRangePicker with two dates on its line.\n//\n// **A range is two sets of segments with a separator between them**, the\n// start's and the end's, each its own React Stately field and each named for\n// its date before the label, \"Start Date\" and \"End Date\" in React Aria's\n// words. Focus runs on from the start's last segment to the end's first, as\n// a full segment or an arrow key moves it, and back from the end's first as\n// a backspace does, as React Aria's picker moves it across both. The\n// separator is decoration in the segments' muted role, hidden from a screen\n// reader, which already hears which date each segment is part of.\n//\n// Focus moving from one date to the other is not focus leaving the field: a\n// date's blur waits for the other's focus before the field draws itself\n// blurred and tells the call site, as React Aria's picker hears focus leave\n// the whole group. A field of one date has nothing to wait for, so its blur\n// is the field's at once. A press on the box while either date has focus\n// leaves focus where it is, rather than taking it back to the start's first\n// segment.\n\n// What the field keeps for its line: each date's segments, the timer a\n// date's blur waits on, and whether it draws itself focused.\ntype FieldLineProps = SegmentedFieldProps & {\n readonly control: RefObject<null | SegmentsHandle>\n readonly endControl: RefObject<null | SegmentsHandle>\n readonly focused: boolean\n readonly leaving: RefObject<ReturnType<typeof setTimeout> | undefined>\n readonly setFocused: (focused: boolean) => void\n}\n\ntype SegmentedFieldProps = {\n /** The box, which a picker measures to place its calendar under. */\n readonly box?: Ref<HostInstance>\n readonly description?: string\n /** A range's end, whose segments follow the separator. */\n readonly end?: DateFieldState\n /** The name a range's end is submitted under. */\n readonly endName?: string\n /** What the Form submits a range's end as, `''` while empty. */\n readonly endSubmitted?: string\n readonly error?: string\n /** What React Stately's validation of the value says, in its words. */\n readonly errors: readonly string[]\n readonly floatingLabel?: boolean\n /**\n * What the segments are read as holding, after their own names: the date\n * written out by default, a range picker's whole range where given.\n */\n readonly holding?: string\n readonly isDisabled: boolean\n /** Whether the value is what a required field must not be left as. */\n readonly isEmpty: boolean\n readonly isReadOnly: boolean\n readonly isRequired: boolean\n readonly label: string\n readonly leadingIcon?: ReactNode\n /** The locale the segments are written in, already resolved. */\n readonly locale: string\n readonly name?: string\n readonly onBlur?: () => void\n readonly onFocus?: () => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n /** What is drawn between a range's two dates. */\n readonly separator?: string\n /** The field's state, or a range's start. */\n readonly state: DateFieldState\n readonly style?: StyleProp<ViewStyle>\n /** What the Form around the field submits the value as, `''` while empty. */\n readonly submitted: string\n readonly testID?: string\n readonly trailingIcon?: ReactNode\n readonly variant?: FieldVariant\n}\n\n// A date's segments arriving in focus: the field's focus where focus comes\n// from outside it, and nothing new where it comes from the other date, whose\n// leaving is then called off. The timer's id is kept until the next blur\n// replaces it, since focus arrives nowhere else before one.\nfunction arrivedOf({ leaving, onFocus, setFocused }: FieldLineProps) {\n return () => {\n if (leaving.current === undefined) {\n setFocused(true)\n onFocus?.()\n } else {\n clearTimeout(leaving.current)\n }\n }\n}\n\n// Moves focus back from the end's first segment to the start's last.\nfunction backToStart({ control }: FieldLineProps) {\n return () => {\n control.current?.focusLast()\n }\n}\n\n// The field's box, label and line under it around its segments.\nfunction FieldLine(line: FieldLineProps) {\n const {\n box,\n control,\n description,\n end,\n endControl,\n endName,\n endSubmitted = '',\n error,\n errors,\n floatingLabel = true,\n focused,\n holding,\n isDisabled,\n isEmpty,\n isReadOnly,\n isRequired,\n label,\n leadingIcon,\n locale,\n name,\n ref,\n separator,\n state,\n style,\n submitted,\n testID,\n trailingIcon,\n variant = 'filled',\n } = 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 validation = useFieldValidation({\n alongside: end === undefined ? undefined : [endName, endSubmitted],\n control,\n error,\n isDisabled,\n isEmpty,\n isReadOnly,\n isRequired,\n name,\n submitted,\n validate: () => errors,\n value: null,\n })\n const shownError = validation.error\n const described = describedBy(id, { description, error: shownError })\n const arrived = arrivedOf(line)\n const left = leftOf(line, validation.onBlur)\n\n return (\n <View\n aria-label={label}\n ref={ref}\n role=\"group\"\n style={style}\n testID={testID}\n >\n <FieldBox\n control={focused ? undefined : control}\n floatingLabel={floatingLabel}\n isDisabled={isDisabled}\n isFocused={focused}\n isInvalid={shownError !== undefined}\n isPopulated\n isRequired={isRequired}\n label={label}\n leading={leadingIcon}\n ref={box}\n trailing={trailingIcon}\n variant={variant}\n >\n {end === undefined ? (\n <DateSegments\n described={described}\n holding={holding}\n isInvalid={shownError !== undefined}\n label={label}\n locale={locale}\n onBlur={left}\n onEdit={validation.onEdit}\n onFocus={arrived}\n ref={control}\n state={state}\n />\n ) : (\n <FieldSegments>\n <DateSegments\n described={described}\n holding={holding}\n isInvalid={shownError !== undefined}\n label={`${words.startDate}, ${label}`}\n locale={locale}\n onBlur={left}\n onEdit={validation.onEdit}\n onFocus={arrived}\n onPastEnd={onToEnd(line)}\n ref={control}\n state={state}\n />\n <Text\n aria-hidden\n style={composeStyles<TextStyle>(\n role,\n own.separator,\n isDisabled ? own.textDisabled : own.textMuted,\n )}\n >\n {separator}\n </Text>\n <DateSegments\n described={described}\n holding={holding}\n isInvalid={shownError !== undefined}\n label={`${words.endDate}, ${label}`}\n locale={locale}\n onBeforeStart={backToStart(line)}\n onBlur={left}\n onEdit={validation.onEdit}\n onFocus={arrived}\n ref={endControl}\n state={end}\n />\n </FieldSegments>\n )}\n </FieldBox>\n <FieldMessage description={description} error={shownError} id={id} />\n </View>\n )\n}\n\n// A date's segments losing focus: the validation's blur at once, as each of\n// React Aria's date fields commits its own, and the field's blur once the\n// other date has not taken focus, or at once where there is no other.\nfunction leftOf(\n { end, leaving, onBlur, setFocused }: FieldLineProps,\n validationBlur: () => void,\n) {\n const left = () => {\n leaving.current = undefined\n setFocused(false)\n onBlur?.()\n }\n\n return () => {\n validationBlur()\n\n if (end === undefined) {\n left()\n } else {\n leaving.current = setTimeout(left, 0)\n }\n }\n}\n\n// Moves focus on from the start's last segment to the end's first.\nfunction onToEnd({ endControl }: FieldLineProps) {\n return () => {\n endControl.current?.focus()\n }\n}\n\n/**\n * A field of segments from React Stately's date field state, in the text\n * field's box: the label floated from the start, since the segments always\n * show, and the error what `error` says, else what `errors` says, in React\n * Stately's order and its words. Given an `end` it draws a range.\n */\nfunction SegmentedField(props: SegmentedFieldProps) {\n const control = useRef<SegmentsHandle>(null)\n const endControl = useRef<SegmentsHandle>(null)\n const leaving = useRef<ReturnType<typeof setTimeout>>(undefined)\n const [focused, setFocused] = useState(false)\n\n return (\n <FieldLine\n {...props}\n control={control}\n endControl={endControl}\n focused={focused}\n leaving={leaving}\n setFocused={setFocused}\n />\n )\n}\n\nexport { SegmentedField }\nexport type { SegmentedFieldProps }\n"],"mappings":";;;;;;;;;;;;;AA0GA,SAAS+D,UAAU,EAAE/B,SAASsB,SAASnB,cAA8B;CACnE,aAAa;EACX,IAAIH,QAAQgC,YAAYC,KAAAA,GAAW;GACjC9B,WAAW,IAAI;GACfmB,UAAU;EACZ,OACEY,aAAalC,QAAQgC,OAAO;CAEhC;AACF;AAGA,SAASG,YAAY,EAAEtC,WAA2B;CAChD,aAAa;EACXA,QAAQmC,SAASI,UAAU;CAC7B;AACF;AAGA,SAAAC,UAAAC,MAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACE,MAAA,EAAApC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