zkit-ui 1.0.5 → 2.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 (55) hide show
  1. package/README.md +28 -14
  2. package/dist/ZKitCoreProvider.d.ts +13 -0
  3. package/dist/ZKitCoreProvider.d.ts.map +1 -0
  4. package/dist/ZKitCoreProvider.js +10 -0
  5. package/dist/ZKitProvider.d.ts +7 -0
  6. package/dist/ZKitProvider.d.ts.map +1 -0
  7. package/dist/ZKitProvider.js +17 -0
  8. package/dist/all.d.ts +59 -0
  9. package/dist/all.d.ts.map +1 -0
  10. package/dist/all.js +92 -0
  11. package/dist/config.d.ts +6 -6
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +15 -15
  14. package/dist/index.d.ts +4 -48
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +4 -74
  17. package/dist/services/PermissionPurposeDialogService/index.d.ts +2 -2
  18. package/dist/services/PermissionPurposeDialogService/index.js +2 -2
  19. package/dist/services/PickerService/index.d.ts +2 -2
  20. package/dist/services/PickerService/index.js +2 -2
  21. package/dist/theme/ThemeProvider.js +1 -1
  22. package/package.json +164 -2
  23. package/src/ZKitCoreProvider.tsx +34 -0
  24. package/src/ZKitProvider.tsx +48 -0
  25. package/src/all.ts +397 -0
  26. package/src/config.ts +18 -18
  27. package/src/index.ts +7 -376
  28. package/src/services/ActionDialogService/README.md +4 -3
  29. package/src/services/CardToastService/README.md +3 -3
  30. package/src/services/ImagePreviewService/README.md +3 -3
  31. package/src/services/LoadingService/README.md +5 -5
  32. package/src/services/PermissionPurposeDialogService/README.md +5 -5
  33. package/src/services/PermissionPurposeDialogService/index.tsx +2 -2
  34. package/src/services/PickerService/README.md +5 -5
  35. package/src/services/PickerService/index.tsx +2 -2
  36. package/src/theme/ThemeProvider.tsx +1 -1
  37. package/src/ui/Accordion/README.md +2 -2
  38. package/src/ui/AddressCascader/README.md +4 -2
  39. package/src/ui/BetweenTime/README.md +12 -12
  40. package/src/ui/Button/README.md +7 -7
  41. package/src/ui/Checkbox/README.md +2 -2
  42. package/src/ui/DatePicker/README.md +2 -1
  43. package/src/ui/LinkedScroll/README.md +2 -1
  44. package/src/ui/Picker/README.md +2 -1
  45. package/src/ui/Radio/README.md +2 -1
  46. package/src/ui/Sheet/README.md +3 -1
  47. package/src/ui/SliderCaptcha/README.md +1 -1
  48. package/src/ui/Switch/README.md +1 -1
  49. package/src/ui/Text/README.md +2 -2
  50. package/src/ui/TextInput/README.md +6 -6
  51. package/src/ui/WheelColumn/README.md +1 -1
  52. package/dist/ComponentLibProvider.d.ts +0 -15
  53. package/dist/ComponentLibProvider.d.ts.map +0 -1
  54. package/dist/ComponentLibProvider.js +0 -18
  55. package/src/ComponentLibProvider.tsx +0 -56
