zkit-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/README.md +267 -0
  2. package/dist/ComponentLibProvider.d.ts +15 -0
  3. package/dist/ComponentLibProvider.d.ts.map +1 -0
  4. package/dist/ComponentLibProvider.js +18 -0
  5. package/dist/assets/animations/spinner.json +1 -0
  6. package/dist/assets/icons/check.svg +4 -0
  7. package/dist/assets/icons/toast/error.webp +0 -0
  8. package/dist/assets/icons/toast/success.webp +0 -0
  9. package/dist/assets/icons/toast/warning.webp +0 -0
  10. package/dist/config.d.ts +16 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +42 -0
  13. package/dist/i18n/I18nProvider.d.ts +11 -0
  14. package/dist/i18n/I18nProvider.d.ts.map +1 -0
  15. package/dist/i18n/I18nProvider.js +84 -0
  16. package/dist/i18n/locale.d.ts +7 -0
  17. package/dist/i18n/locale.d.ts.map +1 -0
  18. package/dist/i18n/locale.js +87 -0
  19. package/dist/i18n/locales/de.d.ts +51 -0
  20. package/dist/i18n/locales/de.d.ts.map +1 -0
  21. package/dist/i18n/locales/de.js +62 -0
  22. package/dist/i18n/locales/en-US.d.ts +51 -0
  23. package/dist/i18n/locales/en-US.d.ts.map +1 -0
  24. package/dist/i18n/locales/en-US.js +62 -0
  25. package/dist/i18n/locales/index.d.ts +9 -0
  26. package/dist/i18n/locales/index.d.ts.map +1 -0
  27. package/dist/i18n/locales/index.js +23 -0
  28. package/dist/i18n/locales/ja.d.ts +51 -0
  29. package/dist/i18n/locales/ja.d.ts.map +1 -0
  30. package/dist/i18n/locales/ja.js +62 -0
  31. package/dist/i18n/locales/zh-CN.d.ts +51 -0
  32. package/dist/i18n/locales/zh-CN.d.ts.map +1 -0
  33. package/dist/i18n/locales/zh-CN.js +62 -0
  34. package/dist/i18n/locales/zh-TW.d.ts +51 -0
  35. package/dist/i18n/locales/zh-TW.d.ts.map +1 -0
  36. package/dist/i18n/locales/zh-TW.js +62 -0
  37. package/dist/i18n/types.d.ts +11 -0
  38. package/dist/i18n/types.d.ts.map +1 -0
  39. package/dist/i18n/types.js +2 -0
  40. package/dist/i18n/useI18n.d.ts +2 -0
  41. package/dist/i18n/useI18n.d.ts.map +1 -0
  42. package/dist/i18n/useI18n.js +41 -0
  43. package/dist/index.d.ts +57 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +90 -0
  46. package/dist/services/ActionDialogService/ActionDialog.d.ts +4 -0
  47. package/dist/services/ActionDialogService/ActionDialog.d.ts.map +1 -0
  48. package/dist/services/ActionDialogService/ActionDialog.js +531 -0
  49. package/dist/services/ActionDialogService/index.d.ts +4 -0
  50. package/dist/services/ActionDialogService/index.d.ts.map +1 -0
  51. package/dist/services/ActionDialogService/index.js +8 -0
  52. package/dist/services/ActionDialogService/service.d.ts +7 -0
  53. package/dist/services/ActionDialogService/service.d.ts.map +1 -0
  54. package/dist/services/ActionDialogService/service.js +309 -0
  55. package/dist/services/ActionDialogService/shared.d.ts +17 -0
  56. package/dist/services/ActionDialogService/shared.d.ts.map +1 -0
  57. package/dist/services/ActionDialogService/shared.js +167 -0
  58. package/dist/services/ActionDialogService/types.d.ts +160 -0
  59. package/dist/services/ActionDialogService/types.d.ts.map +1 -0
  60. package/dist/services/ActionDialogService/types.js +2 -0
  61. package/dist/services/CardToastService/index.d.ts +115 -0
  62. package/dist/services/CardToastService/index.d.ts.map +1 -0
  63. package/dist/services/CardToastService/index.js +899 -0
  64. package/dist/services/ImagePreviewService/index.d.ts +179 -0
  65. package/dist/services/ImagePreviewService/index.d.ts.map +1 -0
  66. package/dist/services/ImagePreviewService/index.js +1383 -0
  67. package/dist/services/LoadingService/index.d.ts +146 -0
  68. package/dist/services/LoadingService/index.d.ts.map +1 -0
  69. package/dist/services/LoadingService/index.js +827 -0
  70. package/dist/services/PermissionPurposeDialogService/index.d.ts +99 -0
  71. package/dist/services/PermissionPurposeDialogService/index.d.ts.map +1 -0
  72. package/dist/services/PermissionPurposeDialogService/index.js +360 -0
  73. package/dist/services/PickerService/index.d.ts +128 -0
  74. package/dist/services/PickerService/index.d.ts.map +1 -0
  75. package/dist/services/PickerService/index.js +250 -0
  76. package/dist/theme/ThemeProvider.d.ts +15 -0
  77. package/dist/theme/ThemeProvider.d.ts.map +1 -0
  78. package/dist/theme/ThemeProvider.js +61 -0
  79. package/dist/theme/defaultTheme.d.ts +3 -0
  80. package/dist/theme/defaultTheme.d.ts.map +1 -0
  81. package/dist/theme/defaultTheme.js +28 -0
  82. package/dist/theme/mergeTheme.d.ts +3 -0
  83. package/dist/theme/mergeTheme.d.ts.map +1 -0
  84. package/dist/theme/mergeTheme.js +19 -0
  85. package/dist/theme/types.d.ts +17 -0
  86. package/dist/theme/types.d.ts.map +1 -0
  87. package/dist/theme/types.js +2 -0
  88. package/dist/theme/useTheme.d.ts +2 -0
  89. package/dist/theme/useTheme.d.ts.map +1 -0
  90. package/dist/theme/useTheme.js +46 -0
  91. package/dist/ui/Accordion/index.d.ts +99 -0
  92. package/dist/ui/Accordion/index.d.ts.map +1 -0
  93. package/dist/ui/Accordion/index.js +777 -0
  94. package/dist/ui/AddressCascader/index.d.ts +58 -0
  95. package/dist/ui/AddressCascader/index.d.ts.map +1 -0
  96. package/dist/ui/AddressCascader/index.js +710 -0
  97. package/dist/ui/BetweenTime/index.d.ts +82 -0
  98. package/dist/ui/BetweenTime/index.d.ts.map +1 -0
  99. package/dist/ui/BetweenTime/index.js +702 -0
  100. package/dist/ui/Button/index.d.ts +93 -0
  101. package/dist/ui/Button/index.d.ts.map +1 -0
  102. package/dist/ui/Button/index.js +832 -0
  103. package/dist/ui/Checkbox/index.d.ts +103 -0
  104. package/dist/ui/Checkbox/index.d.ts.map +1 -0
  105. package/dist/ui/Checkbox/index.js +694 -0
  106. package/dist/ui/DatePicker/index.d.ts +5 -0
  107. package/dist/ui/DatePicker/index.d.ts.map +1 -0
  108. package/dist/ui/DatePicker/index.js +157 -0
  109. package/dist/ui/DatePicker/types.d.ts +99 -0
  110. package/dist/ui/DatePicker/types.d.ts.map +1 -0
  111. package/dist/ui/DatePicker/types.js +2 -0
  112. package/dist/ui/DatePicker/utils.d.ts +32 -0
  113. package/dist/ui/DatePicker/utils.d.ts.map +1 -0
  114. package/dist/ui/DatePicker/utils.js +316 -0
  115. package/dist/ui/LinkedScroll/index.d.ts +78 -0
  116. package/dist/ui/LinkedScroll/index.d.ts.map +1 -0
  117. package/dist/ui/LinkedScroll/index.js +470 -0
  118. package/dist/ui/LoadingSpinner/index.d.ts +8 -0
  119. package/dist/ui/LoadingSpinner/index.d.ts.map +1 -0
  120. package/dist/ui/LoadingSpinner/index.js +122 -0
  121. package/dist/ui/Picker/actionBar.d.ts +14 -0
  122. package/dist/ui/Picker/actionBar.d.ts.map +1 -0
  123. package/dist/ui/Picker/actionBar.js +28 -0
  124. package/dist/ui/Picker/index.d.ts +5 -0
  125. package/dist/ui/Picker/index.d.ts.map +1 -0
  126. package/dist/ui/Picker/index.js +412 -0
  127. package/dist/ui/Picker/types.d.ts +80 -0
  128. package/dist/ui/Picker/types.d.ts.map +1 -0
  129. package/dist/ui/Picker/types.js +2 -0
  130. package/dist/ui/Picker/utils.d.ts +27 -0
  131. package/dist/ui/Picker/utils.d.ts.map +1 -0
  132. package/dist/ui/Picker/utils.js +182 -0
  133. package/dist/ui/Radio/index.d.ts +95 -0
  134. package/dist/ui/Radio/index.d.ts.map +1 -0
  135. package/dist/ui/Radio/index.js +633 -0
  136. package/dist/ui/Sheet/index.d.ts +12 -0
  137. package/dist/ui/Sheet/index.d.ts.map +1 -0
  138. package/dist/ui/Sheet/index.js +832 -0
  139. package/dist/ui/Sheet/nativeBottom.d.ts +52 -0
  140. package/dist/ui/Sheet/nativeBottom.d.ts.map +1 -0
  141. package/dist/ui/Sheet/nativeBottom.js +442 -0
  142. package/dist/ui/Sheet/nativeBottom.web.d.ts +18 -0
  143. package/dist/ui/Sheet/nativeBottom.web.d.ts.map +1 -0
  144. package/dist/ui/Sheet/nativeBottom.web.js +46 -0
  145. package/dist/ui/Sheet/slots.d.ts +5 -0
  146. package/dist/ui/Sheet/slots.d.ts.map +1 -0
  147. package/dist/ui/Sheet/slots.js +40 -0
  148. package/dist/ui/Sheet/types.d.ts +131 -0
  149. package/dist/ui/Sheet/types.d.ts.map +1 -0
  150. package/dist/ui/Sheet/types.js +2 -0
  151. package/dist/ui/SliderCaptcha/index.d.ts +57 -0
  152. package/dist/ui/SliderCaptcha/index.d.ts.map +1 -0
  153. package/dist/ui/SliderCaptcha/index.js +586 -0
  154. package/dist/ui/Switch/index.d.ts +72 -0
  155. package/dist/ui/Switch/index.d.ts.map +1 -0
  156. package/dist/ui/Switch/index.js +671 -0
  157. package/dist/ui/Text/index.d.ts +41 -0
  158. package/dist/ui/Text/index.d.ts.map +1 -0
  159. package/dist/ui/Text/index.js +325 -0
  160. package/dist/ui/TextInput/TextInputPrimitive.d.ts +8 -0
  161. package/dist/ui/TextInput/TextInputPrimitive.d.ts.map +1 -0
  162. package/dist/ui/TextInput/TextInputPrimitive.js +54 -0
  163. package/dist/ui/TextInput/index.d.ts +89 -0
  164. package/dist/ui/TextInput/index.d.ts.map +1 -0
  165. package/dist/ui/TextInput/index.js +545 -0
  166. package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.d.ts +39 -0
  167. package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.d.ts.map +1 -0
  168. package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.js +60 -0
  169. package/dist/ui/WheelColumn/constants.d.ts +2 -0
  170. package/dist/ui/WheelColumn/constants.d.ts.map +1 -0
  171. package/dist/ui/WheelColumn/constants.js +4 -0
  172. package/dist/ui/WheelColumn/index.d.ts +59 -0
  173. package/dist/ui/WheelColumn/index.d.ts.map +1 -0
  174. package/dist/ui/WheelColumn/index.js +547 -0
  175. package/ios/ZKitWheelPicker.h +18 -0
  176. package/ios/ZKitWheelPicker.mm +230 -0
  177. package/ios/ZKitWheelPickerLabel.h +10 -0
  178. package/ios/ZKitWheelPickerLabel.mm +31 -0
  179. package/ios/ZKitWheelPickerManager.h +5 -0
  180. package/ios/ZKitWheelPickerManager.mm +53 -0
  181. package/package.json +75 -0
  182. package/react-native.config.js +10 -0
  183. package/src/ComponentLibProvider.tsx +56 -0
  184. package/src/assets/animations/spinner.json +1 -0
  185. package/src/assets/icons/check.svg +4 -0
  186. package/src/assets/icons/toast/error.webp +0 -0
  187. package/src/assets/icons/toast/success.webp +0 -0
  188. package/src/assets/icons/toast/warning.webp +0 -0
  189. package/src/config.ts +65 -0
  190. package/src/i18n/I18nProvider.tsx +69 -0
  191. package/src/i18n/locale.ts +108 -0
  192. package/src/i18n/locales/de.ts +67 -0
  193. package/src/i18n/locales/en-US.ts +67 -0
  194. package/src/i18n/locales/index.ts +19 -0
  195. package/src/i18n/locales/ja.ts +67 -0
  196. package/src/i18n/locales/zh-CN.ts +67 -0
  197. package/src/i18n/locales/zh-TW.ts +67 -0
  198. package/src/i18n/types.ts +21 -0
  199. package/src/i18n/useI18n.ts +7 -0
  200. package/src/index.ts +395 -0
  201. package/src/services/ActionDialogService/ActionDialog.tsx +756 -0
  202. package/src/services/ActionDialogService/README.md +146 -0
  203. package/src/services/ActionDialogService/index.tsx +39 -0
  204. package/src/services/ActionDialogService/service.tsx +355 -0
  205. package/src/services/ActionDialogService/shared.ts +204 -0
  206. package/src/services/ActionDialogService/types.ts +197 -0
  207. package/src/services/CardToastService/README.md +128 -0
  208. package/src/services/CardToastService/index.tsx +1284 -0
  209. package/src/services/ImagePreviewService/README.md +67 -0
  210. package/src/services/ImagePreviewService/index.tsx +2148 -0
  211. package/src/services/LoadingService/README.md +128 -0
  212. package/src/services/LoadingService/index.tsx +1113 -0
  213. package/src/services/PermissionPurposeDialogService/README.md +80 -0
  214. package/src/services/PermissionPurposeDialogService/index.tsx +449 -0
  215. package/src/services/PickerService/README.md +154 -0
  216. package/src/services/PickerService/index.tsx +410 -0
  217. package/src/theme/ThemeProvider.tsx +40 -0
  218. package/src/theme/defaultTheme.ts +30 -0
  219. package/src/theme/mergeTheme.ts +16 -0
  220. package/src/theme/types.ts +36 -0
  221. package/src/theme/useTheme.ts +10 -0
  222. package/src/types/svg.d.ts +9 -0
  223. package/src/types/vant-area-data.d.ts +19 -0
  224. package/src/ui/Accordion/README.md +67 -0
  225. package/src/ui/Accordion/index.tsx +1221 -0
  226. package/src/ui/AddressCascader/README.md +144 -0
  227. package/src/ui/AddressCascader/index.tsx +1084 -0
  228. package/src/ui/BetweenTime/README.md +490 -0
  229. package/src/ui/BetweenTime/index.tsx +1001 -0
  230. package/src/ui/Button/README.md +186 -0
  231. package/src/ui/Button/index.tsx +1356 -0
  232. package/src/ui/Checkbox/README.md +211 -0
  233. package/src/ui/Checkbox/index.tsx +1231 -0
  234. package/src/ui/DatePicker/README.md +117 -0
  235. package/src/ui/DatePicker/index.tsx +295 -0
  236. package/src/ui/DatePicker/types.ts +115 -0
  237. package/src/ui/DatePicker/utils.ts +405 -0
  238. package/src/ui/LinkedScroll/README.md +55 -0
  239. package/src/ui/LinkedScroll/index.tsx +809 -0
  240. package/src/ui/LoadingSpinner/index.tsx +104 -0
  241. package/src/ui/Picker/README.md +190 -0
  242. package/src/ui/Picker/actionBar.tsx +70 -0
  243. package/src/ui/Picker/index.tsx +694 -0
  244. package/src/ui/Picker/types.ts +94 -0
  245. package/src/ui/Picker/utils.ts +239 -0
  246. package/src/ui/Radio/README.md +207 -0
  247. package/src/ui/Radio/index.tsx +1117 -0
  248. package/src/ui/Sheet/README.md +82 -0
  249. package/src/ui/Sheet/index.tsx +1163 -0
  250. package/src/ui/Sheet/nativeBottom.tsx +683 -0
  251. package/src/ui/Sheet/nativeBottom.web.tsx +40 -0
  252. package/src/ui/Sheet/slots.tsx +75 -0
  253. package/src/ui/Sheet/types.ts +195 -0
  254. package/src/ui/SliderCaptcha/README.md +61 -0
  255. package/src/ui/SliderCaptcha/index.tsx +816 -0
  256. package/src/ui/Switch/README.md +143 -0
  257. package/src/ui/Switch/index.tsx +1092 -0
  258. package/src/ui/Text/README.md +157 -0
  259. package/src/ui/Text/index.tsx +450 -0
  260. package/src/ui/TextInput/README.md +197 -0
  261. package/src/ui/TextInput/TextInputPrimitive.tsx +44 -0
  262. package/src/ui/TextInput/index.tsx +942 -0
  263. package/src/ui/WheelColumn/README.md +104 -0
  264. package/src/ui/WheelColumn/ZKitWheelPickerNativeComponent.tsx +68 -0
  265. package/src/ui/WheelColumn/constants.ts +1 -0
  266. package/src/ui/WheelColumn/index.tsx +826 -0
  267. package/zkit-ui.podspec +19 -0
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.actionDialog = void 0;
37
+ exports.ActionDialogProvider = ActionDialogProvider;
38
+ const jsx_runtime_1 = require("react/jsx-runtime");
39
+ const React = __importStar(require("react"));
40
+ const ActionDialog_1 = require("./ActionDialog");
41
+ const shared_1 = require("./shared");
42
+ const initialState = {
43
+ activeRequest: null,
44
+ queuedRequests: [],
45
+ open: false,
46
+ };
47
+ class ActionDialogServiceClass {
48
+ constructor() {
49
+ this.controller = null;
50
+ this.sequence = 0;
51
+ }
52
+ _bind(controller) {
53
+ this.controller = controller;
54
+ }
55
+ open(options = {}) {
56
+ const id = `action_dialog_${Date.now()}_${++this.sequence}`;
57
+ let resolveResult = () => { };
58
+ const result = new Promise((resolve) => {
59
+ resolveResult = resolve;
60
+ });
61
+ const request = {
62
+ ...options,
63
+ id,
64
+ resolve: resolveResult,
65
+ settled: false,
66
+ };
67
+ const handle = {
68
+ id,
69
+ result,
70
+ close: () => { var _a; return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.close(id, 'api'); },
71
+ update: (patch) => { var _a; return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.update(id, patch); },
72
+ };
73
+ if (!this.controller) {
74
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
75
+ console.warn('[actionDialog] ActionDialogProvider is not mounted.');
76
+ }
77
+ this.settle(request, { type: 'dismiss', reason: 'unmount' });
78
+ return handle;
79
+ }
80
+ this.controller.open(request);
81
+ return handle;
82
+ }
83
+ async confirm({ cancelAction, cancelLabel, confirmAction, confirmLabel, footer, tone = 'default', ...restOptions } = {}) {
84
+ const handle = this.open({
85
+ ...restOptions,
86
+ footer: { layout: footer === null || footer === void 0 ? void 0 : footer.layout },
87
+ actions: [
88
+ (0, shared_1.createSemanticAction)(cancelAction, cancelLabel, 'cancel', 'cancel', 'neutral'),
89
+ (0, shared_1.createSemanticAction)(confirmAction, confirmLabel, 'confirm', 'confirm', tone === 'danger' ? 'danger' : 'primary'),
90
+ ],
91
+ });
92
+ const result = await handle.result;
93
+ return result.type === 'action' && result.action.role === 'confirm';
94
+ }
95
+ async alert({ confirmAction, confirmLabel, footer, tone = 'default', ...restOptions } = {}) {
96
+ const handle = this.open({
97
+ ...restOptions,
98
+ footer: { layout: footer === null || footer === void 0 ? void 0 : footer.layout },
99
+ actions: [
100
+ (0, shared_1.createSemanticAction)(confirmAction, confirmLabel, 'confirm', 'confirm', tone === 'danger' ? 'danger' : 'primary'),
101
+ ],
102
+ });
103
+ await handle.result;
104
+ }
105
+ close() {
106
+ var _a;
107
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.close(undefined, 'api');
108
+ }
109
+ closeByScope(scopeKey) {
110
+ var _a;
111
+ if (!scopeKey)
112
+ return;
113
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.closeByScope(scopeKey, 'api');
114
+ }
115
+ closeAll() {
116
+ var _a;
117
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.closeAll('api');
118
+ }
119
+ getSnapshot() {
120
+ var _a, _b;
121
+ return ((_b = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.getSnapshot()) !== null && _b !== void 0 ? _b : {
122
+ activeId: null,
123
+ open: false,
124
+ queuedCount: 0,
125
+ });
126
+ }
127
+ _settle(request, result) {
128
+ this.settle(request, result);
129
+ }
130
+ settle(request, result) {
131
+ var _a;
132
+ if (request.settled)
133
+ return;
134
+ request.settled = true;
135
+ (_a = request.onClose) === null || _a === void 0 ? void 0 : _a.call(request, result);
136
+ request.resolve(result);
137
+ }
138
+ }
139
+ const actionDialogService = new ActionDialogServiceClass();
140
+ exports.actionDialog = actionDialogService;
141
+ function settleRequest(request, result) {
142
+ if (!request)
143
+ return;
144
+ actionDialogService._settle(request, result);
145
+ }
146
+ function ActionDialogProvider({ children }) {
147
+ var _a;
148
+ const [state, setState] = React.useState(initialState);
149
+ const stateRef = React.useRef(state);
150
+ stateRef.current = state;
151
+ const showNextRequest = React.useCallback(() => {
152
+ setState((prev) => {
153
+ const [nextRequest, ...restQueue] = prev.queuedRequests;
154
+ if (!nextRequest) {
155
+ return {
156
+ activeRequest: null,
157
+ queuedRequests: [],
158
+ open: false,
159
+ };
160
+ }
161
+ return {
162
+ activeRequest: nextRequest,
163
+ queuedRequests: restQueue,
164
+ open: true,
165
+ };
166
+ });
167
+ }, []);
168
+ const controller = React.useMemo(() => ({
169
+ open: (request) => {
170
+ setState((prev) => {
171
+ if (request.collisionStrategy === 'queue' && prev.activeRequest) {
172
+ return {
173
+ ...prev,
174
+ queuedRequests: [...prev.queuedRequests, request],
175
+ };
176
+ }
177
+ settleRequest(prev.activeRequest, { type: 'dismiss', reason: 'replace' });
178
+ for (const queuedRequest of prev.queuedRequests) {
179
+ settleRequest(queuedRequest, { type: 'dismiss', reason: 'replace' });
180
+ }
181
+ return {
182
+ activeRequest: request,
183
+ queuedRequests: [],
184
+ open: true,
185
+ };
186
+ });
187
+ },
188
+ close: (id, reason) => {
189
+ setState((prev) => {
190
+ var _a;
191
+ if (id && ((_a = prev.activeRequest) === null || _a === void 0 ? void 0 : _a.id) !== id) {
192
+ let changed = false;
193
+ const nextQueue = prev.queuedRequests.filter((request) => {
194
+ if (request.id !== id)
195
+ return true;
196
+ changed = true;
197
+ settleRequest(request, { type: 'dismiss', reason });
198
+ return false;
199
+ });
200
+ return changed ? { ...prev, queuedRequests: nextQueue } : prev;
201
+ }
202
+ if (!prev.activeRequest)
203
+ return prev;
204
+ settleRequest(prev.activeRequest, { type: 'dismiss', reason });
205
+ return { ...prev, open: false };
206
+ });
207
+ },
208
+ closeByScope: (scopeKey, reason) => {
209
+ setState((prev) => {
210
+ var _a;
211
+ let changed = false;
212
+ const nextQueue = prev.queuedRequests.filter((request) => {
213
+ if (request.scopeKey !== scopeKey)
214
+ return true;
215
+ changed = true;
216
+ settleRequest(request, { type: 'dismiss', reason });
217
+ return false;
218
+ });
219
+ if (((_a = prev.activeRequest) === null || _a === void 0 ? void 0 : _a.scopeKey) === scopeKey) {
220
+ settleRequest(prev.activeRequest, { type: 'dismiss', reason });
221
+ return { ...prev, queuedRequests: nextQueue, open: false };
222
+ }
223
+ return changed ? { ...prev, queuedRequests: nextQueue } : prev;
224
+ });
225
+ },
226
+ closeAll: (reason) => {
227
+ setState((prev) => {
228
+ settleRequest(prev.activeRequest, { type: 'dismiss', reason });
229
+ for (const queuedRequest of prev.queuedRequests) {
230
+ settleRequest(queuedRequest, { type: 'dismiss', reason });
231
+ }
232
+ return {
233
+ activeRequest: prev.activeRequest,
234
+ queuedRequests: [],
235
+ open: prev.activeRequest ? false : prev.open,
236
+ };
237
+ });
238
+ },
239
+ update: (id, patch) => {
240
+ setState((prev) => {
241
+ var _a;
242
+ if (((_a = prev.activeRequest) === null || _a === void 0 ? void 0 : _a.id) === id) {
243
+ return {
244
+ ...prev,
245
+ activeRequest: {
246
+ ...(0, shared_1.mergeOpenOptions)(prev.activeRequest, patch),
247
+ id,
248
+ resolve: prev.activeRequest.resolve,
249
+ settled: prev.activeRequest.settled,
250
+ },
251
+ };
252
+ }
253
+ let changed = false;
254
+ const queuedRequests = prev.queuedRequests.map((request) => {
255
+ if (request.id !== id)
256
+ return request;
257
+ changed = true;
258
+ return {
259
+ ...(0, shared_1.mergeOpenOptions)(request, patch),
260
+ id,
261
+ resolve: request.resolve,
262
+ settled: request.settled,
263
+ };
264
+ });
265
+ return changed ? { ...prev, queuedRequests } : prev;
266
+ });
267
+ },
268
+ getSnapshot: () => {
269
+ var _a, _b;
270
+ return ({
271
+ activeId: (_b = (_a = stateRef.current.activeRequest) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
272
+ open: stateRef.current.open,
273
+ queuedCount: stateRef.current.queuedRequests.length,
274
+ });
275
+ },
276
+ }), []);
277
+ React.useEffect(() => {
278
+ actionDialogService._bind(controller);
279
+ return () => {
280
+ const currentState = stateRef.current;
281
+ settleRequest(currentState.activeRequest, { type: 'dismiss', reason: 'unmount' });
282
+ for (const queuedRequest of currentState.queuedRequests) {
283
+ settleRequest(queuedRequest, { type: 'dismiss', reason: 'unmount' });
284
+ }
285
+ actionDialogService._bind(null);
286
+ };
287
+ }, [controller]);
288
+ const handleClose = React.useCallback((result) => {
289
+ setState((prev) => {
290
+ if (!prev.activeRequest)
291
+ return prev;
292
+ settleRequest(prev.activeRequest, result);
293
+ return { ...prev, open: false };
294
+ });
295
+ }, []);
296
+ const activeRequest = state.activeRequest;
297
+ const activeDialogProps = React.useMemo(() => {
298
+ if (!activeRequest)
299
+ return {};
300
+ const { collisionStrategy, id, resolve, scopeKey, settled, ...props } = activeRequest;
301
+ void collisionStrategy;
302
+ void id;
303
+ void resolve;
304
+ void scopeKey;
305
+ void settled;
306
+ return props;
307
+ }, [activeRequest]);
308
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children, (0, jsx_runtime_1.jsx)(ActionDialog_1.ActionDialog, { ...activeDialogProps, hostMode: (_a = activeRequest === null || activeRequest === void 0 ? void 0 : activeRequest.hostMode) !== null && _a !== void 0 ? _a : 'inline', open: Boolean(activeRequest && state.open), onClose: handleClose, onDismissComplete: showNextRequest })] }));
309
+ }
@@ -0,0 +1,17 @@
1
+ import type * as React from 'react';
2
+ import type { ActionDialogAction, ActionDialogActionRole, ActionDialogActionTone, ActionDialogColors, ActionDialogDismissOptions, ActionDialogFooterLayout, ActionDialogKeyboardOptions, ActionDialogLabels, ActionDialogLayoutOptions, ActionDialogOpenOptions, ActionDialogResolvedAction, ActionDialogResolvedFooterLayout, ActionDialogResult, ActionDialogSemanticActionOptions } from './types';
3
+ export declare const ACTION_DIALOG_DEFAULT_Z_INDEX = 4200;
4
+ export declare const ACTION_DIALOG_DEFAULT_LAYOUT: Required<ActionDialogLayoutOptions>;
5
+ export declare const ACTION_DIALOG_DEFAULT_DISMISS: Required<ActionDialogDismissOptions>;
6
+ export declare const ACTION_DIALOG_DEFAULT_KEYBOARD: Required<ActionDialogKeyboardOptions>;
7
+ export declare const ACTION_DIALOG_DEFAULT_COLORS: Required<ActionDialogColors>;
8
+ export declare function isFiniteNumber(value: unknown): value is number;
9
+ export declare function resolveLayout(layout: ActionDialogLayoutOptions | undefined): Required<ActionDialogLayoutOptions>;
10
+ export declare function resolveDismissOptions(dismissible: boolean, dismiss: ActionDialogDismissOptions | undefined): Required<ActionDialogDismissOptions>;
11
+ export declare function resolveKeyboardOptions(keyboard: ActionDialogKeyboardOptions | undefined): Required<ActionDialogKeyboardOptions>;
12
+ export declare function resolveFooterLayout(layout: ActionDialogFooterLayout | undefined, actions: readonly Pick<ActionDialogResolvedAction, 'label'>[]): ActionDialogResolvedFooterLayout;
13
+ export declare function resolveActions(actions: readonly ActionDialogAction[] | undefined, labels: ActionDialogLabels): ActionDialogResolvedAction[];
14
+ export declare function createActionResult(action: ActionDialogResolvedAction): ActionDialogResult;
15
+ export declare function mergeOpenOptions(base: ActionDialogOpenOptions, patch: Partial<ActionDialogOpenOptions>): ActionDialogOpenOptions;
16
+ export declare function createSemanticAction(input: ActionDialogSemanticActionOptions | undefined, fallbackLabel: React.ReactNode | undefined, key: string, role: ActionDialogActionRole, tone: ActionDialogActionTone): ActionDialogAction;
17
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/services/ActionDialogService/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EAEtB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,gCAAgC,EAChC,kBAAkB,EAClB,iCAAiC,EAClC,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,yBAAyB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,EAAE,sBAAsB,EAC5B,IAAI,EAAE,sBAAsB,GAC3B,kBAAkB,CAcpB"}
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ACTION_DIALOG_DEFAULT_COLORS = exports.ACTION_DIALOG_DEFAULT_KEYBOARD = exports.ACTION_DIALOG_DEFAULT_DISMISS = exports.ACTION_DIALOG_DEFAULT_LAYOUT = exports.ACTION_DIALOG_DEFAULT_Z_INDEX = void 0;
4
+ exports.isFiniteNumber = isFiniteNumber;
5
+ exports.resolveLayout = resolveLayout;
6
+ exports.resolveDismissOptions = resolveDismissOptions;
7
+ exports.resolveKeyboardOptions = resolveKeyboardOptions;
8
+ exports.resolveFooterLayout = resolveFooterLayout;
9
+ exports.resolveActions = resolveActions;
10
+ exports.createActionResult = createActionResult;
11
+ exports.mergeOpenOptions = mergeOpenOptions;
12
+ exports.createSemanticAction = createSemanticAction;
13
+ exports.ACTION_DIALOG_DEFAULT_Z_INDEX = 4200;
14
+ exports.ACTION_DIALOG_DEFAULT_LAYOUT = {
15
+ width: 320,
16
+ maxWidth: 380,
17
+ contentPadding: 20,
18
+ radius: 20,
19
+ };
20
+ exports.ACTION_DIALOG_DEFAULT_DISMISS = {
21
+ overlayPress: false,
22
+ backPress: true,
23
+ };
24
+ exports.ACTION_DIALOG_DEFAULT_KEYBOARD = {
25
+ avoid: true,
26
+ dismissOnOverlayPress: true,
27
+ dismissOnClose: true,
28
+ };
29
+ exports.ACTION_DIALOG_DEFAULT_COLORS = {
30
+ backdrop: 'rgba(17, 24, 39, 0.48)',
31
+ surface: '',
32
+ title: '',
33
+ message: '',
34
+ border: '',
35
+ };
36
+ const AUTO_ROW_MAX_ACTIONS = 3;
37
+ const AUTO_ROW_MAX_LABEL_WEIGHT = 8;
38
+ function isFiniteNumber(value) {
39
+ return typeof value === 'number' && Number.isFinite(value);
40
+ }
41
+ function positiveNumber(value, fallback) {
42
+ return isFiniteNumber(value) && value > 0 ? value : fallback;
43
+ }
44
+ function resolveLayout(layout) {
45
+ return {
46
+ width: positiveNumber(layout === null || layout === void 0 ? void 0 : layout.width, exports.ACTION_DIALOG_DEFAULT_LAYOUT.width),
47
+ maxWidth: positiveNumber(layout === null || layout === void 0 ? void 0 : layout.maxWidth, exports.ACTION_DIALOG_DEFAULT_LAYOUT.maxWidth),
48
+ contentPadding: positiveNumber(layout === null || layout === void 0 ? void 0 : layout.contentPadding, exports.ACTION_DIALOG_DEFAULT_LAYOUT.contentPadding),
49
+ radius: positiveNumber(layout === null || layout === void 0 ? void 0 : layout.radius, exports.ACTION_DIALOG_DEFAULT_LAYOUT.radius),
50
+ };
51
+ }
52
+ function resolveDismissOptions(dismissible, dismiss) {
53
+ var _a, _b;
54
+ return {
55
+ overlayPress: dismissible && ((_a = dismiss === null || dismiss === void 0 ? void 0 : dismiss.overlayPress) !== null && _a !== void 0 ? _a : exports.ACTION_DIALOG_DEFAULT_DISMISS.overlayPress),
56
+ backPress: dismissible && ((_b = dismiss === null || dismiss === void 0 ? void 0 : dismiss.backPress) !== null && _b !== void 0 ? _b : exports.ACTION_DIALOG_DEFAULT_DISMISS.backPress),
57
+ };
58
+ }
59
+ function resolveKeyboardOptions(keyboard) {
60
+ var _a, _b, _c;
61
+ return {
62
+ avoid: (_a = keyboard === null || keyboard === void 0 ? void 0 : keyboard.avoid) !== null && _a !== void 0 ? _a : exports.ACTION_DIALOG_DEFAULT_KEYBOARD.avoid,
63
+ dismissOnOverlayPress: (_b = keyboard === null || keyboard === void 0 ? void 0 : keyboard.dismissOnOverlayPress) !== null && _b !== void 0 ? _b : exports.ACTION_DIALOG_DEFAULT_KEYBOARD.dismissOnOverlayPress,
64
+ dismissOnClose: (_c = keyboard === null || keyboard === void 0 ? void 0 : keyboard.dismissOnClose) !== null && _c !== void 0 ? _c : exports.ACTION_DIALOG_DEFAULT_KEYBOARD.dismissOnClose,
65
+ };
66
+ }
67
+ function resolveFooterLayout(layout, actions) {
68
+ if (layout === 'bar' || layout === 'row' || layout === 'stack')
69
+ return layout;
70
+ if (actions.length <= 2)
71
+ return 'row';
72
+ if (actions.length > AUTO_ROW_MAX_ACTIONS)
73
+ return 'stack';
74
+ return actions.every((action) => {
75
+ const weight = getPrimitiveLabelWeight(action.label);
76
+ return weight != null && weight <= AUTO_ROW_MAX_LABEL_WEIGHT;
77
+ })
78
+ ? 'row'
79
+ : 'stack';
80
+ }
81
+ function defaultToneForRole(role) {
82
+ if (role === 'confirm')
83
+ return 'primary';
84
+ return 'neutral';
85
+ }
86
+ function getPrimitiveLabelWeight(label) {
87
+ const text = typeof label === 'string' || typeof label === 'number' ? String(label).trim() : '';
88
+ if (!text)
89
+ return null;
90
+ return Array.from(text).reduce((total, char) => {
91
+ var _a;
92
+ const code = (_a = char.codePointAt(0)) !== null && _a !== void 0 ? _a : 0;
93
+ return total + (code > 0xff ? 2 : 1);
94
+ }, 0);
95
+ }
96
+ function defaultVariantForTone(tone) {
97
+ return tone === 'neutral' ? 'soft' : 'solid';
98
+ }
99
+ function fallbackLabel(role, key, labels) {
100
+ if (role === 'confirm')
101
+ return labels.confirm;
102
+ if (role === 'cancel')
103
+ return labels.cancel;
104
+ return key;
105
+ }
106
+ function resolveActions(actions, labels) {
107
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length))
108
+ return [];
109
+ return actions.map((action, index) => {
110
+ var _a, _b, _c, _d, _e, _f;
111
+ const role = (_a = action.role) !== null && _a !== void 0 ? _a : 'neutral';
112
+ const key = (_b = action.key) !== null && _b !== void 0 ? _b : `${role}-${index}`;
113
+ const tone = (_c = action.tone) !== null && _c !== void 0 ? _c : defaultToneForRole(role);
114
+ const variant = (_d = action.variant) !== null && _d !== void 0 ? _d : defaultVariantForTone(tone);
115
+ return {
116
+ key,
117
+ role,
118
+ label: (_e = action.label) !== null && _e !== void 0 ? _e : fallbackLabel(role, key, labels),
119
+ tone,
120
+ variant,
121
+ closeOnPress: (_f = action.closeOnPress) !== null && _f !== void 0 ? _f : true,
122
+ disabled: Boolean(action.disabled),
123
+ loading: Boolean(action.loading),
124
+ accessibilityLabel: action.accessibilityLabel,
125
+ testID: action.testID,
126
+ onPress: action.onPress,
127
+ };
128
+ });
129
+ }
130
+ function createActionResult(action) {
131
+ return {
132
+ type: 'action',
133
+ action: {
134
+ key: action.key,
135
+ role: action.role,
136
+ },
137
+ };
138
+ }
139
+ function mergeOpenOptions(base, patch) {
140
+ return {
141
+ ...base,
142
+ ...patch,
143
+ colors: { ...base.colors, ...patch.colors },
144
+ dismiss: { ...base.dismiss, ...patch.dismiss },
145
+ footer: { ...base.footer, ...patch.footer },
146
+ keyboard: { ...base.keyboard, ...patch.keyboard },
147
+ labels: { ...base.labels, ...patch.labels },
148
+ layer: { ...base.layer, ...patch.layer },
149
+ layout: { ...base.layout, ...patch.layout },
150
+ };
151
+ }
152
+ function createSemanticAction(input, fallbackLabel, key, role, tone) {
153
+ var _a, _b, _c, _d;
154
+ return {
155
+ key: (_a = input === null || input === void 0 ? void 0 : input.key) !== null && _a !== void 0 ? _a : key,
156
+ role,
157
+ label: (_b = input === null || input === void 0 ? void 0 : input.label) !== null && _b !== void 0 ? _b : fallbackLabel,
158
+ tone: (_c = input === null || input === void 0 ? void 0 : input.tone) !== null && _c !== void 0 ? _c : tone,
159
+ variant: input === null || input === void 0 ? void 0 : input.variant,
160
+ closeOnPress: (_d = input === null || input === void 0 ? void 0 : input.closeOnPress) !== null && _d !== void 0 ? _d : true,
161
+ disabled: input === null || input === void 0 ? void 0 : input.disabled,
162
+ loading: input === null || input === void 0 ? void 0 : input.loading,
163
+ accessibilityLabel: input === null || input === void 0 ? void 0 : input.accessibilityLabel,
164
+ testID: input === null || input === void 0 ? void 0 : input.testID,
165
+ onPress: input === null || input === void 0 ? void 0 : input.onPress,
166
+ };
167
+ }
@@ -0,0 +1,160 @@
1
+ import type * as React from 'react';
2
+ import type { ModalProps, StyleProp, ViewProps, ViewStyle } from 'react-native';
3
+ export type ActionDialogActionRole = 'confirm' | 'cancel' | 'neutral';
4
+ export type ActionDialogActionTone = 'primary' | 'neutral' | 'danger';
5
+ export type ActionDialogActionVariant = 'solid' | 'soft' | 'outline' | 'ghost';
6
+ export type ActionDialogFooterLayout = 'auto' | 'row' | 'stack' | 'bar';
7
+ export type ActionDialogResolvedFooterLayout = Exclude<ActionDialogFooterLayout, 'auto'>;
8
+ export type ActionDialogDismissReason = 'api' | 'back' | 'overlay' | 'replace' | 'unmount';
9
+ export type ActionDialogOpenChangeReason = 'action' | ActionDialogDismissReason;
10
+ export type ActionDialogCollisionStrategy = 'replace' | 'queue';
11
+ export type ActionDialogHostMode = 'modal' | 'inline';
12
+ export type ActionDialogMotion = 'none' | 'fade' | 'scale';
13
+ export type ActionDialogActionResult = {
14
+ type: 'action';
15
+ action: {
16
+ key: string;
17
+ role: ActionDialogActionRole;
18
+ };
19
+ };
20
+ export type ActionDialogDismissResult = {
21
+ type: 'dismiss';
22
+ reason: ActionDialogDismissReason;
23
+ };
24
+ export type ActionDialogResult = ActionDialogActionResult | ActionDialogDismissResult;
25
+ export type ActionDialogActionContext = {
26
+ action: ActionDialogResolvedAction;
27
+ close: () => void;
28
+ dismiss: (reason?: Extract<ActionDialogDismissReason, 'api'>) => void;
29
+ };
30
+ export type ActionDialogActionPressResult = void | false;
31
+ export type ActionDialogAction = {
32
+ key?: string;
33
+ role?: ActionDialogActionRole;
34
+ label?: React.ReactNode;
35
+ tone?: ActionDialogActionTone;
36
+ variant?: ActionDialogActionVariant;
37
+ closeOnPress?: boolean;
38
+ disabled?: boolean;
39
+ loading?: boolean;
40
+ accessibilityLabel?: string;
41
+ testID?: ViewProps['testID'];
42
+ onPress?: (context: ActionDialogActionContext) => ActionDialogActionPressResult;
43
+ };
44
+ export type ActionDialogResolvedAction = Required<Pick<ActionDialogAction, 'closeOnPress' | 'disabled' | 'key' | 'loading' | 'role' | 'tone' | 'variant'>> & Pick<ActionDialogAction, 'accessibilityLabel' | 'label' | 'onPress' | 'testID'>;
45
+ export type ActionDialogFooterRenderContext = {
46
+ actions: ActionDialogResolvedAction[];
47
+ layout: ActionDialogResolvedFooterLayout;
48
+ close: () => void;
49
+ pressAction: (key: string) => void;
50
+ };
51
+ export type ActionDialogFooterOptions = {
52
+ layout?: ActionDialogFooterLayout;
53
+ render?: (context: ActionDialogFooterRenderContext) => React.ReactNode;
54
+ };
55
+ export type ActionDialogDismissOptions = {
56
+ overlayPress?: boolean;
57
+ backPress?: boolean;
58
+ };
59
+ export type ActionDialogKeyboardOptions = {
60
+ avoid?: boolean;
61
+ dismissOnOverlayPress?: boolean;
62
+ dismissOnClose?: boolean;
63
+ };
64
+ export type ActionDialogLayoutOptions = {
65
+ width?: number;
66
+ maxWidth?: number;
67
+ contentPadding?: number;
68
+ radius?: number;
69
+ };
70
+ export type ActionDialogLayerOptions = {
71
+ zIndex?: number;
72
+ };
73
+ export type ActionDialogColors = {
74
+ backdrop?: string;
75
+ surface?: string;
76
+ title?: string;
77
+ message?: string;
78
+ border?: string;
79
+ };
80
+ export type ActionDialogLabels = {
81
+ confirm: string;
82
+ cancel: string;
83
+ close: string;
84
+ };
85
+ export type ActionDialogOpenChangeMeta = {
86
+ reason: ActionDialogOpenChangeReason;
87
+ result?: ActionDialogResult;
88
+ };
89
+ export type ActionDialogRef = {
90
+ close: (reason?: Extract<ActionDialogDismissReason, 'api'>) => void;
91
+ pressAction: (key: string) => void;
92
+ getOpen: () => boolean;
93
+ };
94
+ export type ActionDialogProps = {
95
+ open?: boolean;
96
+ defaultOpen?: boolean;
97
+ onOpenChange?: (open: boolean, meta: ActionDialogOpenChangeMeta) => void;
98
+ onClose?: (result: ActionDialogResult) => void;
99
+ onDismissComplete?: () => void;
100
+ onActionError?: (error: unknown, action: ActionDialogResolvedAction) => void;
101
+ title?: React.ReactNode;
102
+ message?: React.ReactNode;
103
+ children?: React.ReactNode;
104
+ actions?: readonly ActionDialogAction[];
105
+ footer?: ActionDialogFooterOptions;
106
+ disabled?: boolean;
107
+ dismissible?: boolean;
108
+ dismiss?: ActionDialogDismissOptions;
109
+ hostMode?: ActionDialogHostMode;
110
+ keyboard?: ActionDialogKeyboardOptions;
111
+ layout?: ActionDialogLayoutOptions;
112
+ layer?: ActionDialogLayerOptions;
113
+ colors?: Partial<ActionDialogColors>;
114
+ labels?: Partial<ActionDialogLabels>;
115
+ motion?: ActionDialogMotion;
116
+ modalProps?: Omit<ModalProps, 'children' | 'onRequestClose' | 'presentationStyle' | 'statusBarTranslucent' | 'transparent' | 'visible'>;
117
+ style?: StyleProp<ViewStyle>;
118
+ testID?: ViewProps['testID'];
119
+ accessibilityLabel?: ViewProps['accessibilityLabel'];
120
+ };
121
+ export type ActionDialogSemanticActionOptions = Omit<Partial<ActionDialogAction>, 'role'>;
122
+ export type ActionDialogOpenOptions = Omit<ActionDialogProps, 'defaultOpen' | 'modalProps' | 'onDismissComplete' | 'onOpenChange' | 'open'> & {
123
+ scopeKey?: string;
124
+ collisionStrategy?: ActionDialogCollisionStrategy;
125
+ };
126
+ export type ActionDialogConfirmOptions = Omit<ActionDialogOpenOptions, 'actions' | 'footer'> & {
127
+ confirmLabel?: React.ReactNode;
128
+ cancelLabel?: React.ReactNode;
129
+ confirmAction?: ActionDialogSemanticActionOptions;
130
+ cancelAction?: ActionDialogSemanticActionOptions;
131
+ tone?: 'default' | 'danger';
132
+ footer?: Pick<ActionDialogFooterOptions, 'layout'>;
133
+ };
134
+ export type ActionDialogAlertOptions = Omit<ActionDialogOpenOptions, 'actions' | 'footer'> & {
135
+ confirmLabel?: React.ReactNode;
136
+ confirmAction?: ActionDialogSemanticActionOptions;
137
+ tone?: 'default' | 'danger';
138
+ footer?: Pick<ActionDialogFooterOptions, 'layout'>;
139
+ };
140
+ export type ActionDialogHandle = {
141
+ id: string;
142
+ result: Promise<ActionDialogResult>;
143
+ close: (reason?: Extract<ActionDialogDismissReason, 'api'>) => void;
144
+ update: (patch: Partial<ActionDialogOpenOptions>) => void;
145
+ };
146
+ export type ActionDialogSnapshot = {
147
+ open: boolean;
148
+ activeId: string | null;
149
+ queuedCount: number;
150
+ };
151
+ export type ActionDialogService = {
152
+ open: (options?: ActionDialogOpenOptions) => ActionDialogHandle;
153
+ confirm: (options?: ActionDialogConfirmOptions) => Promise<boolean>;
154
+ alert: (options?: ActionDialogAlertOptions) => Promise<void>;
155
+ close: (reason?: Extract<ActionDialogDismissReason, 'api'>) => void;
156
+ closeByScope: (scopeKey: string) => void;
157
+ closeAll: (reason?: Extract<ActionDialogDismissReason, 'api'>) => void;
158
+ getSnapshot: () => ActionDialogSnapshot;
159
+ };
160
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/ActionDialogService/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhF,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AACtE,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAC/E,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC;AACxE,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACzF,MAAM,MAAM,yBAAyB,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC3F,MAAM,MAAM,4BAA4B,GAAG,QAAQ,GAAG,yBAAyB,CAAC;AAChF,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,OAAO,CAAC;AAChE,MAAM,MAAM,oBAAoB,GAAG,OAAO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