@kanso-labs/react-native-kanso-ui 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/autocomplete/index.js +15 -1
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/button/group.d.ts +5 -0
- package/dist/button/group.js +115 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/index.d.ts +4 -1
- package/dist/button/index.js +44 -22
- package/dist/button/index.js.map +1 -1
- package/dist/button/slots.js +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/calendar/index.js +351 -182
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +33 -2
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/chequer/index.js +95 -0
- package/dist/chequer/index.js.map +1 -0
- package/dist/collection/index.d.ts +157 -0
- package/dist/collection/index.js +1358 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/color-thumb/index.js +56 -0
- package/dist/color-thumb/index.js.map +1 -0
- package/dist/components/button/index.d.ts +4 -2
- package/dist/components/button/index.js +227 -188
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +87 -0
- package/dist/components/button-group/index.js +275 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +11 -3
- package/dist/components/calendar/index.js +60 -45
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +72 -0
- package/dist/components/carousel/index.js +496 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/checkbox-group/index.d.ts +3 -4
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +4 -1
- package/dist/components/chip/index.js +229 -161
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +85 -0
- package/dist/components/color-area/index.js +630 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-field/index.d.ts +144 -0
- package/dist/components/color-field/index.js +516 -0
- package/dist/components/color-field/index.js.map +1 -0
- package/dist/components/color-picker/index.d.ts +74 -0
- package/dist/components/color-picker/index.js +317 -0
- package/dist/components/color-picker/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +82 -0
- package/dist/components/color-slider/index.js +456 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +46 -0
- package/dist/components/color-swatch/index.js +127 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +81 -0
- package/dist/components/color-swatch-picker/index.js +287 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/color-wheel/index.d.ts +71 -0
- package/dist/components/color-wheel/index.js +407 -0
- package/dist/components/color-wheel/index.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +193 -0
- package/dist/components/combo-box/index.js +616 -0
- package/dist/components/combo-box/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +120 -0
- package/dist/components/date-field/index.js +111 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +130 -0
- package/dist/components/date-picker/index.js +310 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +139 -0
- package/dist/components/date-range-picker/index.js +421 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/dialog/index.d.ts +5 -5
- package/dist/components/dialog/index.js +5 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +94 -0
- package/dist/components/disclosure/index.js +365 -0
- package/dist/components/disclosure/index.js.map +1 -0
- package/dist/components/disclosure-group/index.d.ts +61 -0
- package/dist/components/disclosure-group/index.js +100 -0
- package/dist/components/disclosure-group/index.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +113 -0
- package/dist/components/drop-zone/index.js +304 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js +91 -76
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +4 -2
- package/dist/components/icon-button/index.js +204 -171
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.d.ts +15 -158
- package/dist/components/list/index.js +21 -1047
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +73 -0
- package/dist/components/list-box/index.js +82 -0
- package/dist/components/list-box/index.js.map +1 -0
- package/dist/components/loading-indicator/index.d.ts +32 -0
- package/dist/components/loading-indicator/index.js +174 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +117 -0
- package/dist/components/navigation-tree/index.js +135 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/number-field/index.js +132 -143
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +69 -0
- package/dist/components/range-calendar/index.js +144 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/search-view/index.d.ts +79 -0
- package/dist/components/search-view/index.js +571 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/select/index.d.ts +152 -0
- package/dist/components/select/index.js +419 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/sheet/index.d.ts +16 -7
- package/dist/components/sheet/index.js +157 -152
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +111 -0
- package/dist/components/slider/index.js +673 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/split-button/index.d.ts +77 -0
- package/dist/components/split-button/index.js +354 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/table/index.d.ts +391 -0
- package/dist/components/table/index.js +1708 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +196 -0
- package/dist/components/tabs/index.js +1137 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +43 -0
- package/dist/components/time-field/index.js +107 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-picker/index.d.ts +65 -0
- package/dist/components/time-picker/index.js +1168 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/token-field/index.d.ts +105 -0
- package/dist/components/token-field/index.js +574 -0
- package/dist/components/token-field/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +102 -0
- package/dist/components/tooltip/index.js +223 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +112 -0
- package/dist/components/tree/index.js +157 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/disclosure/chevron.js +75 -0
- package/dist/disclosure/chevron.js.map +1 -0
- package/dist/disclosure/index.js +7 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/drop/index.d.ts +54 -0
- package/dist/drop/index.js +161 -0
- package/dist/drop/index.js.map +1 -0
- package/dist/field/chevron.js +74 -0
- package/dist/field/chevron.js.map +1 -0
- package/dist/field/index.d.ts +2 -1
- package/dist/field/index.js +359 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/files/index.d.ts +18 -0
- package/dist/files/index.js +107 -0
- package/dist/files/index.js.map +1 -0
- package/dist/form/index.d.ts +5 -2
- package/dist/form/index.js +64 -85
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/index.js +128 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +36 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1734 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +37 -3
- package/dist/index.js +36 -3
- package/dist/indicator/paths.js +23 -1
- package/dist/indicator/paths.js.map +1 -1
- package/dist/modal/index.js +92 -77
- package/dist/modal/index.js.map +1 -1
- package/dist/number/keyboard.js +16 -0
- package/dist/number/keyboard.js.map +1 -0
- package/dist/overlay/anchored.js +68 -38
- package/dist/overlay/anchored.js.map +1 -1
- package/dist/overlay/keyboard.js +57 -0
- package/dist/overlay/keyboard.js.map +1 -0
- package/dist/overlay/panel.js +173 -19
- package/dist/overlay/panel.js.map +1 -1
- package/dist/overlay/placement.js +13 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/picker/index.js +322 -0
- package/dist/picker/index.js.map +1 -0
- package/dist/press/index.d.ts +2 -0
- package/dist/press/index.js +102 -100
- package/dist/press/index.js.map +1 -1
- package/dist/row/index.js +77 -69
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +13 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/field.js +277 -0
- package/dist/segments/field.js.map +1 -0
- package/dist/segments/index.js +574 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +24 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/slider/index.js +145 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/swatch/index.js +56 -0
- package/dist/swatch/index.js.map +1 -0
- package/package.json +11 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","GestureResponderEvent","HostInstance","StyleProp","TextStyle","ViewStyle","View","ViewType","useEffect","useEffectEvent","useRef","useState","Platform","Pressable","StyleSheet","Text","ButtonSlots","DragTypes","DropEnterEvent","DropEvent","DropExitEvent","DropOperation","PickedFile","ButtonSlotContext","fileItemOf","isDropTarget","operationOf","typesOf","watchDrops","pickThen","preparePicker","usePressFeedback","refsOf","withOpacity","useTheme","composeStyles","themedStyles","useTypeRole","MIN_HEIGHT","stylesOf","colors","radii","spacing","stateLayerOpacity","disabled","onSurface","disabledContent","create","label","color","onSurfaceVariant","textAlign","labelBox","pointerEvents","labelDisabled","labelOver","onPrimaryContainer","press","borderRadius","md","ring","outlineOffset","root","alignItems","backgroundColor","surface","borderColor","outlineVariant","borderStyle","borderWidth","boxSizing","gap","justifyContent","minHeight","padding","xl","rootDisabled","rootOver","primaryContainer","primary","DropZoneProps","children","getDropOperation","types","allowedOperations","isDisabled","onDrop","event","onDropEnter","onDropExit","ref","style","testID","FileTriggerProps","acceptedFileTypes","allowsMultiple","defaultCamera","onSelect","files","DropZone","t0","$","_c","ariaLabel","t1","undefined","theme","styles","bodyMedium","isOver","setOver","node","web","OS","t2","t3","corners","feedback","t4","handlersNow","t5","disabledNow","name","over","t6","target","current","t7","Symbol","for","T0","t8","t9","t10","t11","t12","t13","handlers","pressOf","absoluteFill","layer","t14","t15","FileTrigger","pick","slotsOf","locationX","x","locationY","y","nativeEvent","dropOperation","map","file","type","items","default","_c"],"sources":["../../../src/components/drop-zone/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n GestureResponderEvent,\n HostInstance,\n StyleProp,\n TextStyle,\n ViewStyle,\n View as ViewType,\n} from 'react-native'\n\nimport { useEffect, useEffectEvent, useRef, useState } from 'react'\nimport { Platform, Pressable, StyleSheet, Text, View } from 'react-native'\n\nimport type { ButtonSlots } from '../../button/slots'\nimport type {\n DragTypes,\n DropEnterEvent,\n DropEvent,\n DropExitEvent,\n DropOperation,\n} from '../../drop'\nimport type { PickedFile } from '../../files'\n\nimport { ButtonSlotContext } from '../../button/slots'\nimport {\n fileItemOf,\n isDropTarget,\n operationOf,\n typesOf,\n watchDrops,\n} from '../../drop'\nimport { pickThen, preparePicker } from '../../files'\nimport { usePressFeedback } from '../../press'\nimport { refsOf } from '../../ref'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\n\n// A place to drop files, and a way to open the file chooser from a button, as\n// kanso-ui's DropZone and FileTrigger are. Material Design carries no page for\n// either, so the target is drawn from the nearest thing it does carry, the\n// outlined card: the same surface, 1dp outline variant rule and medium\n// corner, at least 160dp tall with 24dp of padding and its label centred in\n// body medium. Web's two departures from that card are kept. **The rule is\n// dashed**, since a solid one reads as a card holding content and a dashed one\n// as a place to put something. **Something over it fills it** with primary\n// container, the rule turning primary and solid, the pair a selected row\n// takes, so \"this is the target\" looks like \"this is the one chosen\". It\n// switches at once rather than over web's short transition, as a card's\n// press colours do.\n//\n// What a drop is depends on the platform, since neither iOS nor Android hands\n// React Native a drag from another app. **Under React Native Web it is HTML5\n// drag and drop**, as on web, through src/drop. **On iOS and Android the\n// target is a press target** that opens the chooser and hands `onDrop` what\n// was picked, as file drop items, so a call site writes one handler for both.\n// The drop operation it reports is `copy`, which is true of a pick as it is\n// of a drop from the desktop: the chooser hands the app a copy in its cache,\n// and the person's own file stays where it was. So a call site reading the\n// operation is told nothing a pick does not do. The press target lies under\n// what the target holds, so a button inside it still takes its own presses,\n// and VoiceOver reaches both rather than one.\n//\n// Disabled is web's: the rule and the label in on surface at the disabled\n// content opacity, over the surface, so a dashed rule at full strength stops\n// reading as somewhere to aim at, and nothing is taken.\n//\n// FileTrigger renders nothing of its own. The Button, IconButton, Fab or Chip\n// it wraps opens the chooser through src/button's default slot, the way a\n// button opens the overlay around it, as web's React Aria hands its\n// FileTrigger's press to whatever it wraps.\n\n// The least height a target takes, from web: room enough to aim at.\nconst MIN_HEIGHT = 160\n\nconst stylesOf = themedStyles(\n ({ colors, radii, spacing, stateLayerOpacity }) => {\n const disabled = withOpacity(\n colors.onSurface,\n stateLayerOpacity.disabledContent,\n )\n\n return StyleSheet.create({\n // The label, in the muted role, centred under the target's content.\n label: {\n color: colors.onSurfaceVariant,\n textAlign: 'center',\n },\n labelBox: {\n pointerEvents: 'none',\n },\n labelDisabled: {\n color: disabled,\n },\n labelOver: {\n color: colors.onPrimaryContainer,\n },\n // The press target fills the target under its content, inside the\n // rule. Its ring is drawn over the target's edge rather than around\n // it, as web's is, so a parent clipping its children never cuts the\n // outer half away: set 1dp into the press target, it covers the rule\n // and the 1dp inside it.\n press: {\n borderRadius: radii.md,\n },\n ring: {\n outlineOffset: -1,\n },\n root: {\n alignItems: 'center',\n backgroundColor: colors.surface,\n borderColor: colors.outlineVariant,\n borderRadius: radii.md,\n borderStyle: 'dashed',\n borderWidth: 1,\n boxSizing: 'border-box',\n gap: spacing.md,\n justifyContent: 'center',\n minHeight: MIN_HEIGHT,\n padding: spacing.xl,\n },\n rootDisabled: {\n borderColor: disabled,\n },\n rootOver: {\n backgroundColor: colors.primaryContainer,\n borderColor: colors.primary,\n borderStyle: 'solid',\n },\n })\n },\n)\n\ntype DropZoneProps = {\n /**\n * Names the target without drawing anything, for a page that already says\n * what it takes. Beats `label` as the name.\n */\n readonly 'aria-label'?: string\n /** What the target holds beside its label, such as a FileTrigger. */\n readonly children?: ReactNode\n /**\n * What a drop of these types would do, from the operations the drag\n * allows: `cancel` refuses it. A pick on iOS and Android allows `copy`\n * alone. Left out, the first the drag allows.\n */\n readonly getDropOperation?: (\n types: DragTypes,\n allowedOperations: readonly DropOperation[],\n ) => DropOperation\n /**\n * Takes nothing: no drop, and on iOS and Android no press, drawn faded.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * What the target says it is for, drawn inside it and used as its name. A\n * string rather than a node, since it is what names the target; anything\n * richer goes in `children`.\n */\n readonly label?: string\n /**\n * Called with what landed: what was dropped under React Native Web, what\n * was picked on iOS and Android.\n */\n readonly onDrop?: (event: DropEvent) => void\n /** Called once something the target takes comes over it. Under React Native Web alone. */\n readonly onDropEnter?: (event: DropEnterEvent) => void\n /** Called once what came over it leaves, or lands. Under React Native Web alone. */\n readonly onDropExit?: (event: DropExitEvent) => void\n readonly ref?: Ref<ComponentRef<typeof ViewType>>\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\ntype FileTriggerProps = {\n /** The MIME types the chooser offers, such as `image/png` or `image/*`. Every type when left out. */\n readonly acceptedFileTypes?: readonly string[]\n /** Whether more than one file can be picked. @default false */\n readonly allowsMultiple?: boolean\n /** The Button, IconButton, Fab or Chip that opens the chooser. */\n readonly children?: ReactNode\n /**\n * Opens the camera rather than the chooser, facing away from the person\n * for `environment` or towards them for `user`, as web's `capture` does.\n * It takes one photo, or a video where `acceptedFileTypes` names a video\n * type.\n */\n readonly defaultCamera?: 'environment' | 'user'\n /** Called with what was picked. Not called when the person backs out. */\n readonly onSelect?: (files: readonly PickedFile[]) => void\n}\n\n/**\n * A place to drop files. Under React Native Web it takes HTML5 drag and drop,\n * as kanso-ui's does; on iOS and Android, which hand an app no drag from\n * another, pressing it opens the file chooser, and `onDrop` is handed what\n * was picked. Either way `onDrop` is handed the items, which\n * `isFileDropItem` and `isTextDropItem` pick apart.\n *\n * ```tsx\n * <DropZone label=\"Drop here\" onDrop={handleDrop}>\n * <FileTrigger onSelect={handleSelect}>\n * <Button variant=\"outlined\">Label</Button>\n * </FileTrigger>\n * </DropZone>\n * ```\n *\n * It is drawn from the outlined card, with a dashed rule rather than a solid\n * one, and fills with the primary container while something is over it.\n * `label` both draws the words and names the target; `aria-label` names it\n * without drawing anything.\n *\n * The chooser is expo-document-picker's, which an app installs alongside the\n * library. Without it a press writes to the console that the package is\n * missing, and nothing opens.\n *\n * `style`, `ref` and `testID` land on the target itself, which is what a\n * layout places.\n */\nfunction DropZone({\n 'aria-label': ariaLabel,\n children,\n getDropOperation,\n isDisabled = false,\n label,\n onDrop,\n onDropEnter,\n onDropExit,\n ref,\n style,\n testID,\n}: DropZoneProps) {\n const theme = useTheme()\n const { colors, radii } = theme\n const styles = stylesOf(theme)\n const bodyMedium = useTypeRole('bodyMedium')\n const [isOver, setOver] = useState(false)\n const node = useRef<HostInstance | null>(null)\n const web = Platform.OS === 'web'\n const feedback = usePressFeedback({\n color: colors.onSurface,\n corners: { borderRadius: radii.md },\n disabled: isDisabled,\n })\n const handlersNow = useEffectEvent(() => ({\n getDropOperation,\n onDrop,\n onDropEnter,\n onDropExit,\n }))\n const disabledNow = useEffectEvent(() => isDisabled)\n const name = ariaLabel ?? label\n const over = isOver && !isDisabled\n\n useEffect(() => {\n if (!web) {\n preparePicker({})\n return undefined\n }\n\n const target = node.current\n\n if (!isDropTarget(target)) {\n return undefined\n }\n return watchDrops(\n target,\n () => handlersNow(),\n () => disabledNow(),\n setOver,\n )\n }, [web])\n\n return (\n <View\n // Under React Native Web the target names itself, as a group, and says\n // it is disabled, since there is no press target to carry either.\n aria-disabled={web && isDisabled ? true : undefined}\n aria-label={web ? name : undefined}\n ref={refsOf<HostInstance>(ref, node)}\n role={web && name !== undefined ? 'group' : undefined}\n style={composeStyles<ViewStyle>(\n styles.root,\n over ? styles.rootOver : undefined,\n isDisabled ? styles.rootDisabled : undefined,\n style,\n )}\n testID={testID}\n >\n {web ? null : (\n <Pressable\n {...feedback.handlers}\n aria-label={name}\n disabled={isDisabled}\n onPress={pressOf(getDropOperation, onDrop)}\n role=\"button\"\n style={composeStyles<ViewStyle>(\n StyleSheet.absoluteFill,\n styles.press,\n feedback.ring,\n feedback.ring === undefined ? undefined : styles.ring,\n )}\n >\n {feedback.layer}\n </Pressable>\n )}\n {label === undefined ? null : (\n // Hidden from a screen reader, which hears it as the target's name,\n // and from touches, which land on the press target under it.\n <View aria-hidden style={styles.labelBox}>\n <Text\n style={composeStyles<TextStyle>(\n bodyMedium,\n styles.label,\n over ? styles.labelOver : undefined,\n isDisabled ? styles.labelDisabled : undefined,\n )}\n >\n {label}\n </Text>\n </View>\n )}\n {children}\n </View>\n )\n}\n\n/**\n * Opens the file chooser from the button it wraps, and hands `onSelect`\n * what was picked.\n *\n * ```tsx\n * <FileTrigger acceptedFileTypes={['image/*']} onSelect={handleSelect}>\n * <Button>Label</Button>\n * </FileTrigger>\n * ```\n *\n * It renders nothing of its own, so it takes no `style`: what is seen is the\n * Button, IconButton, Fab or Chip it wraps, which opens the chooser after its\n * own `onPress`. `allowsMultiple` takes more than one file, and `defaultCamera`\n * opens the camera instead. kanso-ui's `acceptDirectory` is not here, since\n * neither iOS's chooser nor Android's picks a folder.\n *\n * The chooser is expo-document-picker's and the camera expo-image-picker's,\n * which an app installs alongside the library, the second only for\n * `defaultCamera`. Without the one it needs, a press writes to the console\n * which package is missing, and nothing opens.\n */\nfunction FileTrigger({\n acceptedFileTypes,\n allowsMultiple,\n children,\n defaultCamera,\n onSelect,\n}: FileTriggerProps) {\n useEffect(() => {\n preparePicker({ defaultCamera })\n }, [defaultCamera])\n\n const pick = () => {\n void pickThen(\n { acceptedFileTypes, allowsMultiple, defaultCamera },\n (files) => {\n onSelect?.(files)\n },\n )\n }\n\n return <ButtonSlotContext value={slotsOf(pick)}>{children}</ButtonSlotContext>\n}\n\n// What pressing the target does on iOS and Android: opens the chooser and\n// hands `onDrop` what was picked, as a drop that copies, where the call site\n// takes the copy. Built by a call rather than inline at the prop, which is\n// what react-perf's jsx-no-new-function-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction pressOf(\n getDropOperation: DropZoneProps['getDropOperation'],\n onDrop: DropZoneProps['onDrop'],\n) {\n return (event: GestureResponderEvent) => {\n const { locationX: x, locationY: y } = event.nativeEvent\n\n void pickThen({ allowsMultiple: true }, (files) => {\n const dropOperation = operationOf(\n { getDropOperation },\n typesOf(files.map((file) => file.type)),\n ['copy'],\n )\n\n if (dropOperation !== 'cancel') {\n onDrop?.({\n dropOperation,\n items: files.map(fileItemOf),\n type: 'drop',\n x,\n y,\n })\n }\n })\n }\n}\n\n// The slots a FileTrigger hands its button: its press in the default slot,\n// in place of any overlay's around it. Built by a call rather than inline at\n// the prop, which is what react-perf's jsx-no-new-object-as-prop is after;\n// the React Compiler memoises the result on its inputs.\nfunction slotsOf(pick: () => void): ButtonSlots {\n return { default: pick }\n}\n\nexport { DropZone, FileTrigger }\nexport type { DropZoneProps, FileTriggerProps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AAKC,IAAI,CAAC,GACtC,CAAC,MAAM,CACT;GAEA,IAAIH,kBAAkB,UACpBjE,SAAS;IACPiE;IACAI,OAAOzD,MAAMsD,IAAIhI,UAAU;IAC3BkI,MAAM;IACNP;IACAE;GACF,CAAC;EAEL,CAAC;CACH;AACF;AAMA,SAASJ,QAAQD,MAA+B;CAC9C,OAAO,EAAEY,SAASZ,KAAK;AACzB"}
|
|
@@ -74,7 +74,7 @@ type FabProps = (ButtonLinkForm | FabPressForm) & FabNaming & Omit<PressableProp
|
|
|
74
74
|
* `style`, `ref` and `testID` land on the `Pressable`, which is what a call
|
|
75
75
|
* site positions over its screen.
|
|
76
76
|
*/
|
|
77
|
-
declare function Fab({ children, delayLongPress, disableRipple, href, isDisabled, label, onBlur, onFocus, onHoverIn, onHoverOut, onLongPress, onPress, onPressIn, onPressOut, ref, size, slot, style, tone, type, variant, ...props }: FabProps): import("react").JSX.Element;
|
|
77
|
+
declare function Fab({ accessibilityHint, children, delayLongPress, disableRipple, href, isDisabled, label, onBlur, onFocus, onHoverIn, onHoverOut, onLongPress, onPress, onPressIn, onPressOut, ref, size, slot, style, tone, type, variant, ...props }: FabProps): import("react").JSX.Element;
|
|
78
78
|
//#endregion
|
|
79
79
|
export { Fab, type FabProps, type FabSize, type FabTone, type FabVariant };
|
|
80
80
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -39,7 +39,8 @@ const styles = StyleSheet.create({
|
|
|
39
39
|
* site positions over its screen.
|
|
40
40
|
*/
|
|
41
41
|
function Fab(t0) {
|
|
42
|
-
const $ = c(
|
|
42
|
+
const $ = c(47);
|
|
43
|
+
let accessibilityHint;
|
|
43
44
|
let children;
|
|
44
45
|
let delayLongPress;
|
|
45
46
|
let href;
|
|
@@ -63,53 +64,55 @@ function Fab(t0) {
|
|
|
63
64
|
let t5;
|
|
64
65
|
let type;
|
|
65
66
|
if ($[0] !== t0) {
|
|
66
|
-
({children, delayLongPress, disableRipple: t1, href, isDisabled: t2, label, onBlur, onFocus, onHoverIn, onHoverOut, onLongPress, onPress, onPressIn, onPressOut, ref, size: t3, slot, style, tone: t4, type, variant: t5, ...props} = t0);
|
|
67
|
+
({accessibilityHint, children, delayLongPress, disableRipple: t1, href, isDisabled: t2, label, onBlur, onFocus, onHoverIn, onHoverOut, onLongPress, onPress, onPressIn, onPressOut, ref, size: t3, slot, style, tone: t4, type, variant: t5, ...props} = t0);
|
|
67
68
|
$[0] = t0;
|
|
68
|
-
$[1] =
|
|
69
|
-
$[2] =
|
|
70
|
-
$[3] =
|
|
71
|
-
$[4] =
|
|
72
|
-
$[5] =
|
|
73
|
-
$[6] =
|
|
74
|
-
$[7] =
|
|
75
|
-
$[8] =
|
|
76
|
-
$[9] =
|
|
77
|
-
$[10] =
|
|
78
|
-
$[11] =
|
|
79
|
-
$[12] =
|
|
80
|
-
$[13] =
|
|
81
|
-
$[14] =
|
|
82
|
-
$[15] =
|
|
83
|
-
$[16] =
|
|
84
|
-
$[17] =
|
|
85
|
-
$[18] =
|
|
86
|
-
$[19] =
|
|
87
|
-
$[20] =
|
|
88
|
-
$[21] =
|
|
89
|
-
$[22] =
|
|
69
|
+
$[1] = accessibilityHint;
|
|
70
|
+
$[2] = children;
|
|
71
|
+
$[3] = delayLongPress;
|
|
72
|
+
$[4] = href;
|
|
73
|
+
$[5] = label;
|
|
74
|
+
$[6] = onBlur;
|
|
75
|
+
$[7] = onFocus;
|
|
76
|
+
$[8] = onHoverIn;
|
|
77
|
+
$[9] = onHoverOut;
|
|
78
|
+
$[10] = onLongPress;
|
|
79
|
+
$[11] = onPress;
|
|
80
|
+
$[12] = onPressIn;
|
|
81
|
+
$[13] = onPressOut;
|
|
82
|
+
$[14] = props;
|
|
83
|
+
$[15] = ref;
|
|
84
|
+
$[16] = slot;
|
|
85
|
+
$[17] = style;
|
|
86
|
+
$[18] = t1;
|
|
87
|
+
$[19] = t2;
|
|
88
|
+
$[20] = t3;
|
|
89
|
+
$[21] = t4;
|
|
90
|
+
$[22] = t5;
|
|
91
|
+
$[23] = type;
|
|
90
92
|
} else {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
accessibilityHint = $[1];
|
|
94
|
+
children = $[2];
|
|
95
|
+
delayLongPress = $[3];
|
|
96
|
+
href = $[4];
|
|
97
|
+
label = $[5];
|
|
98
|
+
onBlur = $[6];
|
|
99
|
+
onFocus = $[7];
|
|
100
|
+
onHoverIn = $[8];
|
|
101
|
+
onHoverOut = $[9];
|
|
102
|
+
onLongPress = $[10];
|
|
103
|
+
onPress = $[11];
|
|
104
|
+
onPressIn = $[12];
|
|
105
|
+
onPressOut = $[13];
|
|
106
|
+
props = $[14];
|
|
107
|
+
ref = $[15];
|
|
108
|
+
slot = $[16];
|
|
109
|
+
style = $[17];
|
|
110
|
+
t1 = $[18];
|
|
111
|
+
t2 = $[19];
|
|
112
|
+
t3 = $[20];
|
|
113
|
+
t4 = $[21];
|
|
114
|
+
t5 = $[22];
|
|
115
|
+
type = $[23];
|
|
113
116
|
}
|
|
114
117
|
const disableRipple = t1 === void 0 ? false : t1;
|
|
115
118
|
const isDisabled = t2 === void 0 ? false : t2;
|
|
@@ -120,7 +123,7 @@ function Fab(t0) {
|
|
|
120
123
|
const role = useTypeRole(EXTENDED_FAB_ROLES[size]);
|
|
121
124
|
const t6 = slot ?? "default";
|
|
122
125
|
let t7;
|
|
123
|
-
if ($[
|
|
126
|
+
if ($[24] !== href || $[25] !== onPress || $[26] !== t6 || $[27] !== type) {
|
|
124
127
|
t7 = {
|
|
125
128
|
defaultSelected: void 0,
|
|
126
129
|
href,
|
|
@@ -131,50 +134,62 @@ function Fab(t0) {
|
|
|
131
134
|
slot: t6,
|
|
132
135
|
type
|
|
133
136
|
};
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else t7 = $[
|
|
137
|
+
$[24] = href;
|
|
138
|
+
$[25] = onPress;
|
|
139
|
+
$[26] = t6;
|
|
140
|
+
$[27] = type;
|
|
141
|
+
$[28] = t7;
|
|
142
|
+
} else t7 = $[28];
|
|
140
143
|
const action = useButtonAction(t7);
|
|
141
144
|
let t8;
|
|
142
|
-
if ($[
|
|
145
|
+
if ($[29] !== accessibilityHint || $[30] !== delayLongPress || $[31] !== href || $[32] !== onHoverIn || $[33] !== onHoverOut || $[34] !== onLongPress || $[35] !== onPressIn || $[36] !== onPressOut || $[37] !== ref || $[38] !== slot) {
|
|
143
146
|
t8 = {
|
|
147
|
+
accessibilityHint,
|
|
144
148
|
delayLongPress,
|
|
145
149
|
href,
|
|
146
150
|
onHoverIn,
|
|
147
151
|
onHoverOut,
|
|
148
152
|
onLongPress,
|
|
153
|
+
onPressIn,
|
|
154
|
+
onPressOut,
|
|
149
155
|
ref,
|
|
150
156
|
slot
|
|
151
157
|
};
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
|
|
158
|
+
$[29] = accessibilityHint;
|
|
159
|
+
$[30] = delayLongPress;
|
|
160
|
+
$[31] = href;
|
|
161
|
+
$[32] = onHoverIn;
|
|
162
|
+
$[33] = onHoverOut;
|
|
163
|
+
$[34] = onLongPress;
|
|
164
|
+
$[35] = onPressIn;
|
|
165
|
+
$[36] = onPressOut;
|
|
166
|
+
$[37] = ref;
|
|
167
|
+
$[38] = slot;
|
|
168
|
+
$[39] = t8;
|
|
169
|
+
} else t8 = $[39];
|
|
161
170
|
const t9 = useSlotTrigger(t8);
|
|
162
171
|
let hoverIn;
|
|
163
172
|
let hoverOut;
|
|
164
173
|
let longPress;
|
|
174
|
+
let pressIn;
|
|
175
|
+
let pressOut;
|
|
165
176
|
let triggerProps;
|
|
166
|
-
if ($[
|
|
167
|
-
({onHoverIn: hoverIn, onHoverOut: hoverOut, onLongPress: longPress, ...triggerProps} = t9);
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
177
|
+
if ($[40] !== t9) {
|
|
178
|
+
({onHoverIn: hoverIn, onHoverOut: hoverOut, onLongPress: longPress, onPressIn: pressIn, onPressOut: pressOut, ...triggerProps} = t9);
|
|
179
|
+
$[40] = t9;
|
|
180
|
+
$[41] = hoverIn;
|
|
181
|
+
$[42] = hoverOut;
|
|
182
|
+
$[43] = longPress;
|
|
183
|
+
$[44] = pressIn;
|
|
184
|
+
$[45] = pressOut;
|
|
185
|
+
$[46] = triggerProps;
|
|
173
186
|
} else {
|
|
174
|
-
hoverIn = $[
|
|
175
|
-
hoverOut = $[
|
|
176
|
-
longPress = $[
|
|
177
|
-
|
|
187
|
+
hoverIn = $[41];
|
|
188
|
+
hoverOut = $[42];
|
|
189
|
+
longPress = $[43];
|
|
190
|
+
pressIn = $[44];
|
|
191
|
+
pressOut = $[45];
|
|
192
|
+
triggerProps = $[46];
|
|
178
193
|
}
|
|
179
194
|
const palettes = fabPalettesOf(theme);
|
|
180
195
|
const colors = isDisabled ? palettes.disabled : palettes[variant][tone];
|
|
@@ -186,8 +201,8 @@ function Fab(t0) {
|
|
|
186
201
|
onFocus,
|
|
187
202
|
onHoverIn: hoverIn,
|
|
188
203
|
onHoverOut: hoverOut,
|
|
189
|
-
onPressIn,
|
|
190
|
-
onPressOut
|
|
204
|
+
onPressIn: pressIn,
|
|
205
|
+
onPressOut: pressOut
|
|
191
206
|
});
|
|
192
207
|
const corner = fabCornersOf(theme)[size];
|
|
193
208
|
const isExtended = label !== void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","PressableProps","StyleProp","TextStyle","ViewStyle","AnimatedStyle","Text","NativeText","StyleSheet","View","ButtonLinkForm","ButtonPressForm","FabSize","FabTone","FabVariant","IconStyle","AnimatedPressable","buttonStyles","useButtonAction","useSlotTrigger","EXTENDED_FAB_ROLES","extendedFabSizesOf","FAB_ICON_SIZES","fabCornersOf","fabPalettesOf","fabShadowOf","fabSizesOf","IconStyleContext","usePressFeedback","useTheme","composeStyles","useTypeRole","FabNaming","label","FabPressForm","Omit","isPending","pendingLabel","FabProps","children","disableRipple","isDisabled","ref","size","style","tone","variant","styles","create","base","alignItems","flexDirection","flexShrink","justifyContent","icon","Fab","t0","$","_c","delayLongPress","href","onBlur","onFocus","onHoverIn","onHoverOut","onLongPress","onPress","onPressIn","onPressOut","props","slot","t1","t2","t3","t4","t5","type","undefined","theme","role","t6","t7","defaultSelected","isSelected","isToggle","onChange","action","t8","t9","hoverIn","hoverOut","longPress","triggerProps","palettes","colors","disabled","feedback","color","content","corner","isExtended","handlers","container","ring","clip","layer","iconStyleOf","_c","NativeText"],"sources":["../../../src/components/fab/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n TextStyle,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\n\nimport { Text as NativeText, StyleSheet, View } from 'react-native'\n\nimport type { ButtonLinkForm, ButtonPressForm } from '../../button'\nimport type { FabSize, FabTone, FabVariant } from '../../fab'\nimport type { IconStyle } from '../../glyphs/icon-style'\n\nimport {\n AnimatedPressable,\n buttonStyles,\n useButtonAction,\n useSlotTrigger,\n} from '../../button'\nimport {\n EXTENDED_FAB_ROLES,\n extendedFabSizesOf,\n FAB_ICON_SIZES,\n fabCornersOf,\n fabPalettesOf,\n fabShadowOf,\n fabSizesOf,\n} from '../../fab'\nimport { IconStyleContext } from '../../glyphs/icon-style'\nimport { usePressFeedback } from '../../press'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\n\n// kanso-ui's Fab: the FAB page's floating action button, and the extended\n// FAB page's form of it with a label. A screen's primary action, raised over\n// the content on the pages' level 3 shadow and lifted to level 4 under a\n// hovering pointer, which is an iPad's or an Android mouse's, since a finger\n// never hovers.\n//\n// Three sizes, the pages' FAB, medium FAB and large FAB: `md` is 56dp with a\n// 24dp icon and a 16dp corner, `lg` 80dp with 28dp and 20dp, and `xl` 96dp\n// with 36dp and 28dp. The extended form keeps the size's height and corner\n// and sets a label after the icon in the size's type role, title medium,\n// title large and headline small, with 16dp, 26dp and 28dp of padding and\n// 8dp, 12dp and 16dp before the label. The 80dp size, the 20dp corner and\n// the 26dp and 28dp paddings fall between steps of their scales and are\n// written out. The pages' small FAB is gone from the newer set, so there is\n// no `xs`.\n//\n// Six colour pairs, by `tone` and `variant`: `tonal` draws the tone's\n// container pair, primary container being the pages' default, and `filled`\n// the tone itself, as Button's two variants of those names do.\n//\n// The hover, focus and pressed layers and the ripple are src/press's, in the\n// icon's colour over the container, as Button's are. The pages give no\n// disabled FAB; a disabled one takes the container every disabled button\n// takes, on-surface at the two disabled opacities, and drops its shadow.\n//\n// Unlike Button, the corner does not morph: the pages draw the FAB at one\n// shape in every state, as web does. Web's forced-colours rule has no\n// counterpart on iOS or Android and is not drawn.\n//\n// It is placed as any view is. A column stretches the extended form as it\n// does a Button, so a FAB floating over a screen takes its place from the\n// call site's `style`.\n//\n// What a press does, the link form and the slot it fills in an overlay are\n// src/button's, shared with Button and IconButton. The metrics and colours\n// are src/fab's, shared with FabMenu's FAB.\n\ntype FabNaming =\n | {\n /**\n * What the FAB does, in words. A FAB without a `label` is an icon\n * alone, which has no name of its own, so it needs this; with a\n * `label` the label is its name.\n */\n readonly 'aria-label': string\n readonly label?: never\n }\n | {\n readonly 'aria-label'?: string\n /**\n * A label after the icon, which makes this the extended FAB: as tall\n * as the size, as wide as what it holds.\n */\n readonly label: ReactNode\n }\n\n// A plain button's form, without the pending state web's FAB leaves out.\n// The two are named `never`, so a FAB given them does not compile.\ntype FabPressForm = Omit<ButtonPressForm, 'isPending' | 'pendingLabel'> & {\n readonly isPending?: never\n readonly pendingLabel?: never\n}\n\ntype FabProps = (ButtonLinkForm | FabPressForm) &\n FabNaming &\n Omit<PressableProps, 'aria-label' | 'children' | 'disabled' | 'style'> & {\n /**\n * The FAB's icon. The FAB hands it its colour and the size's icon size\n * through `useIconStyle()`.\n */\n readonly children?: ReactNode\n /**\n * Draws no press ripple. The state layers are unaffected.\n * @default false\n */\n readonly disableRipple?: boolean\n /**\n * Draws the FAB disabled, without its shadow, and takes no presses.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * The pages' three sizes: `md` the FAB at 56dp, `lg` the medium FAB at\n * 80dp and `xl` the large FAB at 96dp.\n * @default 'md'\n */\n readonly size?: FabSize\n readonly style?: StyleProp<ViewStyle>\n /**\n * The colour role the FAB is drawn in.\n * @default 'primary'\n */\n readonly tone?: FabTone\n /**\n * `tonal` draws the tone's container pair, the pages' default; `filled`\n * draws the tone itself.\n * @default 'tonal'\n */\n readonly variant?: FabVariant\n }\n\nconst styles = StyleSheet.create({\n // The icon and the label sit in the middle of the container, and a row\n // never squeezes it.\n base: {\n alignItems: 'center',\n flexDirection: 'row',\n flexShrink: 0,\n justifyContent: 'center',\n },\n icon: {\n alignItems: 'center',\n flexShrink: 0,\n justifyContent: 'center',\n },\n label: {\n flexShrink: 1,\n },\n})\n\n/**\n * A screen's primary action, raised over its content. Its icon is its\n * children; given a `label` it is the extended FAB, with the label after the\n * icon. Given `href` it is a link with the same appearance.\n *\n * ```tsx\n * <Fab aria-label=\"Label\">\n * <PlusIcon />\n * </Fab>\n * ```\n *\n * Without a `label` it is an icon alone, so `aria-label` is required there.\n * `style`, `ref` and `testID` land on the `Pressable`, which is what a call\n * site positions over its screen.\n */\nfunction Fab({\n children,\n delayLongPress,\n disableRipple = false,\n href,\n isDisabled = false,\n label,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n ref,\n size = 'md',\n slot,\n style,\n tone = 'primary',\n type,\n variant = 'tonal',\n ...props\n}: FabProps) {\n const theme = useTheme()\n const role = useTypeRole(EXTENDED_FAB_ROLES[size])\n const action = useButtonAction({\n defaultSelected: undefined,\n href,\n isSelected: undefined,\n isToggle: false,\n onChange: undefined,\n onPress,\n slot: slot ?? 'default',\n type,\n })\n const {\n onHoverIn: hoverIn,\n onHoverOut: hoverOut,\n onLongPress: longPress,\n ...triggerProps\n } = useSlotTrigger({\n delayLongPress,\n href,\n onHoverIn,\n onHoverOut,\n onLongPress,\n ref,\n slot,\n })\n const palettes = fabPalettesOf(theme)\n const colors = isDisabled ? palettes.disabled : palettes[variant][tone]\n const feedback = usePressFeedback({\n color: colors.content,\n disabled: isDisabled,\n disableRipple,\n onBlur,\n onFocus,\n onHoverIn: hoverIn,\n onHoverOut: hoverOut,\n onPressIn,\n onPressOut,\n })\n const corner = fabCornersOf(theme)[size]\n const isExtended = label !== undefined\n\n return (\n <AnimatedPressable\n role={href === undefined ? 'button' : 'link'}\n {...props}\n {...triggerProps}\n {...feedback.handlers}\n disabled={isDisabled}\n onLongPress={longPress}\n onPress={action.onPress}\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.base,\n isExtended ? extendedFabSizesOf(theme)[size] : fabSizesOf(theme)[size],\n corner,\n colors.container,\n fabShadowOf(feedback, isDisabled, theme),\n feedback.ring,\n style,\n )}\n >\n <View style={composeStyles<ViewStyle>(buttonStyles.clip, corner)}>\n {feedback.layer}\n </View>\n {children === undefined ? null : (\n <View style={styles.icon}>\n <IconStyleContext value={iconStyleOf(colors.content, size)}>\n {children}\n </IconStyleContext>\n </View>\n )}\n {isExtended ? (\n <NativeText\n style={composeStyles<TextStyle>(role, styles.label, colors.label)}\n >\n {label}\n </NativeText>\n ) : null}\n </AnimatedPressable>\n )\n}\n\nfunction iconStyleOf(color: string, size: FabSize): IconStyle {\n return { color, size: FAB_ICON_SIZES[size] }\n}\n\nexport { Fab }\nexport type { FabProps, FabSize, FabTone, FabVariant }\n"],"mappings":";;;;;;;;;;;AA0IA,MAAMiD,SAASvC,WAAWwC,OAAO;CAG/BC,MAAM;EACJC,YAAY;EACZC,eAAe;EACfC,YAAY;EACZC,gBAAgB;CAClB;CACAC,MAAM;EACJJ,YAAY;EACZE,YAAY;EACZC,gBAAgB;CAClB;CACApB,OAAO,EACLmB,YAAY,EACd;AACF,CAAC;;;;;;;;;;;;;;;;AAiBD,SAAAG,IAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAnB;CAAA,IAAAoB;CAAA,IAAAC;CAAA,IAAA3B;CAAA,IAAA4B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAA3B;CAAA,IAAA4B;CAAA,IAAA1B;CAAA,IAAA2B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAnB,EAAA,OAAAD,IAAA;EAAa,CAAA,CAAAjB,UAAAoB,gBAAAnB,eAAA+B,IAAAX,MAAAnB,YAAA+B,IAAAvC,OAAA4B,QAAAC,SAAAC,WAAAC,YAAAC,aAAAC,SAAAC,WAAAC,YAAA1B,KAAAC,MAAA8B,IAAAH,MAAA1B,OAAAC,MAAA6B,IAAAE,MAAA9B,SAAA6B,IAAA,GAAAN,SAAAb;EAuBFC,EAAA,KAAAD;EAAAC,EAAA,KAAAlB;EAAAkB,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAxB;EAAAwB,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,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","names":["ComponentRef","ReactNode","Ref","PressableProps","StyleProp","TextStyle","ViewStyle","AnimatedStyle","Text","NativeText","StyleSheet","View","ButtonLinkForm","ButtonPressForm","FabSize","FabTone","FabVariant","IconStyle","AnimatedPressable","buttonStyles","useButtonAction","useSlotTrigger","EXTENDED_FAB_ROLES","extendedFabSizesOf","FAB_ICON_SIZES","fabCornersOf","fabPalettesOf","fabShadowOf","fabSizesOf","IconStyleContext","usePressFeedback","useTheme","composeStyles","useTypeRole","FabNaming","label","FabPressForm","Omit","isPending","pendingLabel","FabProps","children","disableRipple","isDisabled","ref","size","style","tone","variant","styles","create","base","alignItems","flexDirection","flexShrink","justifyContent","icon","Fab","t0","$","_c","accessibilityHint","delayLongPress","href","onBlur","onFocus","onHoverIn","onHoverOut","onLongPress","onPress","onPressIn","onPressOut","props","slot","t1","t2","t3","t4","t5","type","undefined","theme","role","t6","t7","defaultSelected","isSelected","isToggle","onChange","action","t8","t9","hoverIn","hoverOut","longPress","pressIn","pressOut","triggerProps","palettes","colors","disabled","feedback","color","content","corner","isExtended","handlers","container","ring","clip","layer","iconStyleOf","_c","NativeText"],"sources":["../../../src/components/fab/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n TextStyle,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\n\nimport { Text as NativeText, StyleSheet, View } from 'react-native'\n\nimport type { ButtonLinkForm, ButtonPressForm } from '../../button'\nimport type { FabSize, FabTone, FabVariant } from '../../fab'\nimport type { IconStyle } from '../../glyphs/icon-style'\n\nimport {\n AnimatedPressable,\n buttonStyles,\n useButtonAction,\n useSlotTrigger,\n} from '../../button'\nimport {\n EXTENDED_FAB_ROLES,\n extendedFabSizesOf,\n FAB_ICON_SIZES,\n fabCornersOf,\n fabPalettesOf,\n fabShadowOf,\n fabSizesOf,\n} from '../../fab'\nimport { IconStyleContext } from '../../glyphs/icon-style'\nimport { usePressFeedback } from '../../press'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\n\n// kanso-ui's Fab: the FAB page's floating action button, and the extended\n// FAB page's form of it with a label. A screen's primary action, raised over\n// the content on the pages' level 3 shadow and lifted to level 4 under a\n// hovering pointer, which is an iPad's or an Android mouse's, since a finger\n// never hovers.\n//\n// Three sizes, the pages' FAB, medium FAB and large FAB: `md` is 56dp with a\n// 24dp icon and a 16dp corner, `lg` 80dp with 28dp and 20dp, and `xl` 96dp\n// with 36dp and 28dp. The extended form keeps the size's height and corner\n// and sets a label after the icon in the size's type role, title medium,\n// title large and headline small, with 16dp, 26dp and 28dp of padding and\n// 8dp, 12dp and 16dp before the label. The 80dp size, the 20dp corner and\n// the 26dp and 28dp paddings fall between steps of their scales and are\n// written out. The pages' small FAB is gone from the newer set, so there is\n// no `xs`.\n//\n// Six colour pairs, by `tone` and `variant`: `tonal` draws the tone's\n// container pair, primary container being the pages' default, and `filled`\n// the tone itself, as Button's two variants of those names do.\n//\n// The hover, focus and pressed layers and the ripple are src/press's, in the\n// icon's colour over the container, as Button's are. The pages give no\n// disabled FAB; a disabled one takes the container every disabled button\n// takes, on-surface at the two disabled opacities, and drops its shadow.\n//\n// Unlike Button, the corner does not morph: the pages draw the FAB at one\n// shape in every state, as web does. Web's forced-colours rule has no\n// counterpart on iOS or Android and is not drawn.\n//\n// It is placed as any view is. A column stretches the extended form as it\n// does a Button, so a FAB floating over a screen takes its place from the\n// call site's `style`.\n//\n// What a press does, the link form and the slot it fills in an overlay are\n// src/button's, shared with Button and IconButton. The metrics and colours\n// are src/fab's, shared with FabMenu's FAB.\n\ntype FabNaming =\n | {\n /**\n * What the FAB does, in words. A FAB without a `label` is an icon\n * alone, which has no name of its own, so it needs this; with a\n * `label` the label is its name.\n */\n readonly 'aria-label': string\n readonly label?: never\n }\n | {\n readonly 'aria-label'?: string\n /**\n * A label after the icon, which makes this the extended FAB: as tall\n * as the size, as wide as what it holds.\n */\n readonly label: ReactNode\n }\n\n// A plain button's form, without the pending state web's FAB leaves out.\n// The two are named `never`, so a FAB given them does not compile.\ntype FabPressForm = Omit<ButtonPressForm, 'isPending' | 'pendingLabel'> & {\n readonly isPending?: never\n readonly pendingLabel?: never\n}\n\ntype FabProps = (ButtonLinkForm | FabPressForm) &\n FabNaming &\n Omit<PressableProps, 'aria-label' | 'children' | 'disabled' | 'style'> & {\n /**\n * The FAB's icon. The FAB hands it its colour and the size's icon size\n * through `useIconStyle()`.\n */\n readonly children?: ReactNode\n /**\n * Draws no press ripple. The state layers are unaffected.\n * @default false\n */\n readonly disableRipple?: boolean\n /**\n * Draws the FAB disabled, without its shadow, and takes no presses.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * The pages' three sizes: `md` the FAB at 56dp, `lg` the medium FAB at\n * 80dp and `xl` the large FAB at 96dp.\n * @default 'md'\n */\n readonly size?: FabSize\n readonly style?: StyleProp<ViewStyle>\n /**\n * The colour role the FAB is drawn in.\n * @default 'primary'\n */\n readonly tone?: FabTone\n /**\n * `tonal` draws the tone's container pair, the pages' default; `filled`\n * draws the tone itself.\n * @default 'tonal'\n */\n readonly variant?: FabVariant\n }\n\nconst styles = StyleSheet.create({\n // The icon and the label sit in the middle of the container, and a row\n // never squeezes it.\n base: {\n alignItems: 'center',\n flexDirection: 'row',\n flexShrink: 0,\n justifyContent: 'center',\n },\n icon: {\n alignItems: 'center',\n flexShrink: 0,\n justifyContent: 'center',\n },\n label: {\n flexShrink: 1,\n },\n})\n\n/**\n * A screen's primary action, raised over its content. Its icon is its\n * children; given a `label` it is the extended FAB, with the label after the\n * icon. Given `href` it is a link with the same appearance.\n *\n * ```tsx\n * <Fab aria-label=\"Label\">\n * <PlusIcon />\n * </Fab>\n * ```\n *\n * Without a `label` it is an icon alone, so `aria-label` is required there.\n * `style`, `ref` and `testID` land on the `Pressable`, which is what a call\n * site positions over its screen.\n */\nfunction Fab({\n accessibilityHint,\n children,\n delayLongPress,\n disableRipple = false,\n href,\n isDisabled = false,\n label,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n ref,\n size = 'md',\n slot,\n style,\n tone = 'primary',\n type,\n variant = 'tonal',\n ...props\n}: FabProps) {\n const theme = useTheme()\n const role = useTypeRole(EXTENDED_FAB_ROLES[size])\n const action = useButtonAction({\n defaultSelected: undefined,\n href,\n isSelected: undefined,\n isToggle: false,\n onChange: undefined,\n onPress,\n slot: slot ?? 'default',\n type,\n })\n const {\n onHoverIn: hoverIn,\n onHoverOut: hoverOut,\n onLongPress: longPress,\n onPressIn: pressIn,\n onPressOut: pressOut,\n ...triggerProps\n } = useSlotTrigger({\n accessibilityHint,\n delayLongPress,\n href,\n onHoverIn,\n onHoverOut,\n onLongPress,\n onPressIn,\n onPressOut,\n ref,\n slot,\n })\n const palettes = fabPalettesOf(theme)\n const colors = isDisabled ? palettes.disabled : palettes[variant][tone]\n const feedback = usePressFeedback({\n color: colors.content,\n disabled: isDisabled,\n disableRipple,\n onBlur,\n onFocus,\n onHoverIn: hoverIn,\n onHoverOut: hoverOut,\n onPressIn: pressIn,\n onPressOut: pressOut,\n })\n const corner = fabCornersOf(theme)[size]\n const isExtended = label !== undefined\n\n return (\n <AnimatedPressable\n role={href === undefined ? 'button' : 'link'}\n {...props}\n {...triggerProps}\n {...feedback.handlers}\n disabled={isDisabled}\n onLongPress={longPress}\n onPress={action.onPress}\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.base,\n isExtended ? extendedFabSizesOf(theme)[size] : fabSizesOf(theme)[size],\n corner,\n colors.container,\n fabShadowOf(feedback, isDisabled, theme),\n feedback.ring,\n style,\n )}\n >\n <View style={composeStyles<ViewStyle>(buttonStyles.clip, corner)}>\n {feedback.layer}\n </View>\n {children === undefined ? null : (\n <View style={styles.icon}>\n <IconStyleContext value={iconStyleOf(colors.content, size)}>\n {children}\n </IconStyleContext>\n </View>\n )}\n {isExtended ? (\n <NativeText\n style={composeStyles<TextStyle>(role, styles.label, colors.label)}\n >\n {label}\n </NativeText>\n ) : null}\n </AnimatedPressable>\n )\n}\n\nfunction iconStyleOf(color: string, size: FabSize): IconStyle {\n return { color, size: FAB_ICON_SIZES[size] }\n}\n\nexport { Fab }\nexport type { FabProps, FabSize, FabTone, FabVariant }\n"],"mappings":";;;;;;;;;;;AA0IA,MAAMiD,SAASvC,WAAWwC,OAAO;CAG/BC,MAAM;EACJC,YAAY;EACZC,eAAe;EACfC,YAAY;EACZC,gBAAgB;CAClB;CACAC,MAAM;EACJJ,YAAY;EACZE,YAAY;EACZC,gBAAgB;CAClB;CACApB,OAAO,EACLmB,YAAY,EACd;AACF,CAAC;;;;;;;;;;;;;;;;AAiBD,SAAAG,IAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAApB;CAAA,IAAAqB;CAAA,IAAAC;CAAA,IAAA5B;CAAA,IAAA6B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAA5B;CAAA,IAAA6B;CAAA,IAAA3B;CAAA,IAAA4B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAApB,EAAA,OAAAD,IAAA;EAAa,CAAA,CAAAG,mBAAApB,UAAAqB,gBAAApB,eAAAgC,IAAAX,MAAApB,YAAAgC,IAAAxC,OAAA6B,QAAAC,SAAAC,WAAAC,YAAAC,aAAAC,SAAAC,WAAAC,YAAA3B,KAAAC,MAAA+B,IAAAH,MAAA3B,OAAAC,MAAA8B,IAAAE,MAAA/B,SAAA8B,IAAA,GAAAN,SAAAd;EAwBFC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAlB;EAAAkB,EAAA,KAAAG;EAAAH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S;GADN,CAAA;GAGJrE,aAAauC,KAAAA,IAAb,OACC,oBAAC,MAAD;IAAa,OAAA/B,OAAMO;IACjB,UAAA,oBAAC,kBAAD;KAAyB,OAAAuD,YAAYZ,OAAMI,SAAU1D,IAAI;KACtDJ;IADc,CAAA;GADd,CAAA;GAMNgE,aACC,oBAACQ,MAAD;IACS,OAAAjF,cAAyBkD,MAAMjC,OAAMd,OAAQgE,OAAMhE,KAAM;IAE/DA,UAAAA;GAHQ,CAAA,IADZ;EA5Be;;AAmCE;AAIxB,SAAS4E,YAAYT,OAAezD,MAA0B;CAC5D,OAAO;EAAEyD;EAAOzD,MAAMrB,eAAeqB;CAAM;AAC7C"}
|
|
@@ -17,8 +17,9 @@ type FormProps = {
|
|
|
17
17
|
* Called with the values when the form is submitted: each field with a
|
|
18
18
|
* `name` and not disabled, as the string a web form submits for it, so a
|
|
19
19
|
* number field's value is its number written out, and an empty one is
|
|
20
|
-
* `''`.
|
|
21
|
-
*
|
|
20
|
+
* `''`. A checkbox group's is the list of its ticked entries' values, an
|
|
21
|
+
* empty list while none is ticked. Under `native` it is not called while a
|
|
22
|
+
* field blocks the submission.
|
|
22
23
|
*/
|
|
23
24
|
readonly onSubmit?: (values: FormValues) => void;
|
|
24
25
|
readonly ref?: Ref<FormHandle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","Ref","useImperativeHandle","useMemo","useState","FormValidationBehavior","FormValues","ValidationErrors","createRegistry","FIELD_VALIDATION_BEHAVIOR","FormContext","submitOf","FormHandle","requestSubmit","FormProps","children","onSubmit","values","ref","validationBehavior","validationErrors","NO_ERRORS","Form","t0","$","_c","t1","t2","undefined","registry","t3","t4","state","t5","t6","t7","_c"],"sources":["../../../src/components/form/index.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react'\n\nimport { useImperativeHandle, useMemo, useState } from 'react'\n\nimport type {\n FormValidationBehavior,\n FormValues,\n ValidationErrors,\n} from '../../form'\n\nimport {\n createRegistry,\n FIELD_VALIDATION_BEHAVIOR,\n FormContext,\n submitOf,\n} from '../../form'\n\n// No Material Design page of its own, as on web: a form is the fields inside\n// it, and the text fields page is what each of them draws. The error a form\n// reports lands in the field's supporting text, in the error role, under the\n// box.\n//\n// Native has no form element, so this is a context around its fields rather\n// than an element of its own. It draws nothing and lays nothing out; a Stack\n// inside it is what spaces the fields. It hands each field inside it two\n// things, as React Aria's Form does on web: `validationErrors`, keyed by each\n// field's `name`, which is how a server's answer reaches the fields without\n// any of them changing, and `validationBehavior`, which every field reads in\n// place of its own. And it reserves each field's message line, so an error\n// that arrives later moves nothing below the field.\n//\n// Native has no browser to validate or submit either, so the form does both.\n// A Button with `type=\"submit\"` inside it submits it, as does\n// `requestSubmit()` on its ref, which is how the keyboard's return key does.\n\n/** What a form's ref holds. */\ntype FormHandle = {\n /**\n * Submits the form, as a Button with `type=\"submit\"` inside it does: under\n * `native` it is held back while a field blocks it, and otherwise\n * `onSubmit` is handed the values. Named after the web form's method that\n * does the same.\n */\n readonly requestSubmit: () => void\n}\n\ntype FormProps = {\n readonly children?: ReactNode\n /**\n * Called with the values when the form is submitted: each field with a\n * `name` and not disabled, as the string a web form submits for it, so a\n * number field's value is its number written out, and an empty one is\n * `''`. Under `native` it is not called while a field blocks the
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","Ref","useImperativeHandle","useMemo","useState","FormValidationBehavior","FormValues","ValidationErrors","createRegistry","FIELD_VALIDATION_BEHAVIOR","FormContext","submitOf","FormHandle","requestSubmit","FormProps","children","onSubmit","values","ref","validationBehavior","validationErrors","NO_ERRORS","Form","t0","$","_c","t1","t2","undefined","registry","t3","t4","state","t5","t6","t7","_c"],"sources":["../../../src/components/form/index.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react'\n\nimport { useImperativeHandle, useMemo, useState } from 'react'\n\nimport type {\n FormValidationBehavior,\n FormValues,\n ValidationErrors,\n} from '../../form'\n\nimport {\n createRegistry,\n FIELD_VALIDATION_BEHAVIOR,\n FormContext,\n submitOf,\n} from '../../form'\n\n// No Material Design page of its own, as on web: a form is the fields inside\n// it, and the text fields page is what each of them draws. The error a form\n// reports lands in the field's supporting text, in the error role, under the\n// box.\n//\n// Native has no form element, so this is a context around its fields rather\n// than an element of its own. It draws nothing and lays nothing out; a Stack\n// inside it is what spaces the fields. It hands each field inside it two\n// things, as React Aria's Form does on web: `validationErrors`, keyed by each\n// field's `name`, which is how a server's answer reaches the fields without\n// any of them changing, and `validationBehavior`, which every field reads in\n// place of its own. And it reserves each field's message line, so an error\n// that arrives later moves nothing below the field.\n//\n// Native has no browser to validate or submit either, so the form does both.\n// A Button with `type=\"submit\"` inside it submits it, as does\n// `requestSubmit()` on its ref, which is how the keyboard's return key does.\n\n/** What a form's ref holds. */\ntype FormHandle = {\n /**\n * Submits the form, as a Button with `type=\"submit\"` inside it does: under\n * `native` it is held back while a field blocks it, and otherwise\n * `onSubmit` is handed the values. Named after the web form's method that\n * does the same.\n */\n readonly requestSubmit: () => void\n}\n\ntype FormProps = {\n readonly children?: ReactNode\n /**\n * Called with the values when the form is submitted: each field with a\n * `name` and not disabled, as the string a web form submits for it, so a\n * number field's value is its number written out, and an empty one is\n * `''`. A checkbox group's is the list of its ticked entries' values, an\n * empty list while none is ticked. Under `native` it is not called while a\n * field blocks the submission.\n */\n readonly onSubmit?: (values: FormValues) => void\n readonly ref?: Ref<FormHandle>\n /**\n * How the fields inside validate. `aria` marks a field invalid and shows\n * its error as soon as the field says so, through its `validate`, and\n * lets the form submit regardless. `native` holds the submission back\n * while a field is required and empty or rejected by its `validate`, shows\n * each such field's error once submission is tried, and focuses the first\n * of them.\n *\n * Under `aria`, moving focus after a server answers is the call site's.\n * Each error is announced as it appears under its field, but nothing\n * moves, because no part of the form knows a round trip happened:\n * `validationErrors` is a prop rather than an event, so a form cannot tell\n * a submission coming back from a first render that was given errors to\n * begin with. Focus the first field that came back invalid through its\n * `inputRef`, as the Async submit story does.\n * @default 'aria'\n */\n readonly validationBehavior?: FormValidationBehavior\n /**\n * Errors to show under the fields, keyed by each field's `name`, such as\n * what a server sent back: one message, or several shown as one line. A\n * field's error stays until the field is edited, and a new object shows\n * them all again.\n */\n readonly validationErrors?: ValidationErrors\n}\n\nconst NO_ERRORS: ValidationErrors = {}\n\n/**\n * A form: the fields inside it and what they are told about validation. Pass\n * `validationErrors`, an object keyed by field `name`, to show what a server\n * sent back under each field, and `validationBehavior=\"native\"` to hold the\n * submission back while a required field is empty or a field's `validate`\n * rejects its value. A Button with `type=\"submit\"` inside it submits it, and\n * `onSubmit` is handed the values by name.\n *\n * ```tsx\n * <Form onSubmit={(values) => save(values)}>\n * <Stack gap=\"md\">\n * <TextField label=\"Headline\" name=\"headline\" />\n * <Button type=\"submit\">Save changes</Button>\n * </Stack>\n * </Form>\n * ```\n *\n * Handing `validationErrors` back from a submission is where a reader has to\n * be told something arrived: see `validationBehavior` for what the form does\n * and what it leaves to the call site.\n *\n * A form also reserves each field's message line. A field on its own draws\n * that line only once it has something to say, so an error arriving after a\n * submit or an async check makes the field taller and moves everything below\n * it down the screen. Inside a form the line is there from the start, empty,\n * and nothing moves when it fills.\n *\n * It draws nothing, so it takes no `style`; its ref is a handle whose\n * `requestSubmit()` submits it.\n */\nfunction Form({\n children,\n onSubmit,\n ref,\n validationBehavior = FIELD_VALIDATION_BEHAVIOR,\n validationErrors = NO_ERRORS,\n}: FormProps) {\n const [registry] = useState(createRegistry)\n const requestSubmit = submitOf(registry, validationBehavior, onSubmit)\n const state = useMemo(\n () => ({ registry, requestSubmit, validationBehavior, validationErrors }),\n [registry, requestSubmit, validationBehavior, validationErrors],\n )\n\n useImperativeHandle(ref, () => ({ requestSubmit }), [requestSubmit])\n\n return <FormContext value={state}>{children}</FormContext>\n}\n\nexport { Form }\nexport type { FormHandle, FormProps }\n"],"mappings":";;;;;AAqFA,MAAMqB,YAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCrC,SAAAC,KAAAC,IAAA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QjB;EAAhB,CAAA;EAAuCS,EAAA,MAAAT;EAAAS,EAAA,MAAAQ;EAAAR,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAAnDW;AAAmD"}
|
|
@@ -19,6 +19,8 @@ type IconButtonProps = (ButtonLinkForm | ButtonPressForm | ButtonToggleForm) & O
|
|
|
19
19
|
* @default false
|
|
20
20
|
*/
|
|
21
21
|
readonly disableRipple?: boolean;
|
|
22
|
+
/** The key a ButtonGroup that selects reports the button by. */
|
|
23
|
+
readonly id?: string;
|
|
22
24
|
/**
|
|
23
25
|
* Draws the button disabled, and takes no presses.
|
|
24
26
|
* @default false
|
|
@@ -30,7 +32,7 @@ type IconButtonProps = (ButtonLinkForm | ButtonPressForm | ButtonToggleForm) & O
|
|
|
30
32
|
* the icon buttons spec page's XS to XL, and the same heights `Button`
|
|
31
33
|
* uses, so the two line up beside each other in a row. The icon is 20dp,
|
|
32
34
|
* 24dp, 24dp, 32dp and 40dp in turn.
|
|
33
|
-
* @default 'md'
|
|
35
|
+
* @default the size of the ButtonGroup around it, else 'md'
|
|
34
36
|
*/
|
|
35
37
|
readonly size?: IconButtonSize;
|
|
36
38
|
readonly style?: StyleProp<ViewStyle>;
|
|
@@ -62,7 +64,7 @@ type IconButtonVariant = 'filled' | 'outlined' | 'standard' | 'tonal';
|
|
|
62
64
|
* through `hitSlop`, which a `hitSlop` of the call site's own replaces.
|
|
63
65
|
* `style`, `ref` and `testID` land on the `Pressable`.
|
|
64
66
|
*/
|
|
65
|
-
declare function IconButton({ children, defaultSelected, delayLongPress, disableRipple, hitSlop: ownHitSlop, href, isDisabled, isPending, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onLongPress, onPress, onPressIn, onPressOut, pendingLabel, ref, size, slot, style, type, variant, ...props }: IconButtonProps): import("react").JSX.Element;
|
|
67
|
+
declare function IconButton({ accessibilityHint, children, defaultSelected, delayLongPress, disableRipple, hitSlop: ownHitSlop, href, id, isDisabled: ownDisabled, isPending, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onLongPress, onPress, onPressIn, onPressOut, pendingLabel, ref, size: ownSize, slot, style, type, variant, ...props }: IconButtonProps): import("react").JSX.Element;
|
|
66
68
|
//#endregion
|
|
67
69
|
export { IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant };
|
|
68
70
|
//# sourceMappingURL=index.d.ts.map
|