@fbkworks/adapter-naive-ui 0.0.0-stage → 0.2.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -2
  3. package/dist/dark.css +5 -0
  4. package/dist/feedback.d.ts +4 -0
  5. package/dist/feedback.mjs +61 -0
  6. package/dist/feedback.mjs.map +1 -0
  7. package/dist/index.d.ts +21 -0
  8. package/dist/index.mjs +78 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/locale-context.d.ts +9 -0
  11. package/dist/locale-context.mjs +7 -0
  12. package/dist/locale-context.mjs.map +1 -0
  13. package/dist/primitives/Button.d.ts +53 -0
  14. package/dist/primitives/Button.mjs +62 -0
  15. package/dist/primitives/Button.mjs.map +1 -0
  16. package/dist/primitives/Checkbox.d.ts +26 -0
  17. package/dist/primitives/Checkbox.mjs +43 -0
  18. package/dist/primitives/Checkbox.mjs.map +1 -0
  19. package/dist/primitives/DataGrid.d.ts +93 -0
  20. package/dist/primitives/DataGrid.mjs +125 -0
  21. package/dist/primitives/DataGrid.mjs.map +1 -0
  22. package/dist/primitives/DatePicker.d.ts +66 -0
  23. package/dist/primitives/DatePicker.mjs +90 -0
  24. package/dist/primitives/DatePicker.mjs.map +1 -0
  25. package/dist/primitives/Dialog.d.ts +57 -0
  26. package/dist/primitives/Dialog.mjs +64 -0
  27. package/dist/primitives/Dialog.mjs.map +1 -0
  28. package/dist/primitives/Drawer.d.ts +57 -0
  29. package/dist/primitives/Drawer.mjs +58 -0
  30. package/dist/primitives/Drawer.mjs.map +1 -0
  31. package/dist/primitives/Empty.d.ts +13 -0
  32. package/dist/primitives/Empty.mjs +26 -0
  33. package/dist/primitives/Empty.mjs.map +1 -0
  34. package/dist/primitives/Form.d.ts +95 -0
  35. package/dist/primitives/Form.mjs +124 -0
  36. package/dist/primitives/Form.mjs.map +1 -0
  37. package/dist/primitives/Input.d.ts +57 -0
  38. package/dist/primitives/Input.mjs +58 -0
  39. package/dist/primitives/Input.mjs.map +1 -0
  40. package/dist/primitives/Pagination.d.ts +63 -0
  41. package/dist/primitives/Pagination.mjs +66 -0
  42. package/dist/primitives/Pagination.mjs.map +1 -0
  43. package/dist/primitives/Radio.d.ts +40 -0
  44. package/dist/primitives/Radio.mjs +60 -0
  45. package/dist/primitives/Radio.mjs.map +1 -0
  46. package/dist/primitives/Select.d.ts +61 -0
  47. package/dist/primitives/Select.mjs +55 -0
  48. package/dist/primitives/Select.mjs.map +1 -0
  49. package/dist/primitives/Spin.d.ts +15 -0
  50. package/dist/primitives/Spin.mjs +28 -0
  51. package/dist/primitives/Spin.mjs.map +1 -0
  52. package/dist/primitives/Tag.d.ts +32 -0
  53. package/dist/primitives/Tag.mjs +48 -0
  54. package/dist/primitives/Tag.mjs.map +1 -0
  55. package/dist/root-provider.d.ts +58 -0
  56. package/dist/root-provider.mjs +103 -0
  57. package/dist/root-provider.mjs.map +1 -0
  58. package/dist/style.css +367 -0
  59. package/dist/theme.d.ts +103 -0
  60. package/dist/theme.mjs +133 -0
  61. package/dist/theme.mjs.map +1 -0
  62. package/package.json +56 -3
