@fbkworks/adapter-core 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.mjs +9 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -353,6 +353,14 @@ interface DrawerProps {
|
|
|
353
353
|
showClose?: boolean;
|
|
354
354
|
}
|
|
355
355
|
interface PaginationProps {
|
|
356
|
+
/**
|
|
357
|
+
* 分页形态。默认值由各适配器自己决定,但**必须与它的
|
|
358
|
+
* `capabilities.pagination.mode` 一致** —— 能力位说 infinite、原语默认却是页码时,
|
|
359
|
+
* 「只通过 primitives.* 使用」的业务方会拿到与能力声明相反的东西。
|
|
360
|
+
*
|
|
361
|
+
* 移动端适配器(vant)默认 `'infinite'`,桌面端默认 `'pages'`。
|
|
362
|
+
*/
|
|
363
|
+
mode?: 'pages' | 'infinite';
|
|
356
364
|
page: number;
|
|
357
365
|
pageSize: number;
|
|
358
366
|
total: number;
|
|
@@ -461,6 +469,20 @@ interface DataGridProps<T = any> {
|
|
|
461
469
|
finished?: boolean;
|
|
462
470
|
size?: 'sm' | 'md' | 'lg';
|
|
463
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* DataGrid 的插槽契约。目前只有一个 `empty`。
|
|
474
|
+
*
|
|
475
|
+
* 为什么是插槽而不是又一个组件:`FbkEmpty` 曾经存在并被删掉 ——
|
|
476
|
+
* 它只是把「空态」这件事又包了一层,多一个要同步的入口,而它本身没有任何行为。
|
|
477
|
+
* 空态的默认实现由各适配器用自己的空态组件渲染(`emptyText` 作为文案),
|
|
478
|
+
* 业务方需要自定义时传这一个插槽即可。
|
|
479
|
+
*
|
|
480
|
+
* 适配器实现要求:提供了 `empty` 就用它,没提供才渲染默认空态 ——
|
|
481
|
+
* 三者语义必须一致,否则「换库外观不变」这条承诺在这里就断了。
|
|
482
|
+
*/
|
|
483
|
+
interface DataGridSlots {
|
|
484
|
+
empty?: () => any;
|
|
485
|
+
}
|
|
464
486
|
interface DataGridEmits<T = any> {
|
|
465
487
|
'update:selectedKeys': [keys: Array<string | number>];
|
|
466
488
|
/**
|
|
@@ -560,6 +582,17 @@ declare function useAdapterContext(): AdapterContext | null;
|
|
|
560
582
|
* 组件在独立使用(无 Provider)时不该因为它而崩溃。
|
|
561
583
|
*/
|
|
562
584
|
declare function useReporter(): FbkReporter;
|
|
585
|
+
/**
|
|
586
|
+
* 取当前 UI 适配器。
|
|
587
|
+
*
|
|
588
|
+
* 顺带做一次**运行时兼容校验**:`components` 与 `adapter-core` 现在是同组发布,
|
|
589
|
+
* 但拆 `fixed` 之后两者可以各自升级 —— 那时「组件 0.5 配 core 0.4」或
|
|
590
|
+
* 「core 0.5 配一个按 0.4 契约写的适配器」都不会在构建期报错,只会在运行时
|
|
591
|
+
* 表现得莫名其妙(少了原语就是 undefined,多了字段就被忽略)。
|
|
592
|
+
*
|
|
593
|
+
* 所以每个用到适配器的组件在第一次渲染时都会经过这里,版本对不上就立刻带着
|
|
594
|
+
* 版本号说清楚 —— 而不是让问题漂到业务方的某个页面上。
|
|
595
|
+
*/
|
|
563
596
|
declare function useAdapter(): UiAdapter;
|
|
564
597
|
declare function useAdapterCapabilities(): Capabilities;
|
|
565
598
|
declare function useFbkTheme(): {
|
|
@@ -765,4 +798,4 @@ declare function getCellValue<T>(column: DataGridColumn<T>, row: T): unknown;
|
|
|
765
798
|
declare function renderCell<T>(column: DataGridColumn<T>, row: T, index: number): unknown;
|
|
766
799
|
|
|
767
800
|
export { ADAPTER_API_VERSION, ADAPTER_CONTEXT, FbkProvider, NOOP_REPORTER, PERMISSION_CONTEXT, THEME_IS_DARK, assertAdapterCompatible, createAdapterContext, createBusinessKit, createPermissionDirective, createReporter, getCellValue, hasPermission, renderCell, requirePrimitive, safeContext, toErrorEvent, useAdapter, useAdapterCapabilities, useAdapterContext, useFbkTheme, usePermission, useReporter };
|
|
768
|
-
export type { AdapterContext, AdapterMeta, BusinessKitOptions, ButtonProps, ButtonVariant, Capabilities, CellRenderContext, CheckboxEmits, CheckboxProps, ConfirmApi, ConfirmOptions, DataGridColumn, DataGridEmits, DataGridPresentation, DataGridProps, DatePickerProps, DatePickerType, DialogProps, DrawerProps, FbkErrorEvent, FbkErrorSource, FbkReporter, FbkReporterOptions, FbkRule, FbkTelemetryEvent, FbkTelemetryType, FeedbackApi, FormExpose, FormItemProps, FormProps, FormRules, InputProps, MessageApi, MessageOptions, MessageType, PaginationProps, PermissionContext, PermissionResolver, RadioOption, RadioProps, SelectOption, SelectProps, Size, SortOrder, SortState, SpinProps, Status, TagProps, ThemeBridge, ThemeMode, UiAdapter, UiPrimitives };
|
|
801
|
+
export type { AdapterContext, AdapterMeta, BusinessKitOptions, ButtonProps, ButtonVariant, Capabilities, CellRenderContext, CheckboxEmits, CheckboxProps, ConfirmApi, ConfirmOptions, DataGridColumn, DataGridEmits, DataGridPresentation, DataGridProps, DataGridSlots, DatePickerProps, DatePickerType, DialogProps, DrawerProps, FbkErrorEvent, FbkErrorSource, FbkReporter, FbkReporterOptions, FbkRule, FbkTelemetryEvent, FbkTelemetryType, FeedbackApi, FormExpose, FormItemProps, FormProps, FormRules, InputProps, MessageApi, MessageOptions, MessageType, PaginationProps, PermissionContext, PermissionResolver, RadioOption, RadioProps, SelectOption, SelectProps, Size, SortOrder, SortState, SpinProps, Status, TagProps, ThemeBridge, ThemeMode, UiAdapter, UiPrimitives };
|
package/dist/index.d.ts
CHANGED
|
@@ -353,6 +353,14 @@ interface DrawerProps {
|
|
|
353
353
|
showClose?: boolean;
|
|
354
354
|
}
|
|
355
355
|
interface PaginationProps {
|
|
356
|
+
/**
|
|
357
|
+
* 分页形态。默认值由各适配器自己决定,但**必须与它的
|
|
358
|
+
* `capabilities.pagination.mode` 一致** —— 能力位说 infinite、原语默认却是页码时,
|
|
359
|
+
* 「只通过 primitives.* 使用」的业务方会拿到与能力声明相反的东西。
|
|
360
|
+
*
|
|
361
|
+
* 移动端适配器(vant)默认 `'infinite'`,桌面端默认 `'pages'`。
|
|
362
|
+
*/
|
|
363
|
+
mode?: 'pages' | 'infinite';
|
|
356
364
|
page: number;
|
|
357
365
|
pageSize: number;
|
|
358
366
|
total: number;
|
|
@@ -461,6 +469,20 @@ interface DataGridProps<T = any> {
|
|
|
461
469
|
finished?: boolean;
|
|
462
470
|
size?: 'sm' | 'md' | 'lg';
|
|
463
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* DataGrid 的插槽契约。目前只有一个 `empty`。
|
|
474
|
+
*
|
|
475
|
+
* 为什么是插槽而不是又一个组件:`FbkEmpty` 曾经存在并被删掉 ——
|
|
476
|
+
* 它只是把「空态」这件事又包了一层,多一个要同步的入口,而它本身没有任何行为。
|
|
477
|
+
* 空态的默认实现由各适配器用自己的空态组件渲染(`emptyText` 作为文案),
|
|
478
|
+
* 业务方需要自定义时传这一个插槽即可。
|
|
479
|
+
*
|
|
480
|
+
* 适配器实现要求:提供了 `empty` 就用它,没提供才渲染默认空态 ——
|
|
481
|
+
* 三者语义必须一致,否则「换库外观不变」这条承诺在这里就断了。
|
|
482
|
+
*/
|
|
483
|
+
interface DataGridSlots {
|
|
484
|
+
empty?: () => any;
|
|
485
|
+
}
|
|
464
486
|
interface DataGridEmits<T = any> {
|
|
465
487
|
'update:selectedKeys': [keys: Array<string | number>];
|
|
466
488
|
/**
|
|
@@ -560,6 +582,17 @@ declare function useAdapterContext(): AdapterContext | null;
|
|
|
560
582
|
* 组件在独立使用(无 Provider)时不该因为它而崩溃。
|
|
561
583
|
*/
|
|
562
584
|
declare function useReporter(): FbkReporter;
|
|
585
|
+
/**
|
|
586
|
+
* 取当前 UI 适配器。
|
|
587
|
+
*
|
|
588
|
+
* 顺带做一次**运行时兼容校验**:`components` 与 `adapter-core` 现在是同组发布,
|
|
589
|
+
* 但拆 `fixed` 之后两者可以各自升级 —— 那时「组件 0.5 配 core 0.4」或
|
|
590
|
+
* 「core 0.5 配一个按 0.4 契约写的适配器」都不会在构建期报错,只会在运行时
|
|
591
|
+
* 表现得莫名其妙(少了原语就是 undefined,多了字段就被忽略)。
|
|
592
|
+
*
|
|
593
|
+
* 所以每个用到适配器的组件在第一次渲染时都会经过这里,版本对不上就立刻带着
|
|
594
|
+
* 版本号说清楚 —— 而不是让问题漂到业务方的某个页面上。
|
|
595
|
+
*/
|
|
563
596
|
declare function useAdapter(): UiAdapter;
|
|
564
597
|
declare function useAdapterCapabilities(): Capabilities;
|
|
565
598
|
declare function useFbkTheme(): {
|
|
@@ -765,4 +798,4 @@ declare function getCellValue<T>(column: DataGridColumn<T>, row: T): unknown;
|
|
|
765
798
|
declare function renderCell<T>(column: DataGridColumn<T>, row: T, index: number): unknown;
|
|
766
799
|
|
|
767
800
|
export { ADAPTER_API_VERSION, ADAPTER_CONTEXT, FbkProvider, NOOP_REPORTER, PERMISSION_CONTEXT, THEME_IS_DARK, assertAdapterCompatible, createAdapterContext, createBusinessKit, createPermissionDirective, createReporter, getCellValue, hasPermission, renderCell, requirePrimitive, safeContext, toErrorEvent, useAdapter, useAdapterCapabilities, useAdapterContext, useFbkTheme, usePermission, useReporter };
|
|
768
|
-
export type { AdapterContext, AdapterMeta, BusinessKitOptions, ButtonProps, ButtonVariant, Capabilities, CellRenderContext, CheckboxEmits, CheckboxProps, ConfirmApi, ConfirmOptions, DataGridColumn, DataGridEmits, DataGridPresentation, DataGridProps, DatePickerProps, DatePickerType, DialogProps, DrawerProps, FbkErrorEvent, FbkErrorSource, FbkReporter, FbkReporterOptions, FbkRule, FbkTelemetryEvent, FbkTelemetryType, FeedbackApi, FormExpose, FormItemProps, FormProps, FormRules, InputProps, MessageApi, MessageOptions, MessageType, PaginationProps, PermissionContext, PermissionResolver, RadioOption, RadioProps, SelectOption, SelectProps, Size, SortOrder, SortState, SpinProps, Status, TagProps, ThemeBridge, ThemeMode, UiAdapter, UiPrimitives };
|
|
801
|
+
export type { AdapterContext, AdapterMeta, BusinessKitOptions, ButtonProps, ButtonVariant, Capabilities, CellRenderContext, CheckboxEmits, CheckboxProps, ConfirmApi, ConfirmOptions, DataGridColumn, DataGridEmits, DataGridPresentation, DataGridProps, DataGridSlots, DatePickerProps, DatePickerType, DialogProps, DrawerProps, FbkErrorEvent, FbkErrorSource, FbkReporter, FbkReporterOptions, FbkRule, FbkTelemetryEvent, FbkTelemetryType, FeedbackApi, FormExpose, FormItemProps, FormProps, FormRules, InputProps, MessageApi, MessageOptions, MessageType, PaginationProps, PermissionContext, PermissionResolver, RadioOption, RadioProps, SelectOption, SelectProps, Size, SortOrder, SortState, SpinProps, Status, TagProps, ThemeBridge, ThemeMode, UiAdapter, UiPrimitives };
|
package/dist/index.mjs
CHANGED
|
@@ -136,8 +136,17 @@ function useAdapter() {
|
|
|
136
136
|
'[fbk] \u672A\u627E\u5230 UI \u9002\u914D\u5668\u3002\u8BF7\u5728\u5E94\u7528\u5165\u53E3\u6267\u884C\uFF1A\n app.use(createBusinessKit({ adapter: elementPlusAdapter }))\n\u6216\u5728\u5C40\u90E8\u4F7F\u7528\uFF1A<FbkProvider :adapter="adapter">\u3002\n\u6587\u6863\uFF1A/guide/adapters'
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
|
+
assertAdapterVersion(ctx.adapter);
|
|
139
140
|
return ctx.adapter;
|
|
140
141
|
}
|
|
142
|
+
function assertAdapterVersion(adapter) {
|
|
143
|
+
const actual = adapter.meta?.apiVersion;
|
|
144
|
+
if (actual !== ADAPTER_API_VERSION) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`[fbk] \u9002\u914D\u5668\u300C${adapter.meta?.name ?? "unknown"}\u300D\u7684 apiVersion \u662F ${actual ?? "\u672A\u58F0\u660E"}\uFF0C\u5F53\u524D @fbkworks/adapter-core \u8981\u6C42 ${ADAPTER_API_VERSION}\u3002\u8FD9\u901A\u5E38\u610F\u5473\u7740 @fbkworks/components \u4E0E @fbkworks/adapter-core \u7248\u672C\u4E0D\u5339\u914D\uFF0C\u6216\u9002\u914D\u5668\u662F\u6309\u65E7\u5951\u7EA6\u5199\u7684\u3002\u8BF7\u628A\u4E24\u8005\u5347\u5230\u540C\u4E00\u7248\u672C\u7EBF\u3002`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
141
150
|
function useAdapterCapabilities() {
|
|
142
151
|
return useAdapter().capabilities;
|
|
143
152
|
}
|