@ankhorage/zora 1.2.0 → 1.3.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/CHANGELOG.md +6 -0
- package/README.md +72 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/patterns/selection/SelectableItem.d.ts +4 -0
- package/dist/patterns/selection/SelectableItem.d.ts.map +1 -0
- package/dist/patterns/selection/SelectableItem.js +72 -0
- package/dist/patterns/selection/SelectableItem.js.map +1 -0
- package/dist/patterns/selection/SelectionProvider.d.ts +5 -0
- package/dist/patterns/selection/SelectionProvider.d.ts.map +1 -0
- package/dist/patterns/selection/SelectionProvider.js +64 -0
- package/dist/patterns/selection/SelectionProvider.js.map +1 -0
- package/dist/patterns/selection/index.d.ts +4 -0
- package/dist/patterns/selection/index.d.ts.map +1 -0
- package/dist/patterns/selection/index.js +3 -0
- package/dist/patterns/selection/index.js.map +1 -0
- package/dist/patterns/selection/resolveSelectionNextIds.d.ts +15 -0
- package/dist/patterns/selection/resolveSelectionNextIds.d.ts.map +1 -0
- package/dist/patterns/selection/resolveSelectionNextIds.js +44 -0
- package/dist/patterns/selection/resolveSelectionNextIds.js.map +1 -0
- package/dist/patterns/selection/types.d.ts +38 -0
- package/dist/patterns/selection/types.d.ts.map +1 -0
- package/dist/patterns/selection/types.js +2 -0
- package/dist/patterns/selection/types.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +9 -0
- package/src/patterns/selection/SelectableItem.tsx +93 -0
- package/src/patterns/selection/SelectionProvider.tsx +102 -0
- package/src/patterns/selection/index.ts +10 -0
- package/src/patterns/selection/resolveSelectionNextIds.test.ts +61 -0
- package/src/patterns/selection/resolveSelectionNextIds.ts +71 -0
- package/src/patterns/selection/types.ts +43 -0
- package/src/showcaseCoverage.test.ts +3 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1612,6 +1612,78 @@ No inherited props. `FilterBarProps` is declared directly by ZORA.
|
|
|
1612
1612
|
|
|
1613
1613
|
</details>
|
|
1614
1614
|
|
|
1615
|
+
### `SelectionProvider` / `useSelection` / `SelectableItem`
|
|
1616
|
+
|
|
1617
|
+
Scoped selection state for contextual app bar workflows. Selection state is local interaction state and must not live in `ZoraProvider`.
|
|
1618
|
+
|
|
1619
|
+
Basic usage (selection mode for `AppBar` stays prop-driven):
|
|
1620
|
+
|
|
1621
|
+
```tsx
|
|
1622
|
+
function SelectionHeader() {
|
|
1623
|
+
const selection = useSelection();
|
|
1624
|
+
|
|
1625
|
+
return (
|
|
1626
|
+
<AppBar
|
|
1627
|
+
title={selection.hasSelection ? undefined : 'Inbox'}
|
|
1628
|
+
appMode={
|
|
1629
|
+
selection.hasSelection
|
|
1630
|
+
? {
|
|
1631
|
+
type: 'selection',
|
|
1632
|
+
label: 'Selected',
|
|
1633
|
+
count: selection.selectedCount,
|
|
1634
|
+
onCancel: selection.clear,
|
|
1635
|
+
}
|
|
1636
|
+
: undefined
|
|
1637
|
+
}
|
|
1638
|
+
/>
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
<SelectionProvider mode="single">
|
|
1643
|
+
<SelectionHeader />
|
|
1644
|
+
<SelectableItem id="message-1" trigger="press">
|
|
1645
|
+
{({ selected }) => <Card compact title={selected ? 'Selected' : 'Tap to select'} />}
|
|
1646
|
+
</SelectableItem>
|
|
1647
|
+
</SelectionProvider>;
|
|
1648
|
+
```
|
|
1649
|
+
|
|
1650
|
+
Trigger strategies:
|
|
1651
|
+
|
|
1652
|
+
- `trigger="press"` selects on press.
|
|
1653
|
+
- `trigger="longPress"` selects on long press.
|
|
1654
|
+
- `trigger="manual"` does not bind automatic triggers; consumers call `select`, `toggle`, or `clear` explicitly.
|
|
1655
|
+
|
|
1656
|
+
Nested providers are isolated by default: `useSelection()` always reads the nearest `SelectionProvider`.
|
|
1657
|
+
|
|
1658
|
+
<details>
|
|
1659
|
+
<summary>Props</summary>
|
|
1660
|
+
|
|
1661
|
+
`SelectionProvider` props:
|
|
1662
|
+
|
|
1663
|
+
| Prop | Type | Default | Notes |
|
|
1664
|
+
| -------------------- | ---------------------------------- | ---------- | ------------------------------------------------- |
|
|
1665
|
+
| `children` | `React.ReactNode` | - | Required region subtree. |
|
|
1666
|
+
| `selectedIds` | `readonly string[]` | - | Controlled selected ids (string ids). |
|
|
1667
|
+
| `defaultSelectedIds` | `readonly string[]` | - | Uncontrolled initial selected ids. |
|
|
1668
|
+
| `mode` | `'single' \| 'multi'` | `'single'` | Selection mode. |
|
|
1669
|
+
| `disabled` | `boolean` | `false` | Disables selection updates (select/toggle/clear). |
|
|
1670
|
+
| `onSelectionChange` | `(ids: readonly string[]) => void` | - | Called on selection changes (no-op ignored). |
|
|
1671
|
+
|
|
1672
|
+
`SelectableItem` props:
|
|
1673
|
+
|
|
1674
|
+
| Prop | Type | Default | Notes |
|
|
1675
|
+
| ---------- | -------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
1676
|
+
| `id` | `string` | - | Required item id. |
|
|
1677
|
+
| `trigger` | `'press' \| 'longPress' \| 'manual'` | `'manual'` | Automatic selection trigger strategy. |
|
|
1678
|
+
| `disabled` | `boolean` | `false` | Disables item `select`/`toggle` and automatic triggers (render-prop `clear()` still works unless provider is disabled). |
|
|
1679
|
+
| `children` | `ReactNode \| (state: SelectableItemState) => ReactNode` | - | Render-prop receives selection state and helpers. |
|
|
1680
|
+
|
|
1681
|
+
Accessibility note:
|
|
1682
|
+
|
|
1683
|
+
- For `trigger="manual"`, `SelectableItem` renders no interactive wrapper and does not apply accessibility props automatically. Consumers are responsible for `accessibilityState`, roles, and handlers.
|
|
1684
|
+
|
|
1685
|
+
</details>
|
|
1686
|
+
|
|
1615
1687
|
### `List`
|
|
1616
1688
|
|
|
1617
1689
|
List wrapper that renders `ListRow` items with dividers or spacing, or accepts custom children.
|
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,8 @@ export type { ResponsivePanelDesktopMode, ResponsivePanelMobileMode, ResponsiveP
|
|
|
104
104
|
export { ResponsivePanel } from './patterns/responsive-panel';
|
|
105
105
|
export type { SectionHeaderProps } from './patterns/section-header';
|
|
106
106
|
export { SectionHeader } from './patterns/section-header';
|
|
107
|
+
export type { SelectableItemProps, SelectableItemState, SelectionMode, SelectionProviderProps, SelectionTrigger, UseSelectionResult, } from './patterns/selection';
|
|
108
|
+
export { SelectableItem, SelectionProvider, useSelection } from './patterns/selection';
|
|
107
109
|
export type { SettingsRowProps } from './patterns/settings-row';
|
|
108
110
|
export { SettingsRow } from './patterns/settings-row';
|
|
109
111
|
export type { SwitchFieldProps } from './patterns/switch-field';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,E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M,gCAAgC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ export { Notice } from './patterns/notice';
|
|
|
51
51
|
export { Panel } from './patterns/panel';
|
|
52
52
|
export { ResponsivePanel } from './patterns/responsive-panel';
|
|
53
53
|
export { SectionHeader } from './patterns/section-header';
|
|
54
|
+
export { SelectableItem, SelectionProvider, useSelection } from './patterns/selection';
|
|
54
55
|
export { SettingsRow } from './patterns/settings-row';
|
|
55
56
|
export { SwitchField } from './patterns/switch-field';
|
|
56
57
|
export { ThemeComposer } from './patterns/theme-composer';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAmB7C,OAAO,EACL,IAAI,EACJ,WAAW,EACX,S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O,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,cAAc,SAAS,CAAC","sourcesContent":["export type { AppBarMode, AppBarOverflowAction, AppBarProps } from './components/app-bar';\nexport { AppBar } from './components/app-bar';\nexport type { AvatarProps, AvatarShape, AvatarSize } from './components/avatar';\nexport { Avatar, resolveAvatarInitials } from './components/avatar';\nexport type { AvatarGroupItem, AvatarGroupProps } from './components/avatar-group';\nexport { AvatarGroup } from './components/avatar-group';\nexport type { BadgeProps } from './components/badge';\nexport { Badge } from './components/badge';\nexport type { ButtonProps } from './components/button';\nexport { Button } from './components/button';\nexport type { CardProps } from './components/card';\nexport { Card } from './components/card';\nexport type { CheckboxGroupOption, CheckboxGroupProps, CheckboxProps } from './components/checkbox';\nexport { Checkbox, CheckboxGroup } from './components/checkbox';\nexport type { ChipProps } from './components/chip';\nexport { Chip } from './components/chip';\nexport type { ChipGroupItem, ChipGroupProps } from './components/chip-group';\nexport { ChipGroup } from './components/chip-group';\nexport type { DrawerProps } from './components/drawer';\nexport { Drawer } from './components/drawer';\nexport type {\n FormActionsProps,\n FormErrorProps,\n FormErrors,\n FormFieldConfig,\n FormFieldControlProps,\n FormFieldInputType,\n FormFieldProps,\n FormFieldValue,\n FormFieldWrapperProps,\n FormProps,\n FormValidationErrors,\n FormValidationResult,\n FormValues,\n UseFormControllerOptions,\n UseFormControllerResult,\n ValidationRule,\n} from './components/form';\nexport {\n Form,\n FormActions,\n FormError,\n FormField,\n hasRequiredRule,\n useFormController,\n validateField,\n validateFields,\n validateValue,\n} from './components/form';\nexport type {\n HeadingAlign,\n HeadingLevel,\n HeadingProps,\n HeadingSize,\n HeadingTone,\n HeadingWeight,\n} from './components/heading';\nexport { Heading } from './components/heading';\nexport type { IconProps } from './components/icon';\nexport { Icon } from './components/icon';\nexport type { IconButtonProps } from './components/icon-button';\nexport { IconButton } from './components/icon-button';\nexport type { ImageFit, ImageProps, SurfaceImageSource } from './components/image';\nexport { Image } from './components/image';\nexport type { InputProps, InputTrailingAction } from './components/input';\nexport { Input } from './components/input';\nexport type { MediaCardImageProps, MediaCardProps } from './components/media-card';\nexport { MediaCard } from './components/media-card';\nexport type { MetricCardProps } from './components/metric-card';\nexport { MetricCard } from './components/metric-card';\nexport type { ModalProps } from './components/modal';\nexport { Modal } from './components/modal';\nexport type {\n NavigationItemProps,\n ZoraNavigationRouteMetadata,\n ZoraNavigationRouteState,\n} from './components/navigation-item';\nexport { NavigationItem } from './components/navigation-item';\nexport type { NavigationListProps, ZoraNavigationRouteMap } from './components/navigation-list';\nexport { NavigationList } from './components/navigation-list';\nexport type { ProgressProps } from './components/progress';\nexport { Progress } from './components/progress';\nexport type { RadioGroupOption, RadioGroupProps, RadioProps } from './components/radio';\nexport { Radio, RadioGroup } from './components/radio';\nexport type { RatingProps } from './components/rating';\nexport { Rating } from './components/rating';\nexport type { SearchBarProps } from './components/search-bar';\nexport { SearchBar } from './components/search-bar';\nexport type { SelectOption, SelectProps } from './components/select';\nexport { Select } from './components/select';\nexport type { TabItem, TabsProps, TabsVariant } from './components/tabs';\nexport { Tabs } from './components/tabs';\nexport type { TextAlign, TextProps, TextTone, TextVariant, TextWeight } from './components/text';\nexport { Text } from './components/text';\nexport type { TextareaProps } from './components/textarea';\nexport { Textarea } from './components/textarea';\nexport type { ToolbarActionProps, ToolbarPosition, ToolbarProps } from './components/toolbar';\nexport { Toolbar, ToolbarAction } from './components/toolbar';\nexport type {\n BoxProps,\n CenterProps,\n ContainerProps,\n DividerProps,\n GridProps,\n InlineProps,\n ShowProps,\n SpacerProps,\n StackProps,\n SurfaceProps,\n SurfaceVariant,\n} from './foundation';\nexport {\n Box,\n Center,\n Container,\n Divider,\n Grid,\n Inline,\n Show,\n Spacer,\n Stack,\n Surface,\n} from './foundation';\nexport type { AppShellProps } from './layout/app-shell';\nexport { AppShell } from './layout/app-shell';\nexport type { AuthLayoutProps } from './layout/auth-layout';\nexport { AuthLayout } from './layout/auth-layout';\nexport type { PageProps } from './layout/page';\nexport { Page } from './layout/page';\nexport type { PageHeaderProps } from './layout/page-header';\nexport { PageHeader } from './layout/page-header';\nexport type { PageSectionProps } from './layout/page-section';\nexport { PageSection } from './layout/page-section';\nexport type { SettingsLayoutProps } from './layout/settings-layout';\nexport { SettingsLayout } from './layout/settings-layout';\nexport type { SidebarLayoutProps } from './layout/sidebar-layout';\nexport { SidebarLayout } from './layout/sidebar-layout';\nexport type { TopbarLayoutProps } from './layout/topbar-layout';\nexport { TopbarLayout } from './layout/topbar-layout';\nexport type {\n AuthFormBaseProps,\n AuthIdentifierKind,\n ForgotPasswordFormProps,\n ForgotPasswordFormValues,\n OtpFormProps,\n OtpFormValues,\n SignInFormProps,\n SignInFormValues,\n SignUpFormField,\n SignUpFormProps,\n SignUpFormValues,\n} from './patterns/auth';\nexport { ForgotPasswordForm, OtpForm, SignInForm, SignUpForm } from './patterns/auth';\nexport type {\n CollectionEditorProps,\n CollectionEditorRenderItemProps,\n} from './patterns/collection-editor';\nexport { CollectionEditor } from './patterns/collection-editor';\nexport type { ConfirmDialogProps } from './patterns/confirm-dialog';\nexport { ConfirmDialog } from './patterns/confirm-dialog';\nexport type { DisclosureSectionProps } from './patterns/disclosure-section';\nexport { DisclosureSection } from './patterns/disclosure-section';\nexport type { EmptyStateAction, EmptyStateProps } from './patterns/empty-state';\nexport { EmptyState } from './patterns/empty-state';\nexport type { FilterBarProps } from './patterns/filter-bar';\nexport { FilterBar } from './patterns/filter-bar';\nexport type {\n ImagePreviewProps,\n ZoraImageAsset,\n ZoraImageMetadata,\n} from './patterns/image-preview';\nexport { ImagePreview } from './patterns/image-preview';\nexport type {\n ImageUploadFieldProps,\n ImageUploadProgressContext,\n ZoraPickedImage,\n} from './patterns/image-upload-field';\nexport { ImageUploadField } from './patterns/image-upload-field';\nexport type { InspectorFieldProps } from './patterns/inspector-field';\nexport { InspectorField } from './patterns/inspector-field';\nexport type {\n ListChildrenProps,\n ListItemsProps,\n ListProps,\n ListRowProps,\n ListRowVariant,\n ListSectionProps,\n} from './patterns/list';\nexport { List, ListRow, ListSection } from './patterns/list';\nexport type { NoticeProps } from './patterns/notice';\nexport { Notice } from './patterns/notice';\nexport type { PanelProps } from './patterns/panel';\nexport { Panel } from './patterns/panel';\nexport type {\n ResponsivePanelDesktopMode,\n ResponsivePanelMobileMode,\n ResponsivePanelProps,\n ResponsivePanelSide,\n} from './patterns/responsive-panel';\nexport { ResponsivePanel } from './patterns/responsive-panel';\nexport type { SectionHeaderProps } from './patterns/section-header';\nexport { SectionHeader } from './patterns/section-header';\nexport type { SettingsRowProps } from './patterns/settings-row';\nexport { SettingsRow } from './patterns/settings-row';\nexport type { SwitchFieldProps } from './patterns/switch-field';\nexport { SwitchField } from './patterns/switch-field';\nexport type { ThemeComposerProps } from './patterns/theme-composer';\nexport { ThemeComposer } from './patterns/theme-composer';\nexport type { PaletteItemProps, TileGridProps } from './patterns/tile-grid';\nexport { PaletteItem, TileGrid } from './patterns/tile-grid';\nexport type { TimelineItem, TimelineProps } from './patterns/timeline';\nexport { Timeline } from './patterns/timeline';\nexport type { TreeItemNode, TreeItemRenderProps, TreeViewProps } from './patterns/tree-view';\nexport { TreeItem, TreeView } from './patterns/tree-view';\nexport type { ZoraDrawerContentProps } from './patterns/zora-drawer-content';\nexport { ZoraDrawerContent } from './patterns/zora-drawer-content';\nexport type { ZoraTabBarProps } from './patterns/zora-tab-bar';\nexport { ZoraTabBar } from './patterns/zora-tab-bar';\nexport * from './theme';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAmB7C,OAAO,EACL,IAAI,EACJ,WAAW,EACX,SAAS,EACT,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAM3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,cAAc,SAAS,CAAC","sourcesContent":["export type { AppBarMode, AppBarOverflowAction, AppBarProps } from './components/app-bar';\nexport { AppBar } from './components/app-bar';\nexport type { AvatarProps, AvatarShape, AvatarSize } from './components/avatar';\nexport { Avatar, resolveAvatarInitials } from './components/avatar';\nexport type { AvatarGroupItem, AvatarGroupProps } from './components/avatar-group';\nexport { AvatarGroup } from './components/avatar-group';\nexport type { BadgeProps } from './components/badge';\nexport { Badge } from './components/badge';\nexport type { ButtonProps } from './components/button';\nexport { Button } from './components/button';\nexport type { CardProps } from './components/card';\nexport { Card } from './components/card';\nexport type { CheckboxGroupOption, CheckboxGroupProps, CheckboxProps } from './components/checkbox';\nexport { Checkbox, CheckboxGroup } from './components/checkbox';\nexport type { ChipProps } from './components/chip';\nexport { Chip } from './components/chip';\nexport type { ChipGroupItem, ChipGroupProps } from './components/chip-group';\nexport { ChipGroup } from './components/chip-group';\nexport type { DrawerProps } from './components/drawer';\nexport { Drawer } from './components/drawer';\nexport type {\n FormActionsProps,\n FormErrorProps,\n FormErrors,\n FormFieldConfig,\n FormFieldControlProps,\n FormFieldInputType,\n FormFieldProps,\n FormFieldValue,\n FormFieldWrapperProps,\n FormProps,\n FormValidationErrors,\n FormValidationResult,\n FormValues,\n UseFormControllerOptions,\n UseFormControllerResult,\n ValidationRule,\n} from './components/form';\nexport {\n Form,\n FormActions,\n FormError,\n FormField,\n hasRequiredRule,\n useFormController,\n validateField,\n validateFields,\n validateValue,\n} from './components/form';\nexport type {\n HeadingAlign,\n HeadingLevel,\n HeadingProps,\n HeadingSize,\n HeadingTone,\n HeadingWeight,\n} from './components/heading';\nexport { Heading } from './components/heading';\nexport type { IconProps } from './components/icon';\nexport { Icon } from './components/icon';\nexport type { IconButtonProps } from './components/icon-button';\nexport { IconButton } from './components/icon-button';\nexport type { ImageFit, ImageProps, SurfaceImageSource } from './components/image';\nexport { Image } from './components/image';\nexport type { InputProps, InputTrailingAction } from './components/input';\nexport { Input } from './components/input';\nexport type { MediaCardImageProps, MediaCardProps } from './components/media-card';\nexport { MediaCard } from './components/media-card';\nexport type { MetricCardProps } from './components/metric-card';\nexport { MetricCard } from './components/metric-card';\nexport type { ModalProps } from './components/modal';\nexport { Modal } from './components/modal';\nexport type {\n NavigationItemProps,\n ZoraNavigationRouteMetadata,\n ZoraNavigationRouteState,\n} from './components/navigation-item';\nexport { NavigationItem } from './components/navigation-item';\nexport type { NavigationListProps, ZoraNavigationRouteMap } from './components/navigation-list';\nexport { NavigationList } from './components/navigation-list';\nexport type { ProgressProps } from './components/progress';\nexport { Progress } from './components/progress';\nexport type { RadioGroupOption, RadioGroupProps, RadioProps } from './components/radio';\nexport { Radio, RadioGroup } from './components/radio';\nexport type { RatingProps } from './components/rating';\nexport { Rating } from './components/rating';\nexport type { SearchBarProps } from './components/search-bar';\nexport { SearchBar } from './components/search-bar';\nexport type { SelectOption, SelectProps } from './components/select';\nexport { Select } from './components/select';\nexport type { TabItem, TabsProps, TabsVariant } from './components/tabs';\nexport { Tabs } from './components/tabs';\nexport type { TextAlign, TextProps, TextTone, TextVariant, TextWeight } from './components/text';\nexport { Text } from './components/text';\nexport type { TextareaProps } from './components/textarea';\nexport { Textarea } from './components/textarea';\nexport type { ToolbarActionProps, ToolbarPosition, ToolbarProps } from './components/toolbar';\nexport { Toolbar, ToolbarAction } from './components/toolbar';\nexport type {\n BoxProps,\n CenterProps,\n ContainerProps,\n DividerProps,\n GridProps,\n InlineProps,\n ShowProps,\n SpacerProps,\n StackProps,\n SurfaceProps,\n SurfaceVariant,\n} from './foundation';\nexport {\n Box,\n Center,\n Container,\n Divider,\n Grid,\n Inline,\n Show,\n Spacer,\n Stack,\n Surface,\n} from './foundation';\nexport type { AppShellProps } from './layout/app-shell';\nexport { AppShell } from './layout/app-shell';\nexport type { AuthLayoutProps } from './layout/auth-layout';\nexport { AuthLayout } from './layout/auth-layout';\nexport type { PageProps } from './layout/page';\nexport { Page } from './layout/page';\nexport type { PageHeaderProps } from './layout/page-header';\nexport { PageHeader } from './layout/page-header';\nexport type { PageSectionProps } from './layout/page-section';\nexport { PageSection } from './layout/page-section';\nexport type { SettingsLayoutProps } from './layout/settings-layout';\nexport { SettingsLayout } from './layout/settings-layout';\nexport type { SidebarLayoutProps } from './layout/sidebar-layout';\nexport { SidebarLayout } from './layout/sidebar-layout';\nexport type { TopbarLayoutProps } from './layout/topbar-layout';\nexport { TopbarLayout } from './layout/topbar-layout';\nexport type {\n AuthFormBaseProps,\n AuthIdentifierKind,\n ForgotPasswordFormProps,\n ForgotPasswordFormValues,\n OtpFormProps,\n OtpFormValues,\n SignInFormProps,\n SignInFormValues,\n SignUpFormField,\n SignUpFormProps,\n SignUpFormValues,\n} from './patterns/auth';\nexport { ForgotPasswordForm, OtpForm, SignInForm, SignUpForm } from './patterns/auth';\nexport type {\n CollectionEditorProps,\n CollectionEditorRenderItemProps,\n} from './patterns/collection-editor';\nexport { CollectionEditor } from './patterns/collection-editor';\nexport type { ConfirmDialogProps } from './patterns/confirm-dialog';\nexport { ConfirmDialog } from './patterns/confirm-dialog';\nexport type { DisclosureSectionProps } from './patterns/disclosure-section';\nexport { DisclosureSection } from './patterns/disclosure-section';\nexport type { EmptyStateAction, EmptyStateProps } from './patterns/empty-state';\nexport { EmptyState } from './patterns/empty-state';\nexport type { FilterBarProps } from './patterns/filter-bar';\nexport { FilterBar } from './patterns/filter-bar';\nexport type {\n ImagePreviewProps,\n ZoraImageAsset,\n ZoraImageMetadata,\n} from './patterns/image-preview';\nexport { ImagePreview } from './patterns/image-preview';\nexport type {\n ImageUploadFieldProps,\n ImageUploadProgressContext,\n ZoraPickedImage,\n} from './patterns/image-upload-field';\nexport { ImageUploadField } from './patterns/image-upload-field';\nexport type { InspectorFieldProps } from './patterns/inspector-field';\nexport { InspectorField } from './patterns/inspector-field';\nexport type {\n ListChildrenProps,\n ListItemsProps,\n ListProps,\n ListRowProps,\n ListRowVariant,\n ListSectionProps,\n} from './patterns/list';\nexport { List, ListRow, ListSection } from './patterns/list';\nexport type { NoticeProps } from './patterns/notice';\nexport { Notice } from './patterns/notice';\nexport type { PanelProps } from './patterns/panel';\nexport { Panel } from './patterns/panel';\nexport type {\n ResponsivePanelDesktopMode,\n ResponsivePanelMobileMode,\n ResponsivePanelProps,\n ResponsivePanelSide,\n} from './patterns/responsive-panel';\nexport { ResponsivePanel } from './patterns/responsive-panel';\nexport type { SectionHeaderProps } from './patterns/section-header';\nexport { SectionHeader } from './patterns/section-header';\nexport type {\n SelectableItemProps,\n SelectableItemState,\n SelectionMode,\n SelectionProviderProps,\n SelectionTrigger,\n UseSelectionResult,\n} from './patterns/selection';\nexport { SelectableItem, SelectionProvider, useSelection } from './patterns/selection';\nexport type { SettingsRowProps } from './patterns/settings-row';\nexport { SettingsRow } from './patterns/settings-row';\nexport type { SwitchFieldProps } from './patterns/switch-field';\nexport { SwitchField } from './patterns/switch-field';\nexport type { ThemeComposerProps } from './patterns/theme-composer';\nexport { ThemeComposer } from './patterns/theme-composer';\nexport type { PaletteItemProps, TileGridProps } from './patterns/tile-grid';\nexport { PaletteItem, TileGrid } from './patterns/tile-grid';\nexport type { TimelineItem, TimelineProps } from './patterns/timeline';\nexport { Timeline } from './patterns/timeline';\nexport type { TreeItemNode, TreeItemRenderProps, TreeViewProps } from './patterns/tree-view';\nexport { TreeItem, TreeView } from './patterns/tree-view';\nexport type { ZoraDrawerContentProps } from './patterns/zora-drawer-content';\nexport { ZoraDrawerContent } from './patterns/zora-drawer-content';\nexport type { ZoraTabBarProps } from './patterns/zora-tab-bar';\nexport { ZoraTabBar } from './patterns/zora-tab-bar';\nexport * from './theme';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectableItem.d.ts","sourceRoot":"","sources":["../../../src/patterns/selection/SelectableItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,mBAAmB,EAAyC,MAAM,SAAS,CAAC;AAY1F,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,QAAgB,EAAE,QAAQ,EAAE,EAAE,mBAAmB,qBA2E9F"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ButtonBase } from '@ankhorage/surface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useSelection } from './SelectionProvider';
|
|
4
|
+
function resolveTrigger(trigger) {
|
|
5
|
+
return trigger ?? 'manual';
|
|
6
|
+
}
|
|
7
|
+
function isRenderProp(children) {
|
|
8
|
+
return typeof children === 'function';
|
|
9
|
+
}
|
|
10
|
+
export function SelectableItem({ id, trigger, disabled = false, children }) {
|
|
11
|
+
const selection = useSelection();
|
|
12
|
+
const resolvedTrigger = resolveTrigger(trigger);
|
|
13
|
+
const resolvedDisabled = selection.disabled || disabled;
|
|
14
|
+
const selected = selection.isSelected(id);
|
|
15
|
+
const select = React.useCallback(() => {
|
|
16
|
+
if (resolvedDisabled)
|
|
17
|
+
return;
|
|
18
|
+
selection.select(id);
|
|
19
|
+
}, [id, resolvedDisabled, selection]);
|
|
20
|
+
const toggle = React.useCallback(() => {
|
|
21
|
+
if (resolvedDisabled)
|
|
22
|
+
return;
|
|
23
|
+
selection.toggle(id);
|
|
24
|
+
}, [id, resolvedDisabled, selection]);
|
|
25
|
+
const clear = React.useCallback(() => {
|
|
26
|
+
if (selection.disabled)
|
|
27
|
+
return;
|
|
28
|
+
selection.clear();
|
|
29
|
+
}, [selection]);
|
|
30
|
+
const itemState = React.useMemo(() => {
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
selected,
|
|
34
|
+
disabled: resolvedDisabled,
|
|
35
|
+
mode: selection.mode,
|
|
36
|
+
select,
|
|
37
|
+
toggle,
|
|
38
|
+
clear,
|
|
39
|
+
};
|
|
40
|
+
}, [clear, id, resolvedDisabled, select, selected, selection.mode, toggle]);
|
|
41
|
+
// IMPORTANT:
|
|
42
|
+
// Do not pass `children` directly into ButtonBase. ButtonBase also supports function children,
|
|
43
|
+
// but its function signature receives interaction state, not SelectableItemState.
|
|
44
|
+
const content = isRenderProp(children) ? children(itemState) : children;
|
|
45
|
+
if (resolvedTrigger === 'manual') {
|
|
46
|
+
return <>{content}</>;
|
|
47
|
+
}
|
|
48
|
+
const handlePress = (event) => {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
if (resolvedDisabled)
|
|
51
|
+
return;
|
|
52
|
+
if (selection.mode === 'single') {
|
|
53
|
+
selection.select(id);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
selection.toggle(id);
|
|
57
|
+
};
|
|
58
|
+
const handleLongPress = (event) => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
if (resolvedDisabled)
|
|
61
|
+
return;
|
|
62
|
+
if (selection.mode === 'single') {
|
|
63
|
+
selection.select(id);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
selection.toggle(id);
|
|
67
|
+
};
|
|
68
|
+
return (<ButtonBase accessibilityRole="button" accessibilityState={{ disabled: resolvedDisabled, selected }} disabled={resolvedDisabled} onLongPress={resolvedTrigger === 'longPress' ? handleLongPress : undefined} onPress={resolvedTrigger === 'press' ? handlePress : undefined}>
|
|
69
|
+
{content}
|
|
70
|
+
</ButtonBase>);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=SelectableItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectableItem.js","sourceRoot":"","sources":["../../../src/patterns/selection/SelectableItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,SAAS,cAAc,CAAC,OAAqC;IAC3D,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CACnB,QAAyC;IAEzC,OAAO,OAAO,QAAQ,KAAK,UAAU,CAAC;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,CAAC,CAC3E,OAAO,CAAC,CAAC,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAE/D;MAAA,CAAC,OAAO,CACV;IAAA,EAAE,UAAU,CAAC,CACd,CAAC;AACJ,CAAC","sourcesContent":["import { ButtonBase } from '@ankhorage/surface';\nimport React from 'react';\nimport type { GestureResponderEvent } from 'react-native';\n\nimport { useSelection } from './SelectionProvider';\nimport type { SelectableItemProps, SelectableItemState, SelectionTrigger } from './types';\n\nfunction resolveTrigger(trigger: SelectionTrigger | undefined): SelectionTrigger {\n return trigger ?? 'manual';\n}\n\nfunction isRenderProp(\n children: SelectableItemProps['children'],\n): children is (state: SelectableItemState) => React.ReactNode {\n return typeof children === 'function';\n}\n\nexport function SelectableItem({ id, trigger, disabled = false, children }: SelectableItemProps) {\n const selection = useSelection();\n const resolvedTrigger = resolveTrigger(trigger);\n const resolvedDisabled = selection.disabled || disabled;\n const selected = selection.isSelected(id);\n\n const select = React.useCallback(() => {\n if (resolvedDisabled) return;\n selection.select(id);\n }, [id, resolvedDisabled, selection]);\n\n const toggle = React.useCallback(() => {\n if (resolvedDisabled) return;\n selection.toggle(id);\n }, [id, resolvedDisabled, selection]);\n\n const clear = React.useCallback(() => {\n if (selection.disabled) return;\n selection.clear();\n }, [selection]);\n\n const itemState = React.useMemo<SelectableItemState>(() => {\n return {\n id,\n selected,\n disabled: resolvedDisabled,\n mode: selection.mode,\n select,\n toggle,\n clear,\n };\n }, [clear, id, resolvedDisabled, select, selected, selection.mode, toggle]);\n\n // IMPORTANT:\n // Do not pass `children` directly into ButtonBase. ButtonBase also supports function children,\n // but its function signature receives interaction state, not SelectableItemState.\n const content = isRenderProp(children) ? children(itemState) : children;\n\n if (resolvedTrigger === 'manual') {\n return <>{content}</>;\n }\n\n const handlePress = (event: GestureResponderEvent) => {\n event.stopPropagation();\n if (resolvedDisabled) return;\n if (selection.mode === 'single') {\n selection.select(id);\n return;\n }\n\n selection.toggle(id);\n };\n\n const handleLongPress = (event: GestureResponderEvent) => {\n event.stopPropagation();\n if (resolvedDisabled) return;\n if (selection.mode === 'single') {\n selection.select(id);\n return;\n }\n\n selection.toggle(id);\n };\n\n return (\n <ButtonBase\n accessibilityRole=\"button\"\n accessibilityState={{ disabled: resolvedDisabled, selected }}\n disabled={resolvedDisabled}\n onLongPress={resolvedTrigger === 'longPress' ? handleLongPress : undefined}\n onPress={resolvedTrigger === 'press' ? handlePress : undefined}\n >\n {content}\n </ButtonBase>\n );\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectionProviderProps, UseSelectionResult } from './types';
|
|
3
|
+
export declare function useSelection(): UseSelectionResult;
|
|
4
|
+
export declare function SelectionProvider({ children, selectedIds, defaultSelectedIds, mode, disabled, onSelectionChange, }: SelectionProviderProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=SelectionProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionProvider.d.ts","sourceRoot":"","sources":["../../../src/patterns/selection/SelectionProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAiB,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAiBzF,wBAAgB,YAAY,IAAI,kBAAkB,CAOjD;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,QAAQ,EACR,iBAAiB,GAClB,EAAE,sBAAsB,qBAiExB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { areIdsEqual, clearIds, normalizeIds, selectId, toggleId } from './resolveSelectionNextIds';
|
|
3
|
+
const MISSING_CONTEXT_MESSAGE = 'ZORA selection context is missing. Wrap this tree in <SelectionProvider>.';
|
|
4
|
+
const SelectionContext = React.createContext(null);
|
|
5
|
+
function resolveMode(mode) {
|
|
6
|
+
return mode ?? 'single';
|
|
7
|
+
}
|
|
8
|
+
function resolveDisabled(disabled) {
|
|
9
|
+
return disabled ?? false;
|
|
10
|
+
}
|
|
11
|
+
export function useSelection() {
|
|
12
|
+
const value = React.useContext(SelectionContext);
|
|
13
|
+
if (!value) {
|
|
14
|
+
throw new Error(MISSING_CONTEXT_MESSAGE);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export function SelectionProvider({ children, selectedIds, defaultSelectedIds, mode, disabled, onSelectionChange, }) {
|
|
19
|
+
const resolvedMode = resolveMode(mode);
|
|
20
|
+
const resolvedDisabled = resolveDisabled(disabled);
|
|
21
|
+
const isControlled = selectedIds !== undefined;
|
|
22
|
+
const [uncontrolledIds, setUncontrolledIds] = React.useState(defaultSelectedIds ?? []);
|
|
23
|
+
const rawIds = isControlled ? selectedIds : uncontrolledIds;
|
|
24
|
+
const currentNormalizedIds = normalizeIds(rawIds, resolvedMode);
|
|
25
|
+
const selectedIdSet = React.useMemo(() => new Set(currentNormalizedIds), [currentNormalizedIds]);
|
|
26
|
+
const commitSelectionChange = React.useCallback((nextNormalizedIds) => {
|
|
27
|
+
if (resolvedDisabled)
|
|
28
|
+
return;
|
|
29
|
+
if (areIdsEqual(nextNormalizedIds, currentNormalizedIds))
|
|
30
|
+
return;
|
|
31
|
+
onSelectionChange?.(nextNormalizedIds);
|
|
32
|
+
if (!isControlled) {
|
|
33
|
+
setUncontrolledIds(nextNormalizedIds);
|
|
34
|
+
}
|
|
35
|
+
}, [currentNormalizedIds, isControlled, onSelectionChange, resolvedDisabled]);
|
|
36
|
+
const clear = React.useCallback(() => {
|
|
37
|
+
commitSelectionChange(normalizeIds(clearIds(), resolvedMode));
|
|
38
|
+
}, [commitSelectionChange, resolvedMode]);
|
|
39
|
+
const select = React.useCallback((id) => {
|
|
40
|
+
const nextIds = selectId({ mode: resolvedMode, ids: currentNormalizedIds, id });
|
|
41
|
+
const nextNormalizedIds = normalizeIds(nextIds, resolvedMode);
|
|
42
|
+
commitSelectionChange(nextNormalizedIds);
|
|
43
|
+
}, [commitSelectionChange, currentNormalizedIds, resolvedMode]);
|
|
44
|
+
const toggle = React.useCallback((id) => {
|
|
45
|
+
const nextIds = toggleId({ mode: resolvedMode, ids: currentNormalizedIds, id });
|
|
46
|
+
const nextNormalizedIds = normalizeIds(nextIds, resolvedMode);
|
|
47
|
+
commitSelectionChange(nextNormalizedIds);
|
|
48
|
+
}, [commitSelectionChange, currentNormalizedIds, resolvedMode]);
|
|
49
|
+
const value = React.useMemo(() => {
|
|
50
|
+
return {
|
|
51
|
+
mode: resolvedMode,
|
|
52
|
+
disabled: resolvedDisabled,
|
|
53
|
+
selectedIds: currentNormalizedIds,
|
|
54
|
+
selectedCount: currentNormalizedIds.length,
|
|
55
|
+
hasSelection: currentNormalizedIds.length > 0,
|
|
56
|
+
isSelected: (id) => selectedIdSet.has(id),
|
|
57
|
+
select,
|
|
58
|
+
toggle,
|
|
59
|
+
clear,
|
|
60
|
+
};
|
|
61
|
+
}, [clear, currentNormalizedIds, resolvedDisabled, resolvedMode, select, selectedIdSet, toggle]);
|
|
62
|
+
return <SelectionContext.Provider value={value}>{children}</SelectionContext.Provider>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=SelectionProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionProvider.js","sourceRoot":"","sources":["../../../src/patterns/selection/SelectionProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGpG,MAAM,uBAAuB,GAC3B,2EAA2E,CAAC;AAI9E,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAA+B,IAAI,CAAC,CAAC;AAEjF,SAAS,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GAAG,EAAE;QACnD,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,oBAAoB;YACjC,aAAa,EAAE,oBAAoB,CAAC,MAAM;YAC1C,YAAY,EAAE,oBAAoB,CAAC,MAAM,GAAG,CAAC;YAC7C,UAAU,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACjD,MAAM;YACN,MAAM;YACN,KAAK;SACN,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import React from 'react';\n\nimport { areIdsEqual, clearIds, normalizeIds, selectId, toggleId } from './resolveSelectionNextIds';\nimport type { SelectionMode, SelectionProviderProps, UseSelectionResult } from './types';\n\nconst MISSING_CONTEXT_MESSAGE =\n 'ZORA selection context is missing. Wrap this tree in <SelectionProvider>.';\n\ntype SelectionContextValue = UseSelectionResult;\n\nconst SelectionContext = React.createContext<SelectionContextValue | null>(null);\n\nfunction resolveMode(mode: SelectionMode | undefined): SelectionMode {\n return mode ?? 'single';\n}\n\nfunction resolveDisabled(disabled: boolean | undefined): boolean {\n return disabled ?? false;\n}\n\nexport function useSelection(): UseSelectionResult {\n const value = React.useContext(SelectionContext);\n if (!value) {\n throw new Error(MISSING_CONTEXT_MESSAGE);\n }\n\n return value;\n}\n\nexport function SelectionProvider({\n children,\n selectedIds,\n defaultSelectedIds,\n mode,\n disabled,\n onSelectionChange,\n}: SelectionProviderProps) {\n const resolvedMode = resolveMode(mode);\n const resolvedDisabled = resolveDisabled(disabled);\n const isControlled = selectedIds !== undefined;\n\n const [uncontrolledIds, setUncontrolledIds] = React.useState<readonly string[]>(\n defaultSelectedIds ?? [],\n );\n\n const rawIds = isControlled ? selectedIds : uncontrolledIds;\n const currentNormalizedIds = normalizeIds(rawIds, resolvedMode);\n\n const selectedIdSet = React.useMemo(() => new Set(currentNormalizedIds), [currentNormalizedIds]);\n\n const commitSelectionChange = React.useCallback(\n (nextNormalizedIds: readonly string[]) => {\n if (resolvedDisabled) return;\n if (areIdsEqual(nextNormalizedIds, currentNormalizedIds)) return;\n\n onSelectionChange?.(nextNormalizedIds);\n\n if (!isControlled) {\n setUncontrolledIds(nextNormalizedIds);\n }\n },\n [currentNormalizedIds, isControlled, onSelectionChange, resolvedDisabled],\n );\n\n const clear = React.useCallback(() => {\n commitSelectionChange(normalizeIds(clearIds(), resolvedMode));\n }, [commitSelectionChange, resolvedMode]);\n\n const select = React.useCallback(\n (id: string) => {\n const nextIds = selectId({ mode: resolvedMode, ids: currentNormalizedIds, id });\n const nextNormalizedIds = normalizeIds(nextIds, resolvedMode);\n commitSelectionChange(nextNormalizedIds);\n },\n [commitSelectionChange, currentNormalizedIds, resolvedMode],\n );\n\n const toggle = React.useCallback(\n (id: string) => {\n const nextIds = toggleId({ mode: resolvedMode, ids: currentNormalizedIds, id });\n const nextNormalizedIds = normalizeIds(nextIds, resolvedMode);\n commitSelectionChange(nextNormalizedIds);\n },\n [commitSelectionChange, currentNormalizedIds, resolvedMode],\n );\n\n const value = React.useMemo<UseSelectionResult>(() => {\n return {\n mode: resolvedMode,\n disabled: resolvedDisabled,\n selectedIds: currentNormalizedIds,\n selectedCount: currentNormalizedIds.length,\n hasSelection: currentNormalizedIds.length > 0,\n isSelected: (id: string) => selectedIdSet.has(id),\n select,\n toggle,\n clear,\n };\n }, [clear, currentNormalizedIds, resolvedDisabled, resolvedMode, select, selectedIdSet, toggle]);\n\n return <SelectionContext.Provider value={value}>{children}</SelectionContext.Provider>;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SelectableItem } from './SelectableItem';
|
|
2
|
+
export { SelectionProvider, useSelection } from './SelectionProvider';
|
|
3
|
+
export type { SelectableItemProps, SelectableItemState, SelectionMode, SelectionProviderProps, SelectionTrigger, UseSelectionResult, } from './types';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/selection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtE,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/patterns/selection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { SelectableItem } from './SelectableItem';\nexport { SelectionProvider, useSelection } from './SelectionProvider';\nexport type {\n SelectableItemProps,\n SelectableItemState,\n SelectionMode,\n SelectionProviderProps,\n SelectionTrigger,\n UseSelectionResult,\n} from './types';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SelectionMode } from './types';
|
|
2
|
+
export declare function normalizeIds(ids: readonly string[] | undefined, mode: SelectionMode): readonly string[];
|
|
3
|
+
export declare function areIdsEqual(a: readonly string[], b: readonly string[]): boolean;
|
|
4
|
+
export declare function clearIds(): readonly string[];
|
|
5
|
+
export declare function selectId({ mode, ids, id, }: {
|
|
6
|
+
mode: SelectionMode;
|
|
7
|
+
ids: readonly string[];
|
|
8
|
+
id: string;
|
|
9
|
+
}): readonly string[];
|
|
10
|
+
export declare function toggleId({ mode, ids, id, }: {
|
|
11
|
+
mode: SelectionMode;
|
|
12
|
+
ids: readonly string[];
|
|
13
|
+
id: string;
|
|
14
|
+
}): readonly string[];
|
|
15
|
+
//# sourceMappingURL=resolveSelectionNextIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSelectionNextIds.d.ts","sourceRoot":"","sources":["../../../src/patterns/selection/resolveSelectionNextIds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAClC,IAAI,EAAE,aAAa,GAClB,SAAS,MAAM,EAAE,CAYnB;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAO/E;AAED,wBAAgB,QAAQ,IAAI,SAAS,MAAM,EAAE,CAE5C;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,GAAG,EACH,EAAE,GACH,EAAE;IACD,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,SAAS,MAAM,EAAE,CAUpB;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,GAAG,EACH,EAAE,GACH,EAAE;IACD,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,SAAS,MAAM,EAAE,CAUpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function normalizeIds(ids, mode) {
|
|
2
|
+
const uniqueIds = [];
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
for (const id of ids ?? []) {
|
|
5
|
+
if (seen.has(id))
|
|
6
|
+
continue;
|
|
7
|
+
seen.add(id);
|
|
8
|
+
uniqueIds.push(id);
|
|
9
|
+
if (mode === 'single')
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
return uniqueIds;
|
|
13
|
+
}
|
|
14
|
+
export function areIdsEqual(a, b) {
|
|
15
|
+
if (a.length !== b.length)
|
|
16
|
+
return false;
|
|
17
|
+
for (let index = 0; index < a.length; index += 1) {
|
|
18
|
+
if (a[index] !== b[index])
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
export function clearIds() {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
export function selectId({ mode, ids, id, }) {
|
|
27
|
+
if (mode === 'single') {
|
|
28
|
+
return [id];
|
|
29
|
+
}
|
|
30
|
+
if (ids.includes(id)) {
|
|
31
|
+
return ids;
|
|
32
|
+
}
|
|
33
|
+
return [...ids, id];
|
|
34
|
+
}
|
|
35
|
+
export function toggleId({ mode, ids, id, }) {
|
|
36
|
+
if (ids.includes(id)) {
|
|
37
|
+
return ids.filter((existingId) => existingId !== id);
|
|
38
|
+
}
|
|
39
|
+
if (mode === 'single') {
|
|
40
|
+
return [id];
|
|
41
|
+
}
|
|
42
|
+
return [...ids, id];
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=resolveSelectionNextIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSelectionNextIds.js","sourceRoot":"","sources":["../../../src/patterns/selection/resolveSelectionNextIds.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAC1B,GAAkC,EAClC,IAAmB;IAEnB,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;QAC3B,IAAI,I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IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import type { SelectionMode } from './types';\n\nexport function normalizeIds(\n ids: readonly string[] | undefined,\n mode: SelectionMode,\n): readonly string[] {\n const uniqueIds: string[] = [];\n const seen = new Set<string>();\n\n for (const id of ids ?? []) {\n if (seen.has(id)) continue;\n seen.add(id);\n uniqueIds.push(id);\n if (mode === 'single') break;\n }\n\n return uniqueIds;\n}\n\nexport function areIdsEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n for (let index = 0; index < a.length; index += 1) {\n if (a[index] !== b[index]) return false;\n }\n\n return true;\n}\n\nexport function clearIds(): readonly string[] {\n return [];\n}\n\nexport function selectId({\n mode,\n ids,\n id,\n}: {\n mode: SelectionMode;\n ids: readonly string[];\n id: string;\n}): readonly string[] {\n if (mode === 'single') {\n return [id];\n }\n\n if (ids.includes(id)) {\n return ids;\n }\n\n return [...ids, id];\n}\n\nexport function toggleId({\n mode,\n ids,\n id,\n}: {\n mode: SelectionMode;\n ids: readonly string[];\n id: string;\n}): readonly string[] {\n if (ids.includes(id)) {\n return ids.filter((existingId) => existingId !== id);\n }\n\n if (mode === 'single') {\n return [id];\n }\n\n return [...ids, id];\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type SelectionMode = 'single' | 'multi';
|
|
3
|
+
export type SelectionTrigger = 'press' | 'longPress' | 'manual';
|
|
4
|
+
export interface SelectionProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
selectedIds?: readonly string[];
|
|
7
|
+
defaultSelectedIds?: readonly string[];
|
|
8
|
+
mode?: SelectionMode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onSelectionChange?: (ids: readonly string[]) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface UseSelectionResult {
|
|
13
|
+
mode: SelectionMode;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
selectedIds: readonly string[];
|
|
16
|
+
selectedCount: number;
|
|
17
|
+
hasSelection: boolean;
|
|
18
|
+
isSelected: (id: string) => boolean;
|
|
19
|
+
select: (id: string) => void;
|
|
20
|
+
toggle: (id: string) => void;
|
|
21
|
+
clear: () => void;
|
|
22
|
+
}
|
|
23
|
+
export interface SelectableItemState {
|
|
24
|
+
id: string;
|
|
25
|
+
selected: boolean;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
mode: SelectionMode;
|
|
28
|
+
select: () => void;
|
|
29
|
+
toggle: () => void;
|
|
30
|
+
clear: () => void;
|
|
31
|
+
}
|
|
32
|
+
export interface SelectableItemProps {
|
|
33
|
+
id: string;
|
|
34
|
+
trigger?: SelectionTrigger;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
children: React.ReactNode | ((state: SelectableItemState) => React.ReactNode);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/selection/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEhE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,mBAAmB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CAC/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patterns/selection/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nexport type SelectionMode = 'single' | 'multi';\n\nexport type SelectionTrigger = 'press' | 'longPress' | 'manual';\n\nexport interface SelectionProviderProps {\n children: React.ReactNode;\n selectedIds?: readonly string[];\n defaultSelectedIds?: readonly string[];\n mode?: SelectionMode;\n disabled?: boolean;\n onSelectionChange?: (ids: readonly string[]) => void;\n}\n\nexport interface UseSelectionResult {\n mode: SelectionMode;\n disabled: boolean;\n selectedIds: readonly string[];\n selectedCount: number;\n hasSelection: boolean;\n isSelected: (id: string) => boolean;\n select: (id: string) => void;\n toggle: (id: string) => void;\n clear: () => void;\n}\n\nexport interface SelectableItemState {\n id: string;\n selected: boolean;\n disabled: boolean;\n mode: SelectionMode;\n select: () => void;\n toggle: () => void;\n clear: () => void;\n}\n\nexport interface SelectableItemProps {\n id: string;\n trigger?: SelectionTrigger;\n disabled?: boolean;\n children: React.ReactNode | ((state: SelectableItemState) => React.ReactNode);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/zora#readme",
|
|
7
7
|
"bugs": {
|
package/src/index.ts
CHANGED
|
@@ -200,6 +200,15 @@ export type {
|
|
|
200
200
|
export { ResponsivePanel } from './patterns/responsive-panel';
|
|
201
201
|
export type { SectionHeaderProps } from './patterns/section-header';
|
|
202
202
|
export { SectionHeader } from './patterns/section-header';
|
|
203
|
+
export type {
|
|
204
|
+
SelectableItemProps,
|
|
205
|
+
SelectableItemState,
|
|
206
|
+
SelectionMode,
|
|
207
|
+
SelectionProviderProps,
|
|
208
|
+
SelectionTrigger,
|
|
209
|
+
UseSelectionResult,
|
|
210
|
+
} from './patterns/selection';
|
|
211
|
+
export { SelectableItem, SelectionProvider, useSelection } from './patterns/selection';
|
|
203
212
|
export type { SettingsRowProps } from './patterns/settings-row';
|
|
204
213
|
export { SettingsRow } from './patterns/settings-row';
|
|
205
214
|
export type { SwitchFieldProps } from './patterns/switch-field';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ButtonBase } from '@ankhorage/surface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { GestureResponderEvent } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { useSelection } from './SelectionProvider';
|
|
6
|
+
import type { SelectableItemProps, SelectableItemState, SelectionTrigger } from './types';
|
|
7
|
+
|
|
8
|
+
function resolveTrigger(trigger: SelectionTrigger | undefined): SelectionTrigger {
|
|
9
|
+
return trigger ?? 'manual';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isRenderProp(
|
|
13
|
+
children: SelectableItemProps['children'],
|
|
14
|
+
): children is (state: SelectableItemState) => React.ReactNode {
|
|
15
|
+
return typeof children === 'function';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function SelectableItem({ id, trigger, disabled = false, children }: SelectableItemProps) {
|
|
19
|
+
const selection = useSelection();
|
|
20
|
+
const resolvedTrigger = resolveTrigger(trigger);
|
|
21
|
+
const resolvedDisabled = selection.disabled || disabled;
|
|
22
|
+
const selected = selection.isSelected(id);
|
|
23
|
+
|
|
24
|
+
const select = React.useCallback(() => {
|
|
25
|
+
if (resolvedDisabled) return;
|
|
26
|
+
selection.select(id);
|
|
27
|
+
}, [id, resolvedDisabled, selection]);
|
|
28
|
+
|
|
29
|
+
const toggle = React.useCallback(() => {
|
|
30
|
+
if (resolvedDisabled) return;
|
|
31
|
+
selection.toggle(id);
|
|
32
|
+
}, [id, resolvedDisabled, selection]);
|
|
33
|
+
|
|
34
|
+
const clear = React.useCallback(() => {
|
|
35
|
+
if (selection.disabled) return;
|
|
36
|
+
selection.clear();
|
|
37
|
+
}, [selection]);
|
|
38
|
+
|
|
39
|
+
const itemState = React.useMemo<SelectableItemState>(() => {
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
selected,
|
|
43
|
+
disabled: resolvedDisabled,
|
|
44
|
+
mode: selection.mode,
|
|
45
|
+
select,
|
|
46
|
+
toggle,
|
|
47
|
+
clear,
|
|
48
|
+
};
|
|
49
|
+
}, [clear, id, resolvedDisabled, select, selected, selection.mode, toggle]);
|
|
50
|
+
|
|
51
|
+
// IMPORTANT:
|
|
52
|
+
// Do not pass `children` directly into ButtonBase. ButtonBase also supports function children,
|
|
53
|
+
// but its function signature receives interaction state, not SelectableItemState.
|
|
54
|
+
const content = isRenderProp(children) ? children(itemState) : children;
|
|
55
|
+
|
|
56
|
+
if (resolvedTrigger === 'manual') {
|
|
57
|
+
return <>{content}</>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const handlePress = (event: GestureResponderEvent) => {
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
if (resolvedDisabled) return;
|
|
63
|
+
if (selection.mode === 'single') {
|
|
64
|
+
selection.select(id);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
selection.toggle(id);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handleLongPress = (event: GestureResponderEvent) => {
|
|
72
|
+
event.stopPropagation();
|
|
73
|
+
if (resolvedDisabled) return;
|
|
74
|
+
if (selection.mode === 'single') {
|
|
75
|
+
selection.select(id);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
selection.toggle(id);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<ButtonBase
|
|
84
|
+
accessibilityRole="button"
|
|
85
|
+
accessibilityState={{ disabled: resolvedDisabled, selected }}
|
|
86
|
+
disabled={resolvedDisabled}
|
|
87
|
+
onLongPress={resolvedTrigger === 'longPress' ? handleLongPress : undefined}
|
|
88
|
+
onPress={resolvedTrigger === 'press' ? handlePress : undefined}
|
|
89
|
+
>
|
|
90
|
+
{content}
|
|
91
|
+
</ButtonBase>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { areIdsEqual, clearIds, normalizeIds, selectId, toggleId } from './resolveSelectionNextIds';
|
|
4
|
+
import type { SelectionMode, SelectionProviderProps, UseSelectionResult } from './types';
|
|
5
|
+
|
|
6
|
+
const MISSING_CONTEXT_MESSAGE =
|
|
7
|
+
'ZORA selection context is missing. Wrap this tree in <SelectionProvider>.';
|
|
8
|
+
|
|
9
|
+
type SelectionContextValue = UseSelectionResult;
|
|
10
|
+
|
|
11
|
+
const SelectionContext = React.createContext<SelectionContextValue | null>(null);
|
|
12
|
+
|
|
13
|
+
function resolveMode(mode: SelectionMode | undefined): SelectionMode {
|
|
14
|
+
return mode ?? 'single';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function resolveDisabled(disabled: boolean | undefined): boolean {
|
|
18
|
+
return disabled ?? false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useSelection(): UseSelectionResult {
|
|
22
|
+
const value = React.useContext(SelectionContext);
|
|
23
|
+
if (!value) {
|
|
24
|
+
throw new Error(MISSING_CONTEXT_MESSAGE);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function SelectionProvider({
|
|
31
|
+
children,
|
|
32
|
+
selectedIds,
|
|
33
|
+
defaultSelectedIds,
|
|
34
|
+
mode,
|
|
35
|
+
disabled,
|
|
36
|
+
onSelectionChange,
|
|
37
|
+
}: SelectionProviderProps) {
|
|
38
|
+
const resolvedMode = resolveMode(mode);
|
|
39
|
+
const resolvedDisabled = resolveDisabled(disabled);
|
|
40
|
+
const isControlled = selectedIds !== undefined;
|
|
41
|
+
|
|
42
|
+
const [uncontrolledIds, setUncontrolledIds] = React.useState<readonly string[]>(
|
|
43
|
+
defaultSelectedIds ?? [],
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const rawIds = isControlled ? selectedIds : uncontrolledIds;
|
|
47
|
+
const currentNormalizedIds = normalizeIds(rawIds, resolvedMode);
|
|
48
|
+
|
|
49
|
+
const selectedIdSet = React.useMemo(() => new Set(currentNormalizedIds), [currentNormalizedIds]);
|
|
50
|
+
|
|
51
|
+
const commitSelectionChange = React.useCallback(
|
|
52
|
+
(nextNormalizedIds: readonly string[]) => {
|
|
53
|
+
if (resolvedDisabled) return;
|
|
54
|
+
if (areIdsEqual(nextNormalizedIds, currentNormalizedIds)) return;
|
|
55
|
+
|
|
56
|
+
onSelectionChange?.(nextNormalizedIds);
|
|
57
|
+
|
|
58
|
+
if (!isControlled) {
|
|
59
|
+
setUncontrolledIds(nextNormalizedIds);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
[currentNormalizedIds, isControlled, onSelectionChange, resolvedDisabled],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const clear = React.useCallback(() => {
|
|
66
|
+
commitSelectionChange(normalizeIds(clearIds(), resolvedMode));
|
|
67
|
+
}, [commitSelectionChange, resolvedMode]);
|
|
68
|
+
|
|
69
|
+
const select = React.useCallback(
|
|
70
|
+
(id: string) => {
|
|
71
|
+
const nextIds = selectId({ mode: resolvedMode, ids: currentNormalizedIds, id });
|
|
72
|
+
const nextNormalizedIds = normalizeIds(nextIds, resolvedMode);
|
|
73
|
+
commitSelectionChange(nextNormalizedIds);
|
|
74
|
+
},
|
|
75
|
+
[commitSelectionChange, currentNormalizedIds, resolvedMode],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const toggle = React.useCallback(
|
|
79
|
+
(id: string) => {
|
|
80
|
+
const nextIds = toggleId({ mode: resolvedMode, ids: currentNormalizedIds, id });
|
|
81
|
+
const nextNormalizedIds = normalizeIds(nextIds, resolvedMode);
|
|
82
|
+
commitSelectionChange(nextNormalizedIds);
|
|
83
|
+
},
|
|
84
|
+
[commitSelectionChange, currentNormalizedIds, resolvedMode],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const value = React.useMemo<UseSelectionResult>(() => {
|
|
88
|
+
return {
|
|
89
|
+
mode: resolvedMode,
|
|
90
|
+
disabled: resolvedDisabled,
|
|
91
|
+
selectedIds: currentNormalizedIds,
|
|
92
|
+
selectedCount: currentNormalizedIds.length,
|
|
93
|
+
hasSelection: currentNormalizedIds.length > 0,
|
|
94
|
+
isSelected: (id: string) => selectedIdSet.has(id),
|
|
95
|
+
select,
|
|
96
|
+
toggle,
|
|
97
|
+
clear,
|
|
98
|
+
};
|
|
99
|
+
}, [clear, currentNormalizedIds, resolvedDisabled, resolvedMode, select, selectedIdSet, toggle]);
|
|
100
|
+
|
|
101
|
+
return <SelectionContext.Provider value={value}>{children}</SelectionContext.Provider>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { SelectableItem } from './SelectableItem';
|
|
2
|
+
export { SelectionProvider, useSelection } from './SelectionProvider';
|
|
3
|
+
export type {
|
|
4
|
+
SelectableItemProps,
|
|
5
|
+
SelectableItemState,
|
|
6
|
+
SelectionMode,
|
|
7
|
+
SelectionProviderProps,
|
|
8
|
+
SelectionTrigger,
|
|
9
|
+
UseSelectionResult,
|
|
10
|
+
} from './types';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { areIdsEqual, clearIds, normalizeIds, selectId, toggleId } from './resolveSelectionNextIds';
|
|
4
|
+
import type { SelectionMode } from './types';
|
|
5
|
+
|
|
6
|
+
describe('resolveSelectionNextIds', () => {
|
|
7
|
+
test('normalizeIds removes duplicates, preserves order', () => {
|
|
8
|
+
expect(normalizeIds(['a', 'b', 'a', 'c'], 'multi')).toEqual(['a', 'b', 'c']);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('normalizeIds keeps only first id in single mode', () => {
|
|
12
|
+
expect(normalizeIds(['a', 'b', 'c'], 'single')).toEqual(['a']);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('normalizeIds treats undefined as empty', () => {
|
|
16
|
+
expect(normalizeIds(undefined, 'multi')).toEqual([]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('areIdsEqual compares order', () => {
|
|
20
|
+
expect(areIdsEqual(['a'], ['a'])).toBeTrue();
|
|
21
|
+
expect(areIdsEqual(['a'], ['b'])).toBeFalse();
|
|
22
|
+
expect(areIdsEqual(['a', 'b'], ['a', 'b'])).toBeTrue();
|
|
23
|
+
expect(areIdsEqual(['a', 'b'], ['b', 'a'])).toBeFalse();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('clearIds returns empty selection', () => {
|
|
27
|
+
expect(clearIds()).toEqual([]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('selectId replaces selection in single mode', () => {
|
|
31
|
+
expect(selectId({ mode: 'single', ids: ['a'], id: 'b' })).toEqual(['b']);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('selectId adds id in multi mode when missing', () => {
|
|
35
|
+
expect(selectId({ mode: 'multi', ids: ['a'], id: 'b' })).toEqual(['a', 'b']);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('selectId is no-op in multi mode when already selected', () => {
|
|
39
|
+
const ids = ['a', 'b'];
|
|
40
|
+
expect(selectId({ mode: 'multi', ids, id: 'b' })).toBe(ids);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('toggleId clears id when already selected (single mode)', () => {
|
|
44
|
+
expect(toggleId({ mode: 'single', ids: ['a'], id: 'a' })).toEqual([]);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('toggleId selects id when not selected (single mode)', () => {
|
|
48
|
+
expect(toggleId({ mode: 'single', ids: [], id: 'a' })).toEqual(['a']);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('toggleId toggles membership (multi mode)', () => {
|
|
52
|
+
expect(toggleId({ mode: 'multi', ids: ['a'], id: 'b' })).toEqual(['a', 'b']);
|
|
53
|
+
expect(toggleId({ mode: 'multi', ids: ['a', 'b'], id: 'b' })).toEqual(['a']);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('mode-change normalization example', () => {
|
|
57
|
+
const internalIds = ['a', 'b'];
|
|
58
|
+
const mode: SelectionMode = 'single';
|
|
59
|
+
expect(normalizeIds(internalIds, mode)).toEqual(['a']);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { SelectionMode } from './types';
|
|
2
|
+
|
|
3
|
+
export function normalizeIds(
|
|
4
|
+
ids: readonly string[] | undefined,
|
|
5
|
+
mode: SelectionMode,
|
|
6
|
+
): readonly string[] {
|
|
7
|
+
const uniqueIds: string[] = [];
|
|
8
|
+
const seen = new Set<string>();
|
|
9
|
+
|
|
10
|
+
for (const id of ids ?? []) {
|
|
11
|
+
if (seen.has(id)) continue;
|
|
12
|
+
seen.add(id);
|
|
13
|
+
uniqueIds.push(id);
|
|
14
|
+
if (mode === 'single') break;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return uniqueIds;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function areIdsEqual(a: readonly string[], b: readonly string[]): boolean {
|
|
21
|
+
if (a.length !== b.length) return false;
|
|
22
|
+
for (let index = 0; index < a.length; index += 1) {
|
|
23
|
+
if (a[index] !== b[index]) return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function clearIds(): readonly string[] {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function selectId({
|
|
34
|
+
mode,
|
|
35
|
+
ids,
|
|
36
|
+
id,
|
|
37
|
+
}: {
|
|
38
|
+
mode: SelectionMode;
|
|
39
|
+
ids: readonly string[];
|
|
40
|
+
id: string;
|
|
41
|
+
}): readonly string[] {
|
|
42
|
+
if (mode === 'single') {
|
|
43
|
+
return [id];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (ids.includes(id)) {
|
|
47
|
+
return ids;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return [...ids, id];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function toggleId({
|
|
54
|
+
mode,
|
|
55
|
+
ids,
|
|
56
|
+
id,
|
|
57
|
+
}: {
|
|
58
|
+
mode: SelectionMode;
|
|
59
|
+
ids: readonly string[];
|
|
60
|
+
id: string;
|
|
61
|
+
}): readonly string[] {
|
|
62
|
+
if (ids.includes(id)) {
|
|
63
|
+
return ids.filter((existingId) => existingId !== id);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (mode === 'single') {
|
|
67
|
+
return [id];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return [...ids, id];
|
|
71
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
export type SelectionMode = 'single' | 'multi';
|
|
4
|
+
|
|
5
|
+
export type SelectionTrigger = 'press' | 'longPress' | 'manual';
|
|
6
|
+
|
|
7
|
+
export interface SelectionProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
selectedIds?: readonly string[];
|
|
10
|
+
defaultSelectedIds?: readonly string[];
|
|
11
|
+
mode?: SelectionMode;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onSelectionChange?: (ids: readonly string[]) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface UseSelectionResult {
|
|
17
|
+
mode: SelectionMode;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
selectedIds: readonly string[];
|
|
20
|
+
selectedCount: number;
|
|
21
|
+
hasSelection: boolean;
|
|
22
|
+
isSelected: (id: string) => boolean;
|
|
23
|
+
select: (id: string) => void;
|
|
24
|
+
toggle: (id: string) => void;
|
|
25
|
+
clear: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SelectableItemState {
|
|
29
|
+
id: string;
|
|
30
|
+
selected: boolean;
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
mode: SelectionMode;
|
|
33
|
+
select: () => void;
|
|
34
|
+
toggle: () => void;
|
|
35
|
+
clear: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SelectableItemProps {
|
|
39
|
+
id: string;
|
|
40
|
+
trigger?: SelectionTrigger;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
children: React.ReactNode | ((state: SelectableItemState) => React.ReactNode);
|
|
43
|
+
}
|