cpk-ui 0.8.0-beta.3 → 0.8.0-beta.4
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 +63 -1
- package/components/modals/AlertDialog/AlertDialog.d.ts +7 -0
- package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/components/modals/AlertDialog/AlertDialog.js +34 -19
- package/components/uis/ReorderableList/ReorderableList.d.ts +37 -0
- package/components/uis/ReorderableList/ReorderableList.d.ts.map +1 -0
- package/components/uis/ReorderableList/ReorderableList.js +87 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/node_modules/react-native-drax/LICENSE.md +21 -0
- package/node_modules/react-native-drax/README.md +454 -0
- package/node_modules/react-native-drax/lib/module/DebugOverlay.js +121 -0
- package/node_modules/react-native-drax/lib/module/DebugOverlay.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/Drax.js +36 -0
- package/node_modules/react-native-drax/lib/module/Drax.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxContext.js +6 -0
- package/node_modules/react-native-drax/lib/module/DraxContext.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxHandle.js +47 -0
- package/node_modules/react-native-drax/lib/module/DraxHandle.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxHandleContext.js +11 -0
- package/node_modules/react-native-drax/lib/module/DraxHandleContext.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxList.js +108 -0
- package/node_modules/react-native-drax/lib/module/DraxList.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxProvider.js +203 -0
- package/node_modules/react-native-drax/lib/module/DraxProvider.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxScrollView.js +167 -0
- package/node_modules/react-native-drax/lib/module/DraxScrollView.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxSubprovider.js +21 -0
- package/node_modules/react-native-drax/lib/module/DraxSubprovider.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/DraxView.js +348 -0
- package/node_modules/react-native-drax/lib/module/DraxView.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/HoverLayer.js +152 -0
- package/node_modules/react-native-drax/lib/module/HoverLayer.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/SortableBoardContainer.js +386 -0
- package/node_modules/react-native-drax/lib/module/SortableBoardContainer.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/SortableBoardContext.js +6 -0
- package/node_modules/react-native-drax/lib/module/SortableBoardContext.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/SortableContainer.js +571 -0
- package/node_modules/react-native-drax/lib/module/SortableContainer.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/SortableItem.js +225 -0
- package/node_modules/react-native-drax/lib/module/SortableItem.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/SortableItemContext.js +38 -0
- package/node_modules/react-native-drax/lib/module/SortableItemContext.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/compat/detectVersion.js +19 -0
- package/node_modules/react-native-drax/lib/module/compat/detectVersion.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/compat/index.js +5 -0
- package/node_modules/react-native-drax/lib/module/compat/index.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/compat/types.js +4 -0
- package/node_modules/react-native-drax/lib/module/compat/types.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/compat/useDraxPanGesture.js +95 -0
- package/node_modules/react-native-drax/lib/module/compat/useDraxPanGesture.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/index.js +5 -0
- package/node_modules/react-native-drax/lib/module/hooks/index.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useCallbackDispatch.js +688 -0
- package/node_modules/react-native-drax/lib/module/hooks/useCallbackDispatch.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDragGesture.js +240 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDragGesture.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxContext.js +12 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxContext.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxId.js +13 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxId.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxMethods.js +73 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxMethods.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxScrollHandler.js +97 -0
- package/node_modules/react-native-drax/lib/module/hooks/useDraxScrollHandler.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useSortableBoard.js +37 -0
- package/node_modules/react-native-drax/lib/module/hooks/useSortableBoard.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useSortableList.js +1025 -0
- package/node_modules/react-native-drax/lib/module/hooks/useSortableList.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useSpatialIndex.js +283 -0
- package/node_modules/react-native-drax/lib/module/hooks/useSpatialIndex.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useViewStyles.js +158 -0
- package/node_modules/react-native-drax/lib/module/hooks/useViewStyles.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/hooks/useWebScrollFreeze.js +52 -0
- package/node_modules/react-native-drax/lib/module/hooks/useWebScrollFreeze.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/index.js +37 -0
- package/node_modules/react-native-drax/lib/module/index.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/math.js +294 -0
- package/node_modules/react-native-drax/lib/module/math.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/package.json +1 -0
- package/node_modules/react-native-drax/lib/module/params.js +88 -0
- package/node_modules/react-native-drax/lib/module/params.js.map +1 -0
- package/node_modules/react-native-drax/lib/module/types.js +215 -0
- package/node_modules/react-native-drax/lib/module/types.js.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/package.json +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DebugOverlay.d.ts +17 -0
- package/node_modules/react-native-drax/lib/typescript/src/DebugOverlay.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/Drax.d.ts +28 -0
- package/node_modules/react-native-drax/lib/typescript/src/Drax.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxContext.d.ts +3 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxContext.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxHandle.d.ts +25 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxHandle.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxHandleContext.d.ts +12 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxHandleContext.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxList.d.ts +66 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxList.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxProvider.d.ts +4 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxProvider.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxScrollView.d.ts +7 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxScrollView.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxSubprovider.d.ts +4 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxSubprovider.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxView.d.ts +4 -0
- package/node_modules/react-native-drax/lib/typescript/src/DraxView.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/HoverLayer.d.ts +38 -0
- package/node_modules/react-native-drax/lib/typescript/src/HoverLayer.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableBoardContainer.d.ts +11 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableBoardContainer.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableBoardContext.d.ts +4 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableBoardContext.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableContainer.d.ts +13 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableContainer.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableItem.d.ts +14 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableItem.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableItemContext.d.ts +37 -0
- package/node_modules/react-native-drax/lib/typescript/src/SortableItemContext.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/detectVersion.d.ts +2 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/detectVersion.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/index.d.ts +4 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/index.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/types.d.ts +33 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/types.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/useDraxPanGesture.d.ts +8 -0
- package/node_modules/react-native-drax/lib/typescript/src/compat/useDraxPanGesture.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/index.d.ts +3 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useCallbackDispatch.d.ts +40 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useCallbackDispatch.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDragGesture.d.ts +17 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDragGesture.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxContext.d.ts +2 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxContext.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxId.d.ts +2 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxId.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxMethods.d.ts +13 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxMethods.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxScrollHandler.d.ts +27 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useDraxScrollHandler.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useSortableBoard.d.ts +10 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useSortableBoard.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useSortableList.d.ts +11 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useSortableList.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useSpatialIndex.d.ts +22 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useSpatialIndex.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useViewStyles.d.ts +183 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useViewStyles.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useWebScrollFreeze.d.ts +14 -0
- package/node_modules/react-native-drax/lib/typescript/src/hooks/useWebScrollFreeze.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/index.d.ts +25 -0
- package/node_modules/react-native-drax/lib/typescript/src/index.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/math.d.ts +76 -0
- package/node_modules/react-native-drax/lib/typescript/src/math.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/params.d.ts +31 -0
- package/node_modules/react-native-drax/lib/typescript/src/params.d.ts.map +1 -0
- package/node_modules/react-native-drax/lib/typescript/src/types.d.ts +756 -0
- package/node_modules/react-native-drax/lib/typescript/src/types.d.ts.map +1 -0
- package/node_modules/react-native-drax/package.json +175 -0
- package/node_modules/react-native-drax/src/DebugOverlay.tsx +140 -0
- package/node_modules/react-native-drax/src/Drax.ts +33 -0
- package/node_modules/react-native-drax/src/DraxContext.ts +8 -0
- package/node_modules/react-native-drax/src/DraxHandle.tsx +52 -0
- package/node_modules/react-native-drax/src/DraxHandleContext.ts +15 -0
- package/node_modules/react-native-drax/src/DraxList.tsx +181 -0
- package/node_modules/react-native-drax/src/DraxProvider.tsx +224 -0
- package/node_modules/react-native-drax/src/DraxScrollView.tsx +180 -0
- package/node_modules/react-native-drax/src/DraxSubprovider.tsx +22 -0
- package/node_modules/react-native-drax/src/DraxView.tsx +430 -0
- package/node_modules/react-native-drax/src/HoverLayer.tsx +167 -0
- package/node_modules/react-native-drax/src/SortableBoardContainer.tsx +439 -0
- package/node_modules/react-native-drax/src/SortableBoardContext.ts +6 -0
- package/node_modules/react-native-drax/src/SortableContainer.tsx +650 -0
- package/node_modules/react-native-drax/src/SortableItem.tsx +263 -0
- package/node_modules/react-native-drax/src/SortableItemContext.ts +46 -0
- package/node_modules/react-native-drax/src/compat/detectVersion.ts +17 -0
- package/node_modules/react-native-drax/src/compat/index.ts +7 -0
- package/node_modules/react-native-drax/src/compat/types.ts +35 -0
- package/node_modules/react-native-drax/src/compat/useDraxPanGesture.ts +111 -0
- package/node_modules/react-native-drax/src/hooks/index.ts +2 -0
- package/node_modules/react-native-drax/src/hooks/useCallbackDispatch.tsx +830 -0
- package/node_modules/react-native-drax/src/hooks/useDragGesture.ts +273 -0
- package/node_modules/react-native-drax/src/hooks/useDraxContext.ts +11 -0
- package/node_modules/react-native-drax/src/hooks/useDraxId.ts +11 -0
- package/node_modules/react-native-drax/src/hooks/useDraxMethods.ts +71 -0
- package/node_modules/react-native-drax/src/hooks/useDraxScrollHandler.ts +121 -0
- package/node_modules/react-native-drax/src/hooks/useSortableBoard.ts +44 -0
- package/node_modules/react-native-drax/src/hooks/useSortableList.ts +1102 -0
- package/node_modules/react-native-drax/src/hooks/useSpatialIndex.ts +336 -0
- package/node_modules/react-native-drax/src/hooks/useViewStyles.ts +180 -0
- package/node_modules/react-native-drax/src/hooks/useWebScrollFreeze.ts +60 -0
- package/node_modules/react-native-drax/src/index.ts +111 -0
- package/node_modules/react-native-drax/src/math.ts +333 -0
- package/node_modules/react-native-drax/src/params.ts +74 -0
- package/node_modules/react-native-drax/src/types.ts +933 -0
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ dark theme tokens. Applications that provide product-specific tokens can pass
|
|
|
82
82
|
| Actions | Button, CustomPressable, Fab, IconButton |
|
|
83
83
|
| Inputs | Calendar, Checkbox, EditText, RadioGroup, Rating, SegmentedControl, SwitchToggle |
|
|
84
84
|
| Feedback | AlertDialog, ErrorBoundary, LoadingIndicator, Snackbar |
|
|
85
|
-
| Display | Accordion, Card, Hr, Icon, ParallaxHeader, Typography
|
|
85
|
+
| Display | Accordion, Card, Hr, Icon, ParallaxHeader, ReorderableList, Typography |
|
|
86
86
|
| Media and system | PinchZoom, StatusBarBrightness |
|
|
87
87
|
|
|
88
88
|
Each public component has automated tests and Storybook coverage for its main
|
|
@@ -91,6 +91,41 @@ controls, responsive behavior, accessibility results, and source examples.
|
|
|
91
91
|
|
|
92
92
|
## Release Matrix
|
|
93
93
|
|
|
94
|
+
### ReorderableList (0.8.0-beta.4)
|
|
95
|
+
|
|
96
|
+
`ReorderableList<T>` composes FlashList and react-native-drax. Provide stable
|
|
97
|
+
domain keys, `getItemLabel`, controlled `data`/`onReorder`, and place the
|
|
98
|
+
supplied `dragHandle` inside `renderItem`. Keep the host within
|
|
99
|
+
`GestureHandlerRootView` and give the list a bounded viewport. Apply the new
|
|
100
|
+
order optimistically and roll back on persistence failure. `disabled` removes
|
|
101
|
+
handles without hiding content. The 48pt handles also expose assistive
|
|
102
|
+
increment/decrement actions; no visible Move up/Move down controls are needed.
|
|
103
|
+
Variable row height, autoscroll and reduced motion are owned by the engine.
|
|
104
|
+
FlashList's default visible-item anchoring is disabled for this reorderable
|
|
105
|
+
surface: keeping the former first row anchored after a move would scroll the
|
|
106
|
+
viewport unexpectedly. Accepted orders become real row layout, not permanent
|
|
107
|
+
transforms, so subsequent inline editor height changes remain coherent.
|
|
108
|
+
The row renderer owns text semantics: compact titles may truncate, body copy
|
|
109
|
+
must not inherit that limit. See Display/ReorderableList stories.
|
|
110
|
+
|
|
111
|
+
Requires FlashList 2 (New Architecture), React 19 and Reanimated 4. The package
|
|
112
|
+
bundles its exact patched, JS-only Drax 1.1.0 dependency and MIT license. The
|
|
113
|
+
reproducible patch is `patches/react-native-drax@1.1.0.patch`; the build refuses
|
|
114
|
+
an unpatched engine. Consumers do not need a local patch, fork or postinstall
|
|
115
|
+
mutation. In RN 0.85+ overlays use `StyleSheet.absoluteFill` instead of removed
|
|
116
|
+
`absoluteFillObject`. Verify the packed engine, not only the source checkout.
|
|
117
|
+
The same patch late-binds SortableItem's snap callback: the container registers
|
|
118
|
+
it in a layout effect, so destructuring it during render captures `undefined`
|
|
119
|
+
and prevents the completed drop from committing. Package-boundary regression
|
|
120
|
+
guards cover source and module output; native drag/persistence remains required.
|
|
121
|
+
The patch also supports partially measured single-column virtualized lists:
|
|
122
|
+
hit testing uses known slots and displacement needs geometry only within the
|
|
123
|
+
changed range. Unknown row heights are not guessed, and grid behavior remains
|
|
124
|
+
unchanged. When the consumer accepts an order, flush the temporary visual
|
|
125
|
+
permutation into actual data and clear shifts in the layout phase. Tests cover
|
|
126
|
+
partial measurement, variable heights, horizontal lists and accepted order;
|
|
127
|
+
native reorder → expand/edit → save → reopen must still be replayed.
|
|
128
|
+
|
|
94
129
|
The 0.8.0 beta is verified with Expo 54, React Native 0.81, React 19,
|
|
95
130
|
kstyled 0.4, and React Native Web 0.21. This is the release validation matrix,
|
|
96
131
|
not a claim that every consumer must use those exact React or React Native
|
|
@@ -119,6 +154,33 @@ main-branch GitHub Actions publish workflow with provenance.
|
|
|
119
154
|
- [Changelog](./CHANGELOG.md)
|
|
120
155
|
- [Contributing](./CONTRIBUTING.md)
|
|
121
156
|
|
|
157
|
+
### Custom dialog slots
|
|
158
|
+
|
|
159
|
+
`AlertDialog` supports the same slots in controlled props and
|
|
160
|
+
`useCPK().alertDialog.open(options)`: `renderHeader`, `renderBody`, and
|
|
161
|
+
`renderActions`. Each receives `{close}`. Render functions take precedence
|
|
162
|
+
over the existing `title`, `body`, and `actions` content; keep `title` as a
|
|
163
|
+
plain string to name the dialog for assistive technology.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
alertDialog.open({
|
|
167
|
+
title: 'Transfer ownership',
|
|
168
|
+
renderHeader: () => <OwnershipHeader />,
|
|
169
|
+
renderBody: () => <OwnershipExplanation />,
|
|
170
|
+
renderActions: ({close}) => [
|
|
171
|
+
<Button key="cancel" text="Cancel" onPress={close} />,
|
|
172
|
+
<Button key="confirm" text="Transfer" onPress={requestTransfer} />,
|
|
173
|
+
],
|
|
174
|
+
closeOnTouchOutside: false,
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The header may contain an icon or any custom content. Keep its root's height
|
|
179
|
+
intrinsic (not `flex: 1` inside the title slot). Custom action `style` overrides
|
|
180
|
+
the equal-width defaults; `flex: 0, flexBasis: 'auto'` works for intrinsic-width
|
|
181
|
+
actions on native and web. Use `styles.actionContainer` to align the group.
|
|
182
|
+
The backdrop consistently darkens either theme and respects `backdropOpacity`.
|
|
183
|
+
|
|
122
184
|
## License
|
|
123
185
|
|
|
124
186
|
MIT
|
|
@@ -18,6 +18,13 @@ export type AlertDialogOptions = {
|
|
|
18
18
|
actions?: ReactElement[];
|
|
19
19
|
showCloseButton?: boolean;
|
|
20
20
|
size?: AlertDialogSizeType;
|
|
21
|
+
/** Custom slots take precedence over title/body/actions. Keep title for a11y. */
|
|
22
|
+
renderHeader?: (context: AlertDialogRenderContext) => ReactElement | null;
|
|
23
|
+
renderBody?: (context: AlertDialogRenderContext) => ReactElement | null;
|
|
24
|
+
renderActions?: (context: AlertDialogRenderContext) => ReactElement[] | null;
|
|
25
|
+
};
|
|
26
|
+
export type AlertDialogRenderContext = {
|
|
27
|
+
close: () => void;
|
|
21
28
|
};
|
|
22
29
|
export type AlertDialogProps = {
|
|
23
30
|
style?: StyleProp<ViewStyle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/modals/AlertDialog/AlertDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"AlertDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/modals/AlertDialog/AlertDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EASZ,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AA8DlE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,iFAAiF;IACjF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,YAAY,GAAG,IAAI,CAAC;IAC1E,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,YAAY,GAAG,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,YAAY,EAAE,GAAG,IAAI,CAAC;CAC9E,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,GAAG,kBAAkB,CAAC;AAEvB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAyVF,eAAO,MAAM,WAAW;YAjWd,SAAS,CAAC,SAAS,CAAC;cAClB,OAAO;cACP,MAAM,IAAI;iEAiWrB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useState, useCallback, useMemo, } from 'react';
|
|
2
|
+
import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useState, useCallback, useMemo, isValidElement, } from 'react';
|
|
3
3
|
import { KeyboardAvoidingView, Modal, Platform, StyleSheet, TouchableWithoutFeedback, View, } from 'react-native';
|
|
4
4
|
import { styled, css } from 'kstyled';
|
|
5
5
|
import { useTheme } from '../../../providers/ThemeProvider';
|
|
@@ -52,10 +52,10 @@ const ActionRow = styled.View `
|
|
|
52
52
|
padding-right: 4px;
|
|
53
53
|
flex-direction: row;
|
|
54
54
|
`;
|
|
55
|
-
function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacityProp, body: bodyProp, closeOnTouchOutside: closeOnTouchOutsideProp, onClose, showCloseButton: showCloseButtonProp, size: sizeProp, style, styles: stylesProp, title: titleProp, visible: visibleProp, }, ref) {
|
|
55
|
+
function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacityProp, body: bodyProp, closeOnTouchOutside: closeOnTouchOutsideProp, onClose, renderHeader: renderHeaderProp, renderBody: renderBodyProp, renderActions: renderActionsProp, showCloseButton: showCloseButtonProp, size: sizeProp, style, styles: stylesProp, title: titleProp, visible: visibleProp, }, ref) {
|
|
56
56
|
const [openedOptions, setOpenedOptions] = useState(null);
|
|
57
57
|
const [uncontrolledVisible, setUncontrolledVisible] = useState(false);
|
|
58
|
-
const { theme
|
|
58
|
+
const { theme } = useTheme();
|
|
59
59
|
const isControlled = visibleProp !== undefined;
|
|
60
60
|
const visible = isControlled ? visibleProp : uncontrolledVisible;
|
|
61
61
|
const options = isControlled
|
|
@@ -63,6 +63,9 @@ function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacit
|
|
|
63
63
|
actions: actionsProp,
|
|
64
64
|
backdropOpacity: backdropOpacityProp,
|
|
65
65
|
body: bodyProp,
|
|
66
|
+
renderHeader: renderHeaderProp,
|
|
67
|
+
renderBody: renderBodyProp,
|
|
68
|
+
renderActions: renderActionsProp,
|
|
66
69
|
closeOnTouchOutside: closeOnTouchOutsideProp,
|
|
67
70
|
showCloseButton: showCloseButtonProp,
|
|
68
71
|
size: sizeProp,
|
|
@@ -95,7 +98,7 @@ function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacit
|
|
|
95
98
|
open: handleOpen,
|
|
96
99
|
close: handleClose,
|
|
97
100
|
}), [handleOpen, handleClose]);
|
|
98
|
-
const { backdropOpacity = 0.2, title, body, styles, actions, closeOnTouchOutside = true, showCloseButton = true, size = 'medium', } = options ?? {};
|
|
101
|
+
const { backdropOpacity = 0.2, title, body, renderHeader, renderBody, renderActions, styles, actions, closeOnTouchOutside = true, showCloseButton = true, size = 'medium', } = options ?? {};
|
|
99
102
|
// Calculate sizes based on size prop
|
|
100
103
|
const sizeConfig = useMemo(() => {
|
|
101
104
|
if (typeof size === 'number') {
|
|
@@ -138,10 +141,9 @@ function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacit
|
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
}, [size]);
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
: `rgba(255,255,255,${backdropOpacity})`, [themeType, backdropOpacity]);
|
|
144
|
+
// A scrim subdues the background in either theme. A white dark-mode overlay
|
|
145
|
+
// washes out the page and reverses the dialog's foreground hierarchy.
|
|
146
|
+
const backdropColor = useMemo(() => `rgba(0,0,0,${backdropOpacity})`, [backdropOpacity]);
|
|
145
147
|
// Memoize shadow styles
|
|
146
148
|
const shadowStyles = useMemo(() => Platform.OS !== 'web'
|
|
147
149
|
? {
|
|
@@ -157,18 +159,31 @@ function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacit
|
|
|
157
159
|
handleClose();
|
|
158
160
|
}, [closeOnTouchOutside, handleClose]);
|
|
159
161
|
const handleCloseButtonPress = handleClose;
|
|
162
|
+
const renderContext = useMemo(() => ({ close: handleClose }), [handleClose]);
|
|
160
163
|
// Memoize title content
|
|
161
|
-
const titleContent = useMemo(() => typeof title === 'string' ? (_jsx(Typography.Heading3, { style: [{ fontSize: sizeConfig.titleFontSize }, styles?.title], children: title })) : (title), [
|
|
164
|
+
const titleContent = useMemo(() => renderHeader ? (renderHeader(renderContext)) : typeof title === 'string' ? (_jsx(Typography.Heading3, { style: [{ fontSize: sizeConfig.titleFontSize }, styles?.title], children: title })) : (title), [
|
|
165
|
+
renderHeader,
|
|
166
|
+
renderContext,
|
|
167
|
+
title,
|
|
168
|
+
sizeConfig.titleFontSize,
|
|
169
|
+
styles?.title,
|
|
170
|
+
]);
|
|
162
171
|
// Memoize body content
|
|
163
|
-
const bodyContent = useMemo(() => typeof body === 'string' ? (_jsx(Typography.Body3, { style: [{ fontSize: sizeConfig.bodyFontSize }, styles?.body], children: body })) : (body), [body, sizeConfig.bodyFontSize, styles?.body]);
|
|
172
|
+
const bodyContent = useMemo(() => renderBody ? (renderBody(renderContext)) : typeof body === 'string' ? (_jsx(Typography.Body3, { style: [{ fontSize: sizeConfig.bodyFontSize }, styles?.body], children: body })) : (body), [renderBody, renderContext, body, sizeConfig.bodyFontSize, styles?.body]);
|
|
164
173
|
// Memoize actions content
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
const renderedActions = useMemo(() => (renderActions ? renderActions(renderContext) : actions), [renderActions, renderContext, actions]);
|
|
175
|
+
const actionsContent = useMemo(() => renderedActions ? (_jsx(ActionRow, { "$marginTop": sizeConfig.actionMarginTop, style: styles?.actionContainer, children: renderedActions.map((action, index) => isValidElement(action)
|
|
176
|
+
? cloneElement(action, {
|
|
177
|
+
key: `action-${index}`,
|
|
178
|
+
style: [
|
|
179
|
+
{
|
|
180
|
+
flex: 1,
|
|
181
|
+
marginLeft: index !== 0 ? 12 : 0,
|
|
182
|
+
},
|
|
183
|
+
action.props.style,
|
|
184
|
+
],
|
|
185
|
+
})
|
|
186
|
+
: action) })) : null, [renderedActions, sizeConfig.actionMarginTop, styles?.actionContainer]);
|
|
172
187
|
// Memoize close button content
|
|
173
188
|
const closeButtonContent = useMemo(() => showCloseButton ? (_jsx(Button, { accessibilityLabel: "Close dialog", onPress: handleCloseButtonPress, borderRadius: 24, text: _jsx(Icon, { color: theme.text.basic, name: "X", size: sizeConfig.iconSize }), type: "text" })) : null, [
|
|
174
189
|
showCloseButton,
|
|
@@ -177,7 +192,7 @@ function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacit
|
|
|
177
192
|
theme.text.basic,
|
|
178
193
|
]);
|
|
179
194
|
const titleSlotStyle = useMemo(() => ({ flex: 1, minWidth: 0 }), []);
|
|
180
|
-
const AlertDialogContent = useMemo(() => (_jsxs(Container, { style: css `
|
|
195
|
+
const AlertDialogContent = useMemo(() => (_jsxs(Container, { testID: "alert-dialog-overlay", style: css `
|
|
181
196
|
background-color: ${backdropColor};
|
|
182
197
|
`, children: [_jsx(TouchableWithoutFeedback, { onPress: handleBackdropPress, children: _jsx(View, { style: StyleSheet.absoluteFill, testID: "alert-dialog-backdrop" }) }), _jsxs(AlertDialogContainer, { "$size": size, accessibilityRole: "alert", accessibilityLabel: typeof title === 'string' ? title : 'Alert dialog', style: containerStyles, children: [_jsxs(TitleRow, { style: styles?.titleContainer, children: [_jsx(View, { style: titleSlotStyle, children: titleContent }), closeButtonContent] }), _jsx(BodyRow, { "$marginTop": sizeConfig.bodyMarginTop, "$marginBottom": sizeConfig.bodyMarginBottom, style: styles?.bodyContainer, children: bodyContent }), actionsContent] })] })), [
|
|
183
198
|
backdropColor,
|
|
@@ -197,7 +212,7 @@ function AlertDialogImpl({ actions: actionsProp, backdropOpacity: backdropOpacit
|
|
|
197
212
|
]);
|
|
198
213
|
return (
|
|
199
214
|
// https://github.com/facebook/react-native/issues/48526#issuecomment-2579478884
|
|
200
|
-
_jsx(View, { style: style, children: _jsx(Modal, { animationType: "fade", onRequestClose: handleClose, transparent: true, visible: visible, children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: keyboardAvoidingStyle, children:
|
|
215
|
+
_jsx(View, { style: style, children: _jsx(Modal, { animationType: "fade", onRequestClose: handleClose, transparent: true, visible: visible, children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: keyboardAvoidingStyle, children: AlertDialogContent }) }) }));
|
|
201
216
|
}
|
|
202
217
|
const keyboardAvoidingStyle = { flex: 1 };
|
|
203
218
|
export const AlertDialog = React.memo(forwardRef(AlertDialogImpl));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
export interface ReorderableListItem<T> {
|
|
4
|
+
item: T;
|
|
5
|
+
index: number;
|
|
6
|
+
/** Place this handle inside the row; other row actions remain independent. */
|
|
7
|
+
dragHandle: ReactElement | null;
|
|
8
|
+
}
|
|
9
|
+
export interface ReorderableListProps<T> {
|
|
10
|
+
data: T[];
|
|
11
|
+
/** Use a stable item identity; index-only keys cannot survive reordering. */
|
|
12
|
+
keyExtractor: (item: T, index: number) => string;
|
|
13
|
+
getItemLabel: (item: T) => string;
|
|
14
|
+
renderItem: (info: ReorderableListItem<T>) => ReactElement;
|
|
15
|
+
/** Controlled order: update data immediately, then persist/rollback upstream. */
|
|
16
|
+
onReorder: (data: T[]) => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
extraData?: unknown;
|
|
19
|
+
accessibilityHint?: string;
|
|
20
|
+
testID?: string;
|
|
21
|
+
styles?: {
|
|
22
|
+
container?: StyleProp<ViewStyle>;
|
|
23
|
+
content?: ViewStyle;
|
|
24
|
+
item?: StyleProp<ViewStyle>;
|
|
25
|
+
handle?: StyleProp<ViewStyle>;
|
|
26
|
+
};
|
|
27
|
+
renderHandle?: (info: {
|
|
28
|
+
item: T;
|
|
29
|
+
index: number;
|
|
30
|
+
}) => ReactElement;
|
|
31
|
+
onDragStateChange?: (dragging: boolean) => void;
|
|
32
|
+
onEndReached?: () => void;
|
|
33
|
+
ListEmptyComponent?: ReactElement;
|
|
34
|
+
}
|
|
35
|
+
/** Virtualized, handle-only reordering. Requires the host's GestureHandlerRootView. */
|
|
36
|
+
export declare function ReorderableList<T>(props: ReorderableListProps<T>): ReactElement;
|
|
37
|
+
//# sourceMappingURL=ReorderableList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReorderableList.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/ReorderableList/ReorderableList.tsx"],"names":[],"mappings":"AAAA,OAAc,EAA+B,KAAK,YAAY,EAAC,MAAM,OAAO,CAAC;AAC7E,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAYtB,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,6EAA6E;IAC7E,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAClC,UAAU,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC;IAC3D,iFAAiF;IACjF,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,CAAC,EAAE,SAAS,CAAC;QACpB,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAC/B,CAAC;IACF,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAC,IAAI,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,KAAK,YAAY,CAAC;IAChE,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,kBAAkB,CAAC,EAAE,YAAY,CAAC;CACnC;AAED,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,CAAC,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC7B,YAAY,CAQd"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
3
|
+
import { Platform, StyleSheet, View, } from 'react-native';
|
|
4
|
+
import { FlashList } from '@shopify/flash-list';
|
|
5
|
+
import { DraxHandle, DraxProvider, SortableContainer, SortableItem, useSortableList, } from 'react-native-drax';
|
|
6
|
+
import { useTheme } from '../../../providers/ThemeProvider';
|
|
7
|
+
import { Icon } from '../Icon/Icon';
|
|
8
|
+
/** Virtualized, handle-only reordering. Requires the host's GestureHandlerRootView. */
|
|
9
|
+
export function ReorderableList(props) {
|
|
10
|
+
return (_jsx(View, { style: [layout.container, props.styles?.container], children: _jsx(DraxProvider, { children: _jsx(ReorderableContent, { ...props }) }) }));
|
|
11
|
+
}
|
|
12
|
+
function ReorderableContent({ data, keyExtractor, getItemLabel, renderItem, onReorder, disabled = false, extraData, accessibilityHint = 'Hold and drag to reorder. Adjust up or down to move one place.', testID = 'reorderable-list', styles, renderHandle, onDragStateChange, onEndReached, ListEmptyComponent, }) {
|
|
13
|
+
const { theme } = useTheme();
|
|
14
|
+
const scrollRef = useRef(null);
|
|
15
|
+
const acceptedPositions = useMemo(() => new Map(data.map((item, index) => [keyExtractor(item, index), index + 1])), [data, keyExtractor]);
|
|
16
|
+
const sortable = useSortableList({
|
|
17
|
+
data,
|
|
18
|
+
keyExtractor,
|
|
19
|
+
onReorder: (event) => {
|
|
20
|
+
if (!disabled && event.fromIndex !== event.toIndex)
|
|
21
|
+
onReorder(event.data);
|
|
22
|
+
},
|
|
23
|
+
lockToMainAxis: true,
|
|
24
|
+
// Mouse dragging should begin immediately; touch keeps scroll protection.
|
|
25
|
+
longPressDelay: Platform.OS === 'web' ? 0 : 220,
|
|
26
|
+
animationConfig: 'spring',
|
|
27
|
+
inactiveItemStyle: { opacity: 0.8 },
|
|
28
|
+
onDragStart: () => onDragStateChange?.(true),
|
|
29
|
+
onDragEnd: () => onDragStateChange?.(false),
|
|
30
|
+
});
|
|
31
|
+
const moveAccessible = useCallback((item, rowIndex, direction) => {
|
|
32
|
+
if (disabled)
|
|
33
|
+
return;
|
|
34
|
+
const key = keyExtractor(item, rowIndex);
|
|
35
|
+
const from = data.findIndex((row, index) => keyExtractor(row, index) === key);
|
|
36
|
+
const to = from + direction;
|
|
37
|
+
if (from < 0 || to < 0 || to >= data.length)
|
|
38
|
+
return;
|
|
39
|
+
const next = [...data];
|
|
40
|
+
next.splice(from, 1);
|
|
41
|
+
next.splice(to, 0, item);
|
|
42
|
+
onReorder(next);
|
|
43
|
+
}, [data, disabled, keyExtractor, onReorder]);
|
|
44
|
+
return (_jsx(SortableContainer, { sortable: sortable, scrollRef: scrollRef, style: layout.container, children: _jsx(FlashList, { ref: scrollRef, data: sortable.data, extraData: extraData,
|
|
45
|
+
// A committed reorder must not scroll to keep the former first item
|
|
46
|
+
// anchored. The gesture engine already owns motion and autoscroll.
|
|
47
|
+
maintainVisibleContentPosition: { disabled: true },
|
|
48
|
+
// Stable domain keys also keep recycled editors attached to their item.
|
|
49
|
+
keyExtractor: keyExtractor, contentContainerStyle: styles?.content, onScroll: sortable.onScroll, onContentSizeChange: sortable.onContentSizeChange, onEndReached: onEndReached, ListEmptyComponent: ListEmptyComponent, scrollEventThrottle: 16, testID: testID, renderItem: ({ item, index }) => (_jsx(SortableItem, { sortable: sortable, index: index, draggable: !disabled, dragHandle: true, style: styles?.item, accessible: false, accessibilityRole: "none", accessibilityLabel: undefined, accessibilityHint: undefined, children: renderItem({
|
|
50
|
+
item,
|
|
51
|
+
index,
|
|
52
|
+
dragHandle: disabled ? null : (_jsx(DraxHandle, { children: _jsx(View, { accessible: true, focusable: true, ...(Platform.OS === 'web'
|
|
53
|
+
? {
|
|
54
|
+
tabIndex: 0,
|
|
55
|
+
onKeyDown: (event) => {
|
|
56
|
+
if (event.key !== 'ArrowUp' &&
|
|
57
|
+
event.key !== 'ArrowDown')
|
|
58
|
+
return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
moveAccessible(item, index, event.key === 'ArrowUp' ? -1 : 1);
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
: {}), accessibilityRole: "adjustable", accessibilityLabel: getItemLabel(item), accessibilityHint: accessibilityHint, accessibilityValue: {
|
|
64
|
+
min: 1,
|
|
65
|
+
max: data.length,
|
|
66
|
+
now: acceptedPositions.get(keyExtractor(item, index)) ??
|
|
67
|
+
index + 1,
|
|
68
|
+
}, accessibilityActions: [
|
|
69
|
+
{ name: 'increment' },
|
|
70
|
+
{ name: 'decrement' },
|
|
71
|
+
], onAccessibilityAction: ({ nativeEvent }) => {
|
|
72
|
+
if (nativeEvent.actionName === 'increment')
|
|
73
|
+
moveAccessible(item, index, 1);
|
|
74
|
+
if (nativeEvent.actionName === 'decrement')
|
|
75
|
+
moveAccessible(item, index, -1);
|
|
76
|
+
}, testID: `${testID}-handle-${keyExtractor(item, index)}`, style: [layout.handle, styles?.handle], children: renderHandle?.({ item, index }) ?? (_jsx(Icon, { name: "DotsSixVertical", size: 22, color: theme.text.label })) }) })),
|
|
77
|
+
}) })) }) }));
|
|
78
|
+
}
|
|
79
|
+
const layout = StyleSheet.create({
|
|
80
|
+
container: { flex: 1, minHeight: 0 },
|
|
81
|
+
handle: {
|
|
82
|
+
width: 48,
|
|
83
|
+
minHeight: 48,
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
},
|
|
87
|
+
});
|
package/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './components/uis/PageIndicator/PageIndicator';
|
|
|
18
18
|
export * from './components/uis/PinchZoom/PinchZoom';
|
|
19
19
|
export * from './components/uis/ParallaxHeader/ParallaxHeader';
|
|
20
20
|
export * from './components/uis/Rating/Rating';
|
|
21
|
+
export * from './components/uis/ReorderableList/ReorderableList';
|
|
21
22
|
export * from './components/uis/RadioGroup/RadioGroup';
|
|
22
23
|
export * from './components/uis/SegmentedControl/SegmentedControl';
|
|
23
24
|
export * from './components/uis/StatusbarBrightness/StatusBarBrightness';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AAGtD,cAAc,iDAAiD,CAAC;AAGhE,cAAc,aAAa,CAAC;AAG5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kDAAkD,CAAC;AACjE,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wCAAwC,CAAC;AACvD,cAAc,oDAAoD,CAAC;AACnE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,oDAAoD,CAAC;AACnE,cAAc,0DAA0D,CAAC;AACzE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AAGvD,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AAGtD,cAAc,iDAAiD,CAAC;AAGhE,cAAc,aAAa,CAAC;AAG5B,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kDAAkD,CAAC;AACjE,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wCAAwC,CAAC;AACvD,cAAc,oDAAoD,CAAC;AACnE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kDAAkD,CAAC;AACjE,cAAc,wCAAwC,CAAC;AACvD,cAAc,oDAAoD,CAAC;AACnE,cAAc,0DAA0D,CAAC;AACzE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AAGvD,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
|
package/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export * from './components/uis/PageIndicator/PageIndicator';
|
|
|
22
22
|
export * from './components/uis/PinchZoom/PinchZoom';
|
|
23
23
|
export * from './components/uis/ParallaxHeader/ParallaxHeader';
|
|
24
24
|
export * from './components/uis/Rating/Rating';
|
|
25
|
+
export * from './components/uis/ReorderableList/ReorderableList';
|
|
25
26
|
export * from './components/uis/RadioGroup/RadioGroup';
|
|
26
27
|
export * from './components/uis/SegmentedControl/SegmentedControl';
|
|
27
28
|
export * from './components/uis/StatusbarBrightness/StatusBarBrightness';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-2026 Nuclear Pasta, SRL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|