@fbkworks/adapter-core 0.3.0 → 0.5.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 +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.mjs +9 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -145,7 +145,6 @@ interface Capabilities {
|
|
|
145
145
|
};
|
|
146
146
|
theme: {
|
|
147
147
|
darkMode: boolean;
|
|
148
|
-
cssVariables: boolean;
|
|
149
148
|
provider: boolean;
|
|
150
149
|
};
|
|
151
150
|
/** 细粒度可选能力,业务组件按 key 探测 */
|
|
@@ -462,6 +461,20 @@ interface DataGridProps<T = any> {
|
|
|
462
461
|
finished?: boolean;
|
|
463
462
|
size?: 'sm' | 'md' | 'lg';
|
|
464
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* DataGrid 的插槽契约。目前只有一个 `empty`。
|
|
466
|
+
*
|
|
467
|
+
* 为什么是插槽而不是又一个组件:`FbkEmpty` 曾经存在并被删掉 ——
|
|
468
|
+
* 它只是把「空态」这件事又包了一层,多一个要同步的入口,而它本身没有任何行为。
|
|
469
|
+
* 空态的默认实现由各适配器用自己的空态组件渲染(`emptyText` 作为文案),
|
|
470
|
+
* 业务方需要自定义时传这一个插槽即可。
|
|
471
|
+
*
|
|
472
|
+
* 适配器实现要求:提供了 `empty` 就用它,没提供才渲染默认空态 ——
|
|
473
|
+
* 三者语义必须一致,否则「换库外观不变」这条承诺在这里就断了。
|
|
474
|
+
*/
|
|
475
|
+
interface DataGridSlots {
|
|
476
|
+
empty?: () => any;
|
|
477
|
+
}
|
|
465
478
|
interface DataGridEmits<T = any> {
|
|
466
479
|
'update:selectedKeys': [keys: Array<string | number>];
|
|
467
480
|
/**
|
|
@@ -561,6 +574,17 @@ declare function useAdapterContext(): AdapterContext | null;
|
|
|
561
574
|
* 组件在独立使用(无 Provider)时不该因为它而崩溃。
|
|
562
575
|
*/
|
|
563
576
|
declare function useReporter(): FbkReporter;
|
|
577
|
+
/**
|
|
578
|
+
* 取当前 UI 适配器。
|
|
579
|
+
*
|
|
580
|
+
* 顺带做一次**运行时兼容校验**:`components` 与 `adapter-core` 现在是同组发布,
|
|
581
|
+
* 但拆 `fixed` 之后两者可以各自升级 —— 那时「组件 0.5 配 core 0.4」或
|
|
582
|
+
* 「core 0.5 配一个按 0.4 契约写的适配器」都不会在构建期报错,只会在运行时
|
|
583
|
+
* 表现得莫名其妙(少了原语就是 undefined,多了字段就被忽略)。
|
|
584
|
+
*
|
|
585
|
+
* 所以每个用到适配器的组件在第一次渲染时都会经过这里,版本对不上就立刻带着
|
|
586
|
+
* 版本号说清楚 —— 而不是让问题漂到业务方的某个页面上。
|
|
587
|
+
*/
|
|
564
588
|
declare function useAdapter(): UiAdapter;
|
|
565
589
|
declare function useAdapterCapabilities(): Capabilities;
|
|
566
590
|
declare function useFbkTheme(): {
|
|
@@ -766,4 +790,4 @@ declare function getCellValue<T>(column: DataGridColumn<T>, row: T): unknown;
|
|
|
766
790
|
declare function renderCell<T>(column: DataGridColumn<T>, row: T, index: number): unknown;
|
|
767
791
|
|
|
768
792
|
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 };
|
|
769
|
-
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 };
|
|
793
|
+
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
|
@@ -145,7 +145,6 @@ interface Capabilities {
|
|
|
145
145
|
};
|
|
146
146
|
theme: {
|
|
147
147
|
darkMode: boolean;
|
|
148
|
-
cssVariables: boolean;
|
|
149
148
|
provider: boolean;
|
|
150
149
|
};
|
|
151
150
|
/** 细粒度可选能力,业务组件按 key 探测 */
|
|
@@ -462,6 +461,20 @@ interface DataGridProps<T = any> {
|
|
|
462
461
|
finished?: boolean;
|
|
463
462
|
size?: 'sm' | 'md' | 'lg';
|
|
464
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* DataGrid 的插槽契约。目前只有一个 `empty`。
|
|
466
|
+
*
|
|
467
|
+
* 为什么是插槽而不是又一个组件:`FbkEmpty` 曾经存在并被删掉 ——
|
|
468
|
+
* 它只是把「空态」这件事又包了一层,多一个要同步的入口,而它本身没有任何行为。
|
|
469
|
+
* 空态的默认实现由各适配器用自己的空态组件渲染(`emptyText` 作为文案),
|
|
470
|
+
* 业务方需要自定义时传这一个插槽即可。
|
|
471
|
+
*
|
|
472
|
+
* 适配器实现要求:提供了 `empty` 就用它,没提供才渲染默认空态 ——
|
|
473
|
+
* 三者语义必须一致,否则「换库外观不变」这条承诺在这里就断了。
|
|
474
|
+
*/
|
|
475
|
+
interface DataGridSlots {
|
|
476
|
+
empty?: () => any;
|
|
477
|
+
}
|
|
465
478
|
interface DataGridEmits<T = any> {
|
|
466
479
|
'update:selectedKeys': [keys: Array<string | number>];
|
|
467
480
|
/**
|
|
@@ -561,6 +574,17 @@ declare function useAdapterContext(): AdapterContext | null;
|
|
|
561
574
|
* 组件在独立使用(无 Provider)时不该因为它而崩溃。
|
|
562
575
|
*/
|
|
563
576
|
declare function useReporter(): FbkReporter;
|
|
577
|
+
/**
|
|
578
|
+
* 取当前 UI 适配器。
|
|
579
|
+
*
|
|
580
|
+
* 顺带做一次**运行时兼容校验**:`components` 与 `adapter-core` 现在是同组发布,
|
|
581
|
+
* 但拆 `fixed` 之后两者可以各自升级 —— 那时「组件 0.5 配 core 0.4」或
|
|
582
|
+
* 「core 0.5 配一个按 0.4 契约写的适配器」都不会在构建期报错,只会在运行时
|
|
583
|
+
* 表现得莫名其妙(少了原语就是 undefined,多了字段就被忽略)。
|
|
584
|
+
*
|
|
585
|
+
* 所以每个用到适配器的组件在第一次渲染时都会经过这里,版本对不上就立刻带着
|
|
586
|
+
* 版本号说清楚 —— 而不是让问题漂到业务方的某个页面上。
|
|
587
|
+
*/
|
|
564
588
|
declare function useAdapter(): UiAdapter;
|
|
565
589
|
declare function useAdapterCapabilities(): Capabilities;
|
|
566
590
|
declare function useFbkTheme(): {
|
|
@@ -766,4 +790,4 @@ declare function getCellValue<T>(column: DataGridColumn<T>, row: T): unknown;
|
|
|
766
790
|
declare function renderCell<T>(column: DataGridColumn<T>, row: T, index: number): unknown;
|
|
767
791
|
|
|
768
792
|
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 };
|
|
769
|
-
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 };
|
|
793
|
+
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
|
}
|