@@ -0,0 +1,125 @@
1
+ import { defineComponent, computed, createVNode, mergeProps } from "vue";
2
+ import { NDataTable, NEmpty } from "naive-ui";
3
+ import { renderCell } from "@fbkworks/adapter-core";
4
+ import { getRowKey } from "@fbkworks/shared";
5
+ const DataGrid = /* @__PURE__ */ defineComponent({
6
+ name: "FbkNaiveDataGrid",
7
+ inheritAttrs: false,
8
+ props: {
9
+ columns: {
10
+ type: Array,
11
+ default: () => []
12
+ },
13
+ data: {
14
+ type: Array,
15
+ default: () => []
16
+ },
17
+ rowKey: {
18
+ type: [String, Function],
19
+ default: "id"
20
+ },
21
+ loading: Boolean,
22
+ presentation: {
23
+ type: String,
24
+ default: "auto"
25
+ },
26
+ selectionEnabled: Boolean,
27
+ selectionWidth: {
28
+ type: Number,
29
+ default: 48
30
+ },
31
+ selectedKeys: {
32
+ type: Array,
33
+ default: () => []
34
+ },
35
+ sort: {
36
+ type: Object,
37
+ default: null
38
+ },
39
+ emptyText: String,
40
+ rowClickable: Boolean,
41
+ size: {
42
+ type: String,
43
+ default: "md"
44
+ }
45
+ },
46
+ emits: ["update:selectedKeys", "update:sort", "row-click"],
47
+ setup(props, {
48
+ attrs,
49
+ emit,
50
+ slots
51
+ }) {
52
+ const keyOf = (row, index) => getRowKey(row, index, props.rowKey);
53
+ const naiveColumns = computed(() => {
54
+ const result = [];
55
+ if (props.selectionEnabled) {
56
+ result.push({
57
+ type: "selection",
58
+ width: props.selectionWidth
59
+ });
60
+ }
61
+ for (const column of props.columns) {
62
+ result.push({
63
+ key: column.key,
64
+ title: column.title,
65
+ width: column.width,
66
+ minWidth: column.minWidth,
67
+ fixed: column.fixed,
68
+ align: column.align,
69
+ ellipsis: column.ellipsis ? {
70
+ tooltip: true
71
+ } : void 0,
72
+ sorter: column.sortable ? "default" : false,
73
+ /* 数值列加 .fbk-numeric,由适配器样式给等宽数字。
74
+ naive 的 className 落在 <td> 上。 */
75
+ className: column.numeric ? "fbk-numeric" : void 0,
76
+ render: (row, index) => slots[`cell-${column.key}`]?.({
77
+ row,
78
+ index,
79
+ value: renderCell(column, row, index)
80
+ }) ?? renderCell(column, row, index)
81
+ });
82
+ }
83
+ return result;
84
+ });
85
+ const size = computed(() => props.size === "sm" ? "small" : props.size === "lg" ? "large" : "medium");
86
+ return () => createVNode(NDataTable, mergeProps(attrs, {
87
+ "columns": naiveColumns.value,
88
+ "data": props.data,
89
+ "rowKey": (row) => keyOf(row, props.data.indexOf(row)),
90
+ "checkedRowKeys": props.selectedKeys,
91
+ "loading": props.loading,
92
+ "size": size.value,
93
+ "onUpdate:checkedRowKeys": (keys) => emit("update:selectedKeys", keys),
94
+ "onUpdate:sorter": (sorter) => {
95
+ if (!sorter || !sorter.order) {
96
+ emit("update:sort", null);
97
+ return;
98
+ }
99
+ const columnKey = String(sorter.columnKey ?? sorter.column?.key);
100
+ const source = props.columns.find((column) => column.key === columnKey);
101
+ emit("update:sort", {
102
+ field: String(source?.dataIndex ?? columnKey),
103
+ order: sorter.order === "ascend" ? "asc" : "desc"
104
+ });
105
+ },
106
+ "onUpdate:page": () => {
107
+ },
108
+ "rowProps": (row) => ({
109
+ style: props.rowClickable ? "cursor: pointer" : void 0,
110
+ onClick: (event) => {
111
+ if (!props.rowClickable) return;
112
+ emit("row-click", row, props.data.indexOf(row), event);
113
+ }
114
+ })
115
+ }), {
116
+ empty: () => createVNode(NEmpty, {
117
+ "description": props.emptyText ?? "暂无数据"
118
+ }, null)
119
+ });
120
+ }
121
+ });
122
+ export {
123
+ DataGrid
124
+ };
125
+ //# sourceMappingURL=DataGrid.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.mjs","sources":["../../src/primitives/DataGrid.tsx"],"sourcesContent":["import { computed, defineComponent, type PropType } from 'vue'\nimport { NDataTable, NEmpty, type DataTableColumns } from 'naive-ui'\nimport {\n renderCell,\n type DataGridColumn,\n type DataGridProps,\n type SortState,\n} from '@fbkworks/adapter-core'\nimport { getRowKey } from '@fbkworks/shared'\n\nexport const DataGrid = defineComponent({\n name: 'FbkNaiveDataGrid',\n inheritAttrs: false,\n props: {\n columns: { type: Array as PropType<DataGridColumn<any>[]>, default: () => [] },\n data: { type: Array as PropType<any[]>, default: () => [] },\n rowKey: { type: [String, Function] as PropType<DataGridProps['rowKey']>, default: 'id' },\n loading: Boolean,\n presentation: { type: String as PropType<DataGridProps['presentation']>, default: 'auto' },\n selectionEnabled: Boolean,\n selectionWidth: { type: Number, default: 48 },\n selectedKeys: { type: Array as PropType<Array<string | number>>, default: () => [] },\n sort: { type: Object as PropType<SortState | null>, default: null },\n emptyText: String,\n rowClickable: Boolean,\n size: { type: String, default: 'md' },\n },\n emits: ['update:selectedKeys', 'update:sort', 'row-click'],\n setup(props, { attrs, emit, slots }) {\n const keyOf = (row: any, index: number) => getRowKey(row, index, props.rowKey)\n\n const naiveColumns = computed<DataTableColumns<any>>(() => {\n const result: DataTableColumns<any> = []\n if (props.selectionEnabled) {\n result.push({ type: 'selection', width: props.selectionWidth } as any)\n }\n for (const column of props.columns) {\n result.push({\n key: column.key,\n title: column.title,\n width: column.width,\n minWidth: column.minWidth,\n fixed: column.fixed,\n align: column.align,\n ellipsis: column.ellipsis\n ? { tooltip: true }\n : undefined,\n sorter: column.sortable ? 'default' : false,\n /* 数值列加 .fbk-numeric,由适配器样式给等宽数字。\n naive 的 className 落在 <td> 上。 */\n className: column.numeric ? 'fbk-numeric' : undefined,\n render: (row: any, index: number) =>\n (slots[`cell-${column.key}`]?.({ row, index, value: renderCell(column, row, index) }) ??\n renderCell(column, row, index)) as any,\n })\n }\n return result\n })\n\n const size = computed(() => (props.size === 'sm' ? 'small' : props.size === 'lg' ? 'large' : 'medium'))\n\n return () => (\n <NDataTable\n {...attrs}\n columns={naiveColumns.value}\n data={props.data}\n rowKey={(row: any) => keyOf(row, props.data.indexOf(row)) as any}\n checkedRowKeys={props.selectedKeys as any}\n loading={props.loading}\n size={size.value}\n v-slots={{\n empty: () => <NEmpty description={props.emptyText ?? '暂无数据'} />,\n }}\n onUpdate:checkedRowKeys={(keys: Array<string | number>) => emit('update:selectedKeys', keys)}\n onUpdate:sorter={(sorter: any) => {\n if (!sorter || !sorter.order) {\n emit('update:sort', null)\n return\n }\n /* 列的 key 只用于定位(sorter.columnKey 就是它),\n update:sort 的 field 取 dataIndex、缺省回退 key —— 与 element-plus 同一语义。 */\n const columnKey = String(sorter.columnKey ?? sorter.column?.key)\n const source = props.columns.find((column) => column.key === columnKey)\n emit('update:sort', {\n field: String(source?.dataIndex ?? columnKey),\n order: sorter.order === 'ascend' ? 'asc' : 'desc',\n })\n }}\n onUpdate:page={() => {}}\n rowProps={(row: any) => ({\n style: props.rowClickable ? 'cursor: pointer' : undefined,\n onClick: (event: Event) => {\n if (!props.rowClickable) return\n emit('row-click', row, props.data.indexOf(row), event)\n },\n })}\n />\n )\n },\n})\n"],"names":["DataGrid","defineComponent","name","inheritAttrs","props","columns","type","Array","default","data","rowKey","String","Function","loading","Boolean","presentation","selectionEnabled","selectionWidth","Number","selectedKeys","sort","Object","emptyText","rowClickable","size","emits","setup","attrs","emit","slots","keyOf","row","index","getRowKey","naiveColumns","computed","result","push","width","column","key","title","minWidth","fixed","align","ellipsis","tooltip","undefined","sorter","sortable","className","numeric","render","value","renderCell","_createVNode","NDataTable","_mergeProps","indexOf","keys","order","columnKey","source","find","field","dataIndex","onUpdate:page","style","onClick","event","empty","NEmpty"],"mappings":"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"}
@@ -0,0 +1,66 @@
1
+ import { PropType } from 'vue';
2
+ import { DatePickerProps, Size } from '@fbkworks/adapter-core';
3
+ export declare const DatePicker: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
+ modelValue: {
5
+ type: PropType<string | string[] | null>;
6
+ default: undefined;
7
+ };
8
+ type: {
9
+ type: PropType<DatePickerProps["type"]>;
10
+ default: string;
11
+ };
12
+ placeholder: {
13
+ type: PropType<string | [string, string]>;
14
+ default: undefined;
15
+ };
16
+ disabled: BooleanConstructor;
17
+ clearable: {
18
+ type: BooleanConstructor;
19
+ default: boolean;
20
+ };
21
+ size: {
22
+ type: PropType<Size>;
23
+ default: string;
24
+ };
25
+ uiProps: {
26
+ type: PropType<Record<string, any>>;
27
+ default: undefined;
28
+ };
29
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
30
+ modelValue: {
31
+ type: PropType<string | string[] | null>;
32
+ default: undefined;
33
+ };
34
+ type: {
35
+ type: PropType<DatePickerProps["type"]>;
36
+ default: string;
37
+ };
38
+ placeholder: {
39
+ type: PropType<string | [string, string]>;
40
+ default: undefined;
41
+ };
42
+ disabled: BooleanConstructor;
43
+ clearable: {
44
+ type: BooleanConstructor;
45
+ default: boolean;
46
+ };
47
+ size: {
48
+ type: PropType<Size>;
49
+ default: string;
50
+ };
51
+ uiProps: {
52
+ type: PropType<Record<string, any>>;
53
+ default: undefined;
54
+ };
55
+ }>> & Readonly<{
56
+ onChange?: ((...args: any[]) => any) | undefined;
57
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
58
+ }>, {
59
+ size: Size;
60
+ type: import('@fbkworks/adapter-core').DatePickerType | undefined;
61
+ disabled: boolean;
62
+ placeholder: string | [string, string];
63
+ modelValue: string | string[] | null;
64
+ clearable: boolean;
65
+ uiProps: Record<string, any>;
66
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,90 @@
1
+ import { defineComponent, computed, createVNode, mergeProps } from "vue";
2
+ import { NDatePicker } from "naive-ui";
3
+ const pad = (n) => String(n).padStart(2, "0");
4
+ function toTimestamp(value) {
5
+ if (value === null || value === void 0 || value === "") return null;
6
+ if (Array.isArray(value)) {
7
+ const [start, end] = value;
8
+ const s = start ? new Date(start.replace(" ", "T")).getTime() : null;
9
+ const e = end ? new Date(end.replace(" ", "T")).getTime() : null;
10
+ return s !== null && e !== null ? [s, e] : null;
11
+ }
12
+ const ts = new Date(value.replace(" ", "T")).getTime();
13
+ return Number.isNaN(ts) ? null : ts;
14
+ }
15
+ function formatDate(ts, type) {
16
+ const d = new Date(ts);
17
+ const ymd = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
18
+ const hms = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
19
+ if (type === "time") return hms;
20
+ if (type === "datetime" || type === "datetimerange") return `${ymd} ${hms}`;
21
+ return ymd;
22
+ }
23
+ const sizeOf = {
24
+ sm: "small",
25
+ md: "medium",
26
+ lg: "large"
27
+ };
28
+ const DatePicker = /* @__PURE__ */ defineComponent({
29
+ name: "FbkNaiveDatePicker",
30
+ inheritAttrs: false,
31
+ props: {
32
+ modelValue: {
33
+ type: [String, Array],
34
+ default: void 0
35
+ },
36
+ type: {
37
+ type: String,
38
+ default: "date"
39
+ },
40
+ placeholder: {
41
+ type: [String, Array],
42
+ default: void 0
43
+ },
44
+ disabled: Boolean,
45
+ clearable: {
46
+ type: Boolean,
47
+ default: true
48
+ },
49
+ size: {
50
+ type: String,
51
+ default: "md"
52
+ },
53
+ uiProps: {
54
+ type: Object,
55
+ default: void 0
56
+ }
57
+ },
58
+ emits: ["update:modelValue", "change"],
59
+ setup(props, {
60
+ attrs,
61
+ emit
62
+ }) {
63
+ const isRange = computed(() => props.type === "daterange" || props.type === "datetimerange");
64
+ const hasTime = computed(() => props.type === "datetime" || props.type === "datetimerange");
65
+ const isTimeOnly = computed(() => props.type === "time");
66
+ const emitValue = (value) => {
67
+ let next = null;
68
+ if (value === null) next = null;
69
+ else if (Array.isArray(value)) next = value.map((v) => formatDate(v, props.type));
70
+ else next = formatDate(value, props.type);
71
+ emit("update:modelValue", next);
72
+ emit("change", next);
73
+ };
74
+ return () => createVNode(NDatePicker, mergeProps(attrs, props.uiProps ?? {}, {
75
+ "value": toTimestamp(props.modelValue),
76
+ "type": isRange.value ? hasTime.value ? "datetimerange" : "daterange" : isTimeOnly.value ? "datetime" : hasTime.value ? "datetime" : "date",
77
+ "clearable": props.clearable,
78
+ "disabled": props.disabled,
79
+ "size": sizeOf[props.size ?? "md"],
80
+ "startPlaceholder": isRange.value ? props.placeholder?.[0] ?? "开始日期" : void 0,
81
+ "endPlaceholder": isRange.value ? props.placeholder?.[1] ?? "结束日期" : void 0,
82
+ "placeholder": isRange.value ? void 0 : props.placeholder,
83
+ "onUpdate:value": emitValue
84
+ }), null);
85
+ }
86
+ });
87
+ export {
88
+ DatePicker
89
+ };
90
+ //# sourceMappingURL=DatePicker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatePicker.mjs","sources":["../../src/primitives/DatePicker.tsx"],"sourcesContent":["import { computed, defineComponent, type PropType } from 'vue'\nimport { NDatePicker } from 'naive-ui'\nimport type { DatePickerProps, Size } from '@fbkworks/adapter-core'\n\n/**\n * 日期/时间选择。\n *\n * 与 element-plus 的关键差异:naive 的 NDatePicker **只接受时间戳(number)**,\n * 不接受字符串。所以这里必须做双向转换,否则 v-model 会静默失效\n * (控件显示为空、选择后拿不到值)。\n *\n * 转换只用本地时区,不做 UTC 换算 —— 业务侧传的是\"用户看到的日期\"。\n */\nconst pad = (n: number) => String(n).padStart(2, '0')\n\nfunction toTimestamp(value: string | string[] | null | undefined): number | [number, number] | null {\n if (value === null || value === undefined || value === '') return null\n if (Array.isArray(value)) {\n const [start, end] = value\n const s = start ? new Date(start.replace(' ', 'T')).getTime() : null\n const e = end ? new Date(end.replace(' ', 'T')).getTime() : null\n return s !== null && e !== null ? [s, e] : null\n }\n const ts = new Date(value.replace(' ', 'T')).getTime()\n return Number.isNaN(ts) ? null : ts\n}\n\nfunction formatDate(ts: number, type: string): string {\n const d = new Date(ts)\n const ymd = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`\n const hms = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`\n if (type === 'time') return hms\n if (type === 'datetime' || type === 'datetimerange') return `${ymd} ${hms}`\n return ymd\n}\n\nconst sizeOf = { sm: 'small', md: 'medium', lg: 'large' } as const\n\nexport const DatePicker = defineComponent({\n name: 'FbkNaiveDatePicker',\n inheritAttrs: false,\n props: {\n modelValue: { type: [String, Array] as PropType<string | string[] | null>, default: undefined },\n type: { type: String as PropType<DatePickerProps['type']>, default: 'date' },\n placeholder: { type: [String, Array] as PropType<string | [string, string]>, default: undefined },\n disabled: Boolean,\n clearable: { type: Boolean, default: true },\n size: { type: String as PropType<Size>, default: 'md' },\n uiProps: { type: Object as PropType<Record<string, any>>, default: undefined },\n },\n emits: ['update:modelValue', 'change'],\n setup(props, { attrs, emit }) {\n const isRange = computed(() => props.type === 'daterange' || props.type === 'datetimerange')\n const hasTime = computed(() => props.type === 'datetime' || props.type === 'datetimerange')\n const isTimeOnly = computed(() => props.type === 'time')\n\n const emitValue = (value: number | [number, number] | null) => {\n let next: string | string[] | null = null\n if (value === null) next = null\n else if (Array.isArray(value)) next = value.map((v) => formatDate(v, props.type!))\n else next = formatDate(value, props.type!)\n emit('update:modelValue', next)\n emit('change', next)\n }\n\n return () => (\n <NDatePicker\n {...attrs}\n {...(props.uiProps ?? {})}\n value={toTimestamp(props.modelValue)}\n /* naive 的 NDatePicker 没有 'time' 这一档,纯时间场景用 datetime 面板\n 并靠 format 只显示时分(见 uiProps.format 约定)。\n 强转类型是因为契约的 DatePickerType 比 naive 的枚举宽。 */\n type={\n (isRange.value\n ? hasTime.value\n ? 'datetimerange'\n : 'daterange'\n : isTimeOnly.value\n ? 'datetime'\n : hasTime.value\n ? 'datetime'\n : 'date') as any\n }\n clearable={props.clearable}\n disabled={props.disabled}\n size={sizeOf[props.size ?? 'md']}\n /* naive 的 range 模式用 start/end 占位符;单值用 placeholder */\n startPlaceholder={isRange.value ? (props.placeholder as [string, string])?.[0] ?? '开始日期' : undefined}\n endPlaceholder={isRange.value ? (props.placeholder as [string, string])?.[1] ?? '结束日期' : undefined}\n placeholder={isRange.value ? undefined : (props.placeholder as string)}\n onUpdate:value={emitValue}\n />\n )\n },\n})\n"],"names":["pad","n","String","padStart","toTimestamp","value","undefined","Array","isArray","start","end","s","Date","replace","getTime","e","ts","Number","isNaN","formatDate","type","d","ymd","getFullYear","getMonth","getDate","hms","getHours","getMinutes","getSeconds","sizeOf","sm","md","lg","DatePicker","defineComponent","name","inheritAttrs","props","modelValue","default","placeholder","disabled","Boolean","clearable","size","uiProps","Object","emits","setup","attrs","emit","isRange","computed","hasTime","isTimeOnly","emitValue","next","map","v","_createVNode","NDatePicker","_mergeProps"],"mappings":"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"}
@@ -0,0 +1,57 @@
1
+ import { PropType } from 'vue';
2
+ import { DialogProps } from '@fbkworks/adapter-core';
3
+ /**
4
+ * placement 必须真的生效(此前这个适配器完全不读它,属于审查 B12)。
5
+ *
6
+ * naive 的 NModal 把内容放进 .n-modal-scroll-content,那是个 flex 容器,
7
+ * 卡片位置由 align-self 决定:center 保持库默认的居中,bottom 用 flex-end
8
+ * 把卡片压到视口底部并铺满宽度 —— 也就是贴底弹层。
9
+ */
10
+ export declare const Dialog: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
11
+ modelValue: BooleanConstructor;
12
+ title: StringConstructor;
13
+ width: {
14
+ type: PropType<string | number>;
15
+ default: string;
16
+ };
17
+ placement: {
18
+ type: PropType<DialogProps["placement"]>;
19
+ default: string;
20
+ };
21
+ closeOnClickModal: {
22
+ type: BooleanConstructor;
23
+ default: boolean;
24
+ };
25
+ showClose: {
26
+ type: BooleanConstructor;
27
+ default: boolean;
28
+ };
29
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
30
+ modelValue: BooleanConstructor;
31
+ title: StringConstructor;
32
+ width: {
33
+ type: PropType<string | number>;
34
+ default: string;
35
+ };
36
+ placement: {
37
+ type: PropType<DialogProps["placement"]>;
38
+ default: string;
39
+ };
40
+ closeOnClickModal: {
41
+ type: BooleanConstructor;
42
+ default: boolean;
43
+ };
44
+ showClose: {
45
+ type: BooleanConstructor;
46
+ default: boolean;
47
+ };
48
+ }>> & Readonly<{
49
+ onClose?: ((...args: any[]) => any) | undefined;
50
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
51
+ }>, {
52
+ modelValue: boolean;
53
+ placement: "center" | "bottom" | undefined;
54
+ width: string | number;
55
+ closeOnClickModal: boolean;
56
+ showClose: boolean;
57
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,64 @@
1
+ import { defineComponent, createVNode, mergeProps } from "vue";
2
+ import { NModal, NCard } from "naive-ui";
3
+ const toCssSize = (value) => typeof value === "number" ? `${value}px` : value;
4
+ const Dialog = /* @__PURE__ */ defineComponent({
5
+ name: "FbkNaiveDialog",
6
+ inheritAttrs: false,
7
+ props: {
8
+ modelValue: Boolean,
9
+ title: String,
10
+ width: {
11
+ type: [String, Number],
12
+ default: "520px"
13
+ },
14
+ placement: {
15
+ type: String,
16
+ default: "center"
17
+ },
18
+ closeOnClickModal: {
19
+ type: Boolean,
20
+ default: true
21
+ },
22
+ showClose: {
23
+ type: Boolean,
24
+ default: true
25
+ }
26
+ },
27
+ emits: ["update:modelValue", "close"],
28
+ setup(props, {
29
+ attrs,
30
+ emit,
31
+ slots
32
+ }) {
33
+ return () => {
34
+ const bottom = props.placement === "bottom";
35
+ const cardStyle = bottom ? {
36
+ width: "100%",
37
+ alignSelf: "flex-end"
38
+ } : {
39
+ width: toCssSize(props.width)
40
+ };
41
+ return createVNode(NModal, mergeProps(attrs, {
42
+ "show": props.modelValue,
43
+ "maskClosable": props.closeOnClickModal,
44
+ "onUpdate:show": (value) => emit("update:modelValue", value),
45
+ "onAfterLeave": () => emit("close")
46
+ }), {
47
+ default: () => createVNode(NCard, {
48
+ "class": bottom ? "fbk-naive-dialog--bottom" : void 0,
49
+ "style": cardStyle,
50
+ "title": props.title,
51
+ "closable": props.showClose,
52
+ "onClose": () => emit("update:modelValue", false)
53
+ }, {
54
+ default: slots.default,
55
+ footer: slots.footer
56
+ })
57
+ });
58
+ };
59
+ }
60
+ });
61
+ export {
62
+ Dialog
63
+ };
64
+ //# sourceMappingURL=Dialog.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.mjs","sources":["../../src/primitives/Dialog.tsx"],"sourcesContent":["import { defineComponent, type CSSProperties, type PropType } from 'vue'\nimport { NModal, NCard } from 'naive-ui'\nimport type { DialogProps } from '@fbkworks/adapter-core'\n\nconst toCssSize = (value: string | number) => (typeof value === 'number' ? `${value}px` : value)\n\n/**\n * placement 必须真的生效(此前这个适配器完全不读它,属于审查 B12)。\n *\n * naive 的 NModal 把内容放进 .n-modal-scroll-content,那是个 flex 容器,\n * 卡片位置由 align-self 决定:center 保持库默认的居中,bottom 用 flex-end\n * 把卡片压到视口底部并铺满宽度 —— 也就是贴底弹层。\n */\nexport const Dialog = defineComponent({\n name: 'FbkNaiveDialog',\n inheritAttrs: false,\n props: {\n modelValue: Boolean,\n title: String,\n width: { type: [String, Number] as PropType<string | number>, default: '520px' },\n placement: { type: String as PropType<DialogProps['placement']>, default: 'center' },\n closeOnClickModal: { type: Boolean, default: true },\n showClose: { type: Boolean, default: true },\n },\n emits: ['update:modelValue', 'close'],\n setup(props, { attrs, emit, slots }) {\n return () => {\n const bottom = props.placement === 'bottom'\n const cardStyle: CSSProperties = bottom\n ? { width: '100%', alignSelf: 'flex-end' }\n : { width: toCssSize(props.width) }\n return (\n <NModal\n {...attrs}\n show={props.modelValue}\n maskClosable={props.closeOnClickModal}\n onUpdate:show={(value: boolean) => emit('update:modelValue', value)}\n onAfterLeave={() => emit('close')}\n v-slots={{\n default: () => (\n <NCard\n class={bottom ? 'fbk-naive-dialog--bottom' : undefined}\n style={cardStyle}\n title={props.title}\n closable={props.showClose}\n onClose={() => emit('update:modelValue', false)}\n >\n {{\n default: slots.default,\n footer: slots.footer,\n }}\n </NCard>\n ),\n }}\n />\n )\n }\n },\n})\n"],"names":["toCssSize","value","Dialog","defineComponent","name","inheritAttrs","props","modelValue","Boolean","title","String","width","type","Number","default","placement","closeOnClickModal","showClose","emits","setup","attrs","emit","slots","bottom","cardStyle","alignSelf","_createVNode","NModal","_mergeProps","onAfterLeave","NCard","undefined","onClose","footer"],"mappings":";;AAIA,MAAMA,YAAaC,WAA4B,OAAOA,UAAU,WAAW,GAAGA,KAAK,OAAOA;AASnF,MAAMC,SAASC,gCAAgB;AAAA,EACpCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAYC;AAAAA,IACZC,OAAOC;AAAAA,IACPC,OAAO;AAAA,MAAEC,MAAM,CAACF,QAAQG,MAAM;AAAA,MAAgCC,SAAS;AAAA;IACvEC,WAAW;AAAA,MAAEH,MAAMF;AAAAA,MAA8CI,SAAS;AAAA;IAC1EE,mBAAmB;AAAA,MAAEJ,MAAMJ;AAAAA,MAASM,SAAS;AAAA;IAC7CG,WAAW;AAAA,MAAEL,MAAMJ;AAAAA,MAASM,SAAS;AAAA,IAAK;AAAA;EAE5CI,OAAO,CAAC,qBAAqB,OAAO;AAAA,EACpCC,MAAMb,OAAO;AAAA,IAAEc;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,WAAO,MAAM;AACX,YAAMC,SAASjB,MAAMS,cAAc;AACnC,YAAMS,YAA2BD,SAC7B;AAAA,QAAEZ,OAAO;AAAA,QAAQc,WAAW;AAAA,MAAW,IACvC;AAAA,QAAEd,OAAOX,UAAUM,MAAMK,KAAK;AAAA;AAClC,aAAAe,YAAAC,QAAAC,WAEQR,OAAK;AAAA,QAAA,QACHd,MAAMC;AAAAA,QAAU,gBACRD,MAAMU;AAAAA,QAAiB,iBACrBf,WAAmBoB,KAAK,qBAAqBpB,KAAK;AAAA,QAAC,gBACrD4B,MAAMR,KAAK,OAAO;AAAA,OAAC,GACxB;AAAA,QACPP,SAASA,MAAAY,YAAAI,OAAA;AAAA,UAAA,SAEEP,SAAS,6BAA6BQ;AAAAA,UAAS,SAC/CP;AAAAA,UAAS,SACTlB,MAAMG;AAAAA,UAAK,YACRH,MAAMW;AAAAA,UAAS,WAChBe,MAAMX,KAAK,qBAAqB,KAAK;AAAA,QAAC,GAAA;AAAA,UAG7CP,SAASQ,MAAMR;AAAAA,UACfmB,QAAQX,MAAMW;AAAAA,QAAM,CAAA;AAAA,OAI3B;AAAA,IAGP;AAAA,EACF;AACF,CAAC;"}
@@ -0,0 +1,57 @@
1
+ import { PropType } from 'vue';
2
+ import { DrawerProps } from '@fbkworks/adapter-core';
3
+ /**
4
+ * naive 的 NDrawer 只有 direction 与尺寸,没有标题栏:标题与关闭按钮由
5
+ * NDrawerContent 提供(closable),点它内部走 doUpdateShow(false),
6
+ * 也就是 update:show —— 这里再翻译成契约里的 update:modelValue(false)。
7
+ *
8
+ * bottom 方向用 height 控制尺寸,宽度由 naive 自己铺满 = 移动端全屏。
9
+ */
10
+ export declare const Drawer: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
11
+ modelValue: BooleanConstructor;
12
+ title: StringConstructor;
13
+ width: {
14
+ type: PropType<string | number>;
15
+ default: string;
16
+ };
17
+ placement: {
18
+ type: PropType<DrawerProps["placement"]>;
19
+ default: string;
20
+ };
21
+ closeOnClickModal: {
22
+ type: BooleanConstructor;
23
+ default: boolean;
24
+ };
25
+ showClose: {
26
+ type: BooleanConstructor;
27
+ default: boolean;
28
+ };
29
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
30
+ modelValue: BooleanConstructor;
31
+ title: StringConstructor;
32
+ width: {
33
+ type: PropType<string | number>;
34
+ default: string;
35
+ };
36
+ placement: {
37
+ type: PropType<DrawerProps["placement"]>;
38
+ default: string;
39
+ };
40
+ closeOnClickModal: {
41
+ type: BooleanConstructor;
42
+ default: boolean;
43
+ };
44
+ showClose: {
45
+ type: BooleanConstructor;
46
+ default: boolean;
47
+ };
48
+ }>> & Readonly<{
49
+ onClose?: ((...args: any[]) => any) | undefined;
50
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
51
+ }>, {
52
+ modelValue: boolean;
53
+ placement: "bottom" | "right" | undefined;
54
+ width: string | number;
55
+ closeOnClickModal: boolean;
56
+ showClose: boolean;
57
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,58 @@
1
+ import { defineComponent, createVNode, mergeProps } from "vue";
2
+ import { NDrawer, NDrawerContent } from "naive-ui";
3
+ const Drawer = /* @__PURE__ */ defineComponent({
4
+ name: "FbkNaiveDrawer",
5
+ inheritAttrs: false,
6
+ props: {
7
+ modelValue: Boolean,
8
+ title: String,
9
+ width: {
10
+ type: [String, Number],
11
+ default: "480px"
12
+ },
13
+ placement: {
14
+ type: String,
15
+ default: "right"
16
+ },
17
+ closeOnClickModal: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ showClose: {
22
+ type: Boolean,
23
+ default: true
24
+ }
25
+ },
26
+ emits: ["update:modelValue", "close"],
27
+ setup(props, {
28
+ attrs,
29
+ emit,
30
+ slots
31
+ }) {
32
+ return () => {
33
+ const bottom = props.placement === "bottom";
34
+ return createVNode(NDrawer, mergeProps(attrs, {
35
+ "show": props.modelValue,
36
+ "placement": bottom ? "bottom" : "right",
37
+ "width": bottom ? void 0 : props.width,
38
+ "height": bottom ? "100%" : void 0,
39
+ "maskClosable": props.closeOnClickModal,
40
+ "to": "body",
41
+ "onUpdate:show": (value) => emit("update:modelValue", value),
42
+ "onAfterLeave": () => emit("close")
43
+ }), {
44
+ default: () => [createVNode(NDrawerContent, {
45
+ "title": props.title,
46
+ "closable": props.showClose
47
+ }, {
48
+ default: slots.default,
49
+ footer: slots.footer
50
+ })]
51
+ });
52
+ };
53
+ }
54
+ });
55
+ export {
56
+ Drawer
57
+ };
58
+ //# sourceMappingURL=Drawer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer.mjs","sources":["../../src/primitives/Drawer.tsx"],"sourcesContent":["import { defineComponent, type PropType } from 'vue'\nimport { NDrawer, NDrawerContent } from 'naive-ui'\nimport type { DrawerProps } from '@fbkworks/adapter-core'\n\n/**\n * naive 的 NDrawer 只有 direction 与尺寸,没有标题栏:标题与关闭按钮由\n * NDrawerContent 提供(closable),点它内部走 doUpdateShow(false),\n * 也就是 update:show —— 这里再翻译成契约里的 update:modelValue(false)。\n *\n * bottom 方向用 height 控制尺寸,宽度由 naive 自己铺满 = 移动端全屏。\n */\nexport const Drawer = defineComponent({\n name: 'FbkNaiveDrawer',\n inheritAttrs: false,\n props: {\n modelValue: Boolean,\n title: String,\n width: { type: [String, Number] as PropType<string | number>, default: '480px' },\n placement: { type: String as PropType<DrawerProps['placement']>, default: 'right' },\n closeOnClickModal: { type: Boolean, default: true },\n showClose: { type: Boolean, default: true },\n },\n emits: ['update:modelValue', 'close'],\n setup(props, { attrs, emit, slots }) {\n return () => {\n const bottom = props.placement === 'bottom'\n return (\n <NDrawer\n {...attrs}\n show={props.modelValue}\n placement={bottom ? 'bottom' : 'right'}\n width={bottom ? undefined : props.width}\n height={bottom ? '100%' : undefined}\n maskClosable={props.closeOnClickModal}\n to=\"body\"\n onUpdate:show={(value: boolean) => emit('update:modelValue', value)}\n onAfterLeave={() => emit('close')}\n >\n <NDrawerContent title={props.title} closable={props.showClose}>\n {{ default: slots.default, footer: slots.footer }}\n </NDrawerContent>\n </NDrawer>\n )\n }\n },\n})\n"],"names":["Drawer","defineComponent","name","inheritAttrs","props","modelValue","Boolean","title","String","width","type","Number","default","placement","closeOnClickModal","showClose","emits","setup","attrs","emit","slots","bottom","_createVNode","NDrawer","_mergeProps","undefined","value","onAfterLeave","NDrawerContent","footer"],"mappings":";;AAWO,MAAMA,SAASC,gCAAgB;AAAA,EACpCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAYC;AAAAA,IACZC,OAAOC;AAAAA,IACPC,OAAO;AAAA,MAAEC,MAAM,CAACF,QAAQG,MAAM;AAAA,MAAgCC,SAAS;AAAA;IACvEC,WAAW;AAAA,MAAEH,MAAMF;AAAAA,MAA8CI,SAAS;AAAA;IAC1EE,mBAAmB;AAAA,MAAEJ,MAAMJ;AAAAA,MAASM,SAAS;AAAA;IAC7CG,WAAW;AAAA,MAAEL,MAAMJ;AAAAA,MAASM,SAAS;AAAA,IAAK;AAAA;EAE5CI,OAAO,CAAC,qBAAqB,OAAO;AAAA,EACpCC,MAAMb,OAAO;AAAA,IAAEc;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,WAAO,MAAM;AACX,YAAMC,SAASjB,MAAMS,cAAc;AACnC,aAAAS,YAAAC,SAAAC,WAEQN,OAAK;AAAA,QAAA,QACHd,MAAMC;AAAAA,QAAU,aACXgB,SAAS,WAAW;AAAA,QAAO,SAC/BA,SAASI,SAAYrB,MAAMK;AAAAA,QAAK,UAC/BY,SAAS,SAASI;AAAAA,QAAS,gBACrBrB,MAAMU;AAAAA,QAAiB,MAAA;AAAA,QAAA,iBAErBY,WAAmBP,KAAK,qBAAqBO,KAAK;AAAA,QAAC,gBACrDC,MAAMR,KAAK,OAAO;AAAA,MAAC,CAAA,GAAA;AAAA,QAAAP,SAAAA,MAAA,CAAAU,YAAAM,gBAAA;AAAA,UAAA,SAEVxB,MAAMG;AAAAA,UAAK,YAAYH,MAAMW;AAAAA,QAAS,GAAA;AAAA,UACxDH,SAASQ,MAAMR;AAAAA,UAASiB,QAAQT,MAAMS;AAAAA,QAAM,CAAA,CAAA;AAAA,MAAA,CAAA;AAAA,IAIvD;AAAA,EACF;AACF,CAAC;"}
@@ -0,0 +1,13 @@
1
+ export declare const Empty: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ description: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
7
+ description: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ };
11
+ }>> & Readonly<{}>, {
12
+ description: string;
13
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,26 @@
1
+ import { defineComponent, createVNode, mergeProps } from "vue";
2
+ import { NEmpty } from "naive-ui";
3
+ const Empty = /* @__PURE__ */ defineComponent({
4
+ name: "FbkNaiveEmpty",
5
+ inheritAttrs: false,
6
+ props: {
7
+ description: {
8
+ type: String,
9
+ default: "暂无数据"
10
+ }
11
+ },
12
+ setup(props, {
13
+ attrs,
14
+ slots
15
+ }) {
16
+ return () => createVNode(NEmpty, mergeProps(attrs, {
17
+ "description": props.description
18
+ }), {
19
+ default: () => [slots.default?.()]
20
+ });
21
+ }
22
+ });
23
+ export {
24
+ Empty
25
+ };
26
+ //# sourceMappingURL=Empty.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Empty.mjs","sources":["../../src/primitives/Empty.tsx"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { NEmpty } from 'naive-ui'\n\nexport const Empty = defineComponent({\n name: 'FbkNaiveEmpty',\n inheritAttrs: false,\n props: { description: { type: String, default: '暂无数据' } },\n setup(props, { attrs, slots }) {\n return () => (\n <NEmpty {...attrs} description={props.description}>\n {slots.default?.()}\n </NEmpty>\n )\n },\n})\n"],"names":["Empty","defineComponent","name","inheritAttrs","props","description","type","String","default","setup","attrs","slots","_createVNode","NEmpty","_mergeProps"],"mappings":";;AAGO,MAAMA,QAAQC,gCAAgB;AAAA,EACnCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IAAEC,aAAa;AAAA,MAAEC,MAAMC;AAAAA,MAAQC,SAAS;AAAA,IAAO;AAAA;EACtDC,MAAML,OAAO;AAAA,IAAEM;AAAAA,IAAOC;AAAAA,EAAM,GAAG;AAC7B,WAAO,MAAAC,YAAAC,QAAAC,WACOJ,OAAK;AAAA,MAAA,eAAeN,MAAMC;AAAAA,IAAW,CAAA,GAAA;AAAA,MAAAG,SAAAA,MAAA,CAC9CG,MAAMH,UAAO,CAAI;AAAA,KAAA;AAAA,EAGxB;AACF,CAAC;"}