package/src/all.ts ADDED
@@ -0,0 +1,397 @@
1
+ export { Button } from './ui/Button/index';
2
+ export type {
3
+ ButtonBorder,
4
+ ButtonBorderStyle,
5
+ ButtonColors,
6
+ ButtonGradient,
7
+ ButtonGradientDirection,
8
+ ButtonGradientPoint,
9
+ ButtonIconPlacement,
10
+ ButtonLayout,
11
+ ButtonLoadingMode,
12
+ ButtonPressEffect,
13
+ ButtonProps,
14
+ ButtonRef,
15
+ ButtonShape,
16
+ ButtonShadow,
17
+ ButtonShadowConfig,
18
+ ButtonShadowSize,
19
+ ButtonSize,
20
+ ButtonTone,
21
+ ButtonVariant,
22
+ } from './ui/Button/index';
23
+ export { LoadingSpinner } from './ui/LoadingSpinner/index';
24
+ export type { LoadingSpinnerProps } from './ui/LoadingSpinner/index';
25
+ export { Checkbox, CheckboxGroup, CheckboxIndicator } from './ui/Checkbox/index';
26
+ export type {
27
+ CheckboxCheckedState,
28
+ CheckboxColors,
29
+ CheckboxGroupAlign,
30
+ CheckboxGroupOrientation,
31
+ CheckboxGroupProps,
32
+ CheckboxIndicatorProps,
33
+ CheckboxLabelPlacement,
34
+ CheckboxLayout,
35
+ CheckboxProps,
36
+ CheckboxRef,
37
+ CheckboxShape,
38
+ CheckboxSize,
39
+ CheckboxSlotProps,
40
+ CheckboxTone,
41
+ CheckboxValue,
42
+ CheckboxVariant,
43
+ } from './ui/Checkbox/index';
44
+ export { Text } from './ui/Text/index';
45
+ export type {
46
+ TextProps,
47
+ TextRef,
48
+ TextSize,
49
+ TextSizeValue,
50
+ TextTone,
51
+ TextTruncate,
52
+ TextVariant,
53
+ TextWeight,
54
+ } from './ui/Text/index';
55
+ export { TextInput, TextInputPrimitive } from './ui/TextInput/index';
56
+ export type {
57
+ TextInputColors,
58
+ TextInputLayout,
59
+ TextInputPrimitiveProps,
60
+ TextInputPrimitiveRef,
61
+ TextInputProps,
62
+ TextInputRef,
63
+ TextInputSize,
64
+ TextInputStatus,
65
+ TextInputTone,
66
+ TextInputVariant,
67
+ } from './ui/TextInput/index';
68
+ export {
69
+ Sheet,
70
+ SheetContent,
71
+ SheetFooter,
72
+ SheetHeader,
73
+ } from './ui/Sheet/index';
74
+ export type {
75
+ SheetAnimationConfig,
76
+ SheetBackdropConfig,
77
+ SheetCloseCompleteDetails,
78
+ SheetCloseOptions,
79
+ SheetCloseReason,
80
+ SheetContentProps,
81
+ SheetDetent,
82
+ SheetDetentChangePayload,
83
+ SheetFooterProps,
84
+ SheetHandleConfig,
85
+ SheetHeaderProps,
86
+ SheetNativeProps,
87
+ SheetOpenChangeDetails,
88
+ SheetOpenChangeReason,
89
+ SheetOpenCompleteDetails,
90
+ SheetOpenOptions,
91
+ SheetOpenReason,
92
+ SheetPlacement,
93
+ SheetProps,
94
+ SheetRef,
95
+ SheetRenderContext,
96
+ SheetSafeAreaEdges,
97
+ SheetSize,
98
+ SheetState,
99
+ } from './ui/Sheet/index';
100
+ export {
101
+ Accordion,
102
+ AccordionContent,
103
+ AccordionIndicator,
104
+ AccordionItem,
105
+ AccordionTrigger,
106
+ } from './ui/Accordion/index';
107
+ export type {
108
+ AccordionAnimationConfig,
109
+ AccordionContentProps,
110
+ AccordionIndicatorProps,
111
+ AccordionItemState,
112
+ AccordionItemProps,
113
+ AccordionMountStrategy,
114
+ AccordionMultipleProps,
115
+ AccordionPressEffect,
116
+ AccordionProps,
117
+ AccordionSingleProps,
118
+ AccordionSize,
119
+ AccordionSlot,
120
+ AccordionTone,
121
+ AccordionTriggerProps,
122
+ AccordionTriggerRenderState,
123
+ AccordionType,
124
+ AccordionValue,
125
+ AccordionVariant,
126
+ } from './ui/Accordion/index';
127
+ export { BetweenTime } from './ui/BetweenTime/index';
128
+ export type { BetweenTimeProps } from './ui/BetweenTime/index';
129
+ export { Picker } from './ui/Picker/index';
130
+ export type {
131
+ PickerChangePayload,
132
+ PickerColumnHeaderContext,
133
+ PickerConfirmPayload,
134
+ PickerDraftChangePayload,
135
+ PickerHandle,
136
+ PickerOption,
137
+ PickerPrimitiveValue,
138
+ PickerProps,
139
+ PickerSelection,
140
+ PickerTriggerContext,
141
+ PickerValue,
142
+ PickerValueMode,
143
+ } from './ui/Picker/index';
144
+ export {
145
+ WheelColumn,
146
+ WHEEL_AREA_HEIGHT,
147
+ WHEEL_AREA_VERTICAL_INSET,
148
+ WHEEL_ITEM_HEIGHT,
149
+ WHEEL_VIEWPORT_HEIGHT,
150
+ WHEEL_VISIBLE_ITEMS,
151
+ } from './ui/WheelColumn/index';
152
+ export type {
153
+ WheelColumnChangePayload,
154
+ WheelColumnChangeSource,
155
+ WheelColumnHandle,
156
+ WheelColumnOption,
157
+ WheelColumnProps,
158
+ WheelColumnValue,
159
+ WheelOption,
160
+ } from './ui/WheelColumn/index';
161
+ export { AddressCascader } from './ui/AddressCascader/index';
162
+ export type {
163
+ AddressCascaderChangePayload,
164
+ AddressCascaderConfirmPayload,
165
+ AddressCascaderHandle,
166
+ AddressCascaderOption,
167
+ AddressCascaderProps,
168
+ AddressCascaderRenderContext,
169
+ AddressCascaderValue,
170
+ } from './ui/AddressCascader/index';
171
+ export { DatePicker } from './ui/DatePicker/index';
172
+ export type {
173
+ DatePickerChangePayload,
174
+ DatePickerColumn,
175
+ DatePickerColumnHeaderContext,
176
+ DatePickerConfirmPayload,
177
+ DatePickerDisableContext,
178
+ DatePickerDraftChangePayload,
179
+ DatePickerHandle,
180
+ DatePickerInput,
181
+ DatePickerLabelFormat,
182
+ DatePickerOption,
183
+ DatePickerParts,
184
+ DatePickerPrecision,
185
+ DatePickerProps,
186
+ DatePickerRenderContext,
187
+ DatePickerSelection,
188
+ DatePickerValue,
189
+ } from './ui/DatePicker/index';
190
+ export { Switch } from './ui/Switch/index';
191
+ export type {
192
+ SwitchColors,
193
+ SwitchLabelPlacement,
194
+ SwitchLayout,
195
+ SwitchProps,
196
+ SwitchRef,
197
+ SwitchSize,
198
+ SwitchSlotProps,
199
+ SwitchStateText,
200
+ SwitchTone,
201
+ } from './ui/Switch/index';
202
+ export { SliderCaptcha } from './ui/SliderCaptcha/index';
203
+ export type {
204
+ SliderCaptchaChallenge,
205
+ SliderCaptchaErrorInfo,
206
+ SliderCaptchaErrorStage,
207
+ SliderCaptchaLoadReason,
208
+ SliderCaptchaProps,
209
+ SliderCaptchaStatus,
210
+ SliderCaptchaTexts,
211
+ SliderCaptchaVerifyPayload,
212
+ SliderCaptchaVerifyResult,
213
+ } from './ui/SliderCaptcha/index';
214
+ export { Radio, RadioGroup, RadioIndicator } from './ui/Radio/index';
215
+ export type {
216
+ RadioColors,
217
+ RadioGroupAlign,
218
+ RadioGroupOrientation,
219
+ RadioGroupProps,
220
+ RadioIndicatorProps,
221
+ RadioLabelPlacement,
222
+ RadioLayout,
223
+ RadioProps,
224
+ RadioRef,
225
+ RadioSize,
226
+ RadioSlotProps,
227
+ RadioTone,
228
+ RadioValue,
229
+ RadioVariant,
230
+ } from './ui/Radio/index';
231
+ export { LinkedScroll } from './ui/LinkedScroll/index';
232
+ export type {
233
+ LinkedScrollChangeMeta,
234
+ LinkedScrollChangeSource,
235
+ LinkedScrollItem,
236
+ LinkedScrollMenuItemRenderContext,
237
+ LinkedScrollProps,
238
+ LinkedScrollSectionRenderContext,
239
+ LinkedScrollValue,
240
+ } from './ui/LinkedScroll/index';
241
+ export { ThemeProvider } from './theme/ThemeProvider';
242
+ export { useTheme } from './theme/useTheme';
243
+ export type { Theme, ThemeOverride } from './theme/types';
244
+ export { configureZKit } from './config';
245
+ export type { ZKitConfig, ZKitI18nConfig } from './config';
246
+ export {
247
+ BUILTIN_I18N_LOCALES,
248
+ DEFAULT_I18N_LOCALE,
249
+ resolveBuiltinLocale,
250
+ resolveSystemBuiltinLocale,
251
+ } from './i18n/locale';
252
+ export type { BuiltinI18nLocale } from './i18n/locale';
253
+ export { I18nProvider } from './i18n/I18nProvider';
254
+ export { useI18n } from './i18n/useI18n';
255
+ export type {
256
+ I18nContextValue,
257
+ I18nMessages,
258
+ I18nMissingKeyPolicy,
259
+ I18nTranslate,
260
+ I18nTranslateParams,
261
+ } from './i18n/types';
262
+ export { ZKitProvider } from './ZKitProvider';
263
+ export type { ZKitProviderProps } from './ZKitProvider';
264
+ export { ZKitCoreProvider } from './ZKitCoreProvider';
265
+ export type { ZKitCoreProviderProps } from './ZKitCoreProvider';
266
+ export { pickerService, PickerServiceProvider } from './services/PickerService/index';
267
+ export type {
268
+ AddressPickerResult,
269
+ BetweenTimePickerResult,
270
+ DatePickerResult,
271
+ PickOptions,
272
+ PickDateOptions,
273
+ PickAddressOptions,
274
+ PickBetweenTimeOptions,
275
+ PickerResult,
276
+ } from './services/PickerService/index';
277
+ export { toast, ToastProvider } from './services/CardToastService/index';
278
+ export type {
279
+ ToastAction,
280
+ ToastActionContext,
281
+ ToastCustomOptions,
282
+ ToastDefaults,
283
+ ToastDismissReason,
284
+ ToastHandle,
285
+ ToastIconRenderContext,
286
+ ToastItem,
287
+ ToastOpenChangeMeta,
288
+ ToastOpenChangeReason,
289
+ ToastOptions,
290
+ ToastPlacement,
291
+ ToastProviderProps,
292
+ ToastRenderContext,
293
+ ToastService,
294
+ ToastShortcutOptions,
295
+ ToastStrategy,
296
+ ToastTone,
297
+ ToastUpdateOptions,
298
+ } from './services/CardToastService/index';
299
+ export { ActionDialog, actionDialog, ActionDialogProvider } from './services/ActionDialogService/index';
300
+ export type {
301
+ ActionDialogAction,
302
+ ActionDialogActionContext,
303
+ ActionDialogActionPressResult,
304
+ ActionDialogActionResult,
305
+ ActionDialogActionRole,
306
+ ActionDialogActionTone,
307
+ ActionDialogActionVariant,
308
+ ActionDialogAlertOptions,
309
+ ActionDialogCollisionStrategy,
310
+ ActionDialogColors,
311
+ ActionDialogConfirmOptions,
312
+ ActionDialogDismissOptions,
313
+ ActionDialogDismissReason,
314
+ ActionDialogDismissResult,
315
+ ActionDialogFooterLayout,
316
+ ActionDialogFooterOptions,
317
+ ActionDialogFooterRenderContext,
318
+ ActionDialogHandle,
319
+ ActionDialogHostMode,
320
+ ActionDialogKeyboardOptions,
321
+ ActionDialogLabels,
322
+ ActionDialogLayerOptions,
323
+ ActionDialogLayoutOptions,
324
+ ActionDialogMotion,
325
+ ActionDialogOpenChangeMeta,
326
+ ActionDialogOpenChangeReason,
327
+ ActionDialogOpenOptions,
328
+ ActionDialogProps,
329
+ ActionDialogRef,
330
+ ActionDialogResolvedAction,
331
+ ActionDialogResolvedFooterLayout,
332
+ ActionDialogResult,
333
+ ActionDialogSemanticActionOptions,
334
+ ActionDialogService,
335
+ ActionDialogSnapshot,
336
+ } from './services/ActionDialogService/index';
337
+ export { loading, LoadingProvider } from './services/LoadingService/index';
338
+ export type {
339
+ LoadingColors,
340
+ LoadingDefaults,
341
+ LoadingDismissReason,
342
+ LoadingHandle,
343
+ LoadingIconRenderContext,
344
+ LoadingInput,
345
+ LoadingItem,
346
+ LoadingLabels,
347
+ LoadingLiveRegion,
348
+ LoadingOpenChangeMeta,
349
+ LoadingOpenChangeReason,
350
+ LoadingPromiseErrorInput,
351
+ LoadingPromiseOptions,
352
+ LoadingPromiseResultInput,
353
+ LoadingProviderProps,
354
+ LoadingRenderContext,
355
+ LoadingResolvedDefaults,
356
+ LoadingResultInput,
357
+ LoadingResultOptions,
358
+ LoadingService,
359
+ LoadingShowOptions,
360
+ LoadingSnapshot,
361
+ LoadingStatus,
362
+ LoadingUpdateOptions,
363
+ } from './services/LoadingService/index';
364
+ export {
365
+ permissionPurposeDialog,
366
+ PermissionPurposeDialogProvider,
367
+ } from './services/PermissionPurposeDialogService/index';
368
+ export type {
369
+ PermissionPurpose,
370
+ PermissionPurposeDialogHandle,
371
+ PermissionPurposeDialogOptions,
372
+ } from './services/PermissionPurposeDialogService/index';
373
+ export { imagePreview, ImagePreview, ImagePreviewProvider } from './services/ImagePreviewService/index';
374
+ export type {
375
+ ImagePreviewChangeMeta,
376
+ ImagePreviewChangeReason,
377
+ ImagePreviewCloseReason,
378
+ ImagePreviewColors,
379
+ ImagePreviewImage,
380
+ ImagePreviewImageDescriptor,
381
+ ImagePreviewImageProps,
382
+ ImagePreviewInteractions,
383
+ ImagePreviewLabels,
384
+ ImagePreviewOpenChangeMeta,
385
+ ImagePreviewOpenChangeReason,
386
+ ImagePreviewOpenOptions,
387
+ ImagePreviewPrefetchCachePolicy,
388
+ ImagePreviewProps,
389
+ ImagePreviewRef,
390
+ ImagePreviewRenderContext,
391
+ ImagePreviewResolvedImage,
392
+ ImagePreviewResult,
393
+ ImagePreviewServiceHandle,
394
+ ImagePreviewServiceSnapshot,
395
+ ImagePreviewSource,
396
+ ImagePreviewTapBehavior,
397
+ } from './services/ImagePreviewService/index';
package/src/config.ts CHANGED
@@ -8,9 +8,9 @@ import type { I18nMessages, I18nMissingKeyPolicy } from './i18n/types';
8
8
  // 1) Theme:用于给所有组件提供默认 tokens(颜色等)
9
9
  // 2) i18n:用于给所有组件提供默认文案字典/缺失策略
10
10
  //
11
- // 推荐在应用启动时调用一次 configureComponentLib()(例如在 app entry),
11
+ // 推荐在应用启动时调用一次 configureZKit()(例如在 app entry),
12
12
  // 这样即便业务侧没有包 Provider,组件库也能拿到一致的默认值。
13
- export type ComponentLibI18nConfig = {
13
+ export type ZKitI18nConfig = {
14
14
  // locale 目前仅用于透传;组件内部可据此选择 key 前缀或做格式化扩展
15
15
  locale?: string;
16
16
  // messages 是 key -> 文案 的扁平字典,组件内部用 t(key) 获取
@@ -21,45 +21,45 @@ export type ComponentLibI18nConfig = {
21
21
  missingKeyPolicy?: I18nMissingKeyPolicy;
22
22
  };
23
23
 
24
- export type ComponentLibConfig = {
24
+ export type ZKitConfig = {
25
25
  // theme 是“覆盖对象”,只需要传你要改的字段即可(未传字段回落到 defaultTheme)
26
26
  theme?: ThemeOverride;
27
- i18n?: ComponentLibI18nConfig;
27
+ i18n?: ZKitI18nConfig;
28
28
  };
29
29
 
30
- let componentLibConfig: ComponentLibConfig = {};
30
+ let zKitConfig: ZKitConfig = {};
31
31
 
32
32
  // 合并式更新:多次调用会按层级合并(不会把之前的 i18n 整块覆盖掉)
33
- export function configureComponentLib(next: ComponentLibConfig) {
34
- componentLibConfig = {
35
- ...componentLibConfig,
33
+ export function configureZKit(next: ZKitConfig) {
34
+ zKitConfig = {
35
+ ...zKitConfig,
36
36
  ...next,
37
37
  i18n: {
38
- ...componentLibConfig.i18n,
38
+ ...zKitConfig.i18n,
39
39
  ...next.i18n,
40
40
  },
41
41
  };
42
42
  }
43
43
 
44
- export function getComponentLibConfig(): ComponentLibConfig {
45
- return componentLibConfig;
44
+ export function getZKitConfig(): ZKitConfig {
45
+ return zKitConfig;
46
46
  }
47
47
 
48
48
  // getDefaultTheme 用于生成“当前有效的默认主题”:
49
49
  // - defaultTheme 作为组件库内置基线
50
- // - configureComponentLib({ theme }) 提供全局覆盖
50
+ // - configureZKit({ theme }) 提供全局覆盖
51
51
  // - ThemeProvider({ theme }) 再做实例级覆盖(优先级更高)
52
52
  export function getDefaultTheme(): Theme {
53
- return mergeTheme(defaultTheme, componentLibConfig.theme);
53
+ return mergeTheme(defaultTheme, zKitConfig.theme);
54
54
  }
55
55
 
56
56
  // getDefaultI18nConfig 用于生成“当前有效的默认 i18n 配置”:
57
- // - configureComponentLib({ i18n }) 可在应用启动时设定默认 locale/messages
57
+ // - configureZKit({ i18n }) 可在应用启动时设定默认 locale/messages
58
58
  // - I18nProvider({ ... }) 可在局部覆盖(例如某个子树临时切换语言)
59
- export function getDefaultI18nConfig(): Required<ComponentLibI18nConfig> {
59
+ export function getDefaultI18nConfig(): Required<ZKitI18nConfig> {
60
60
  return {
61
- locale: componentLibConfig.i18n?.locale ?? resolveSystemBuiltinLocale(),
62
- messages: componentLibConfig.i18n?.messages ?? {},
63
- missingKeyPolicy: componentLibConfig.i18n?.missingKeyPolicy ?? 'key',
61
+ locale: zKitConfig.i18n?.locale ?? resolveSystemBuiltinLocale(),
62
+ messages: zKitConfig.i18n?.messages ?? {},
63
+ missingKeyPolicy: zKitConfig.i18n?.missingKeyPolicy ?? 'key',
64
64
  };
65
65
  }