@shwfed/config 3.0.11 → 3.0.13

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 (98) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/config/blocks/2026-06-17/com.shwfed.block.tree.single/config.d.vue.ts +18 -18
  3. package/dist/runtime/components/config/blocks/2026-06-17/com.shwfed.block.tree.single/config.vue.d.ts +18 -18
  4. package/dist/runtime/components/config/blocks/2026-06-17/com.shwfed.block.tree.single/runtime.d.vue.ts +18 -18
  5. package/dist/runtime/components/config/blocks/2026-06-17/com.shwfed.block.tree.single/runtime.vue.d.ts +18 -18
  6. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/config.d.vue.ts +86 -0
  7. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/config.vue +376 -0
  8. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/config.vue.d.ts +86 -0
  9. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/items-colgroup.d.vue.ts +3 -0
  10. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/items-colgroup.vue +20 -0
  11. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/items-colgroup.vue.d.ts +3 -0
  12. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/runtime.d.vue.ts +86 -0
  13. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/runtime.vue +146 -0
  14. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/runtime.vue.d.ts +86 -0
  15. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/schema.d.ts +84 -0
  16. package/dist/runtime/components/config/blocks/2026-07-17/com.shwfed.block.invoice.digital/schema.js +165 -0
  17. package/dist/runtime/components/config/index.d.vue.ts +2 -2
  18. package/dist/runtime/components/config/index.vue.d.ts +2 -2
  19. package/dist/runtime/components/form/fields/2026-04-24/com.shwfed.form.field.combobox.single/config.d.vue.ts +16 -16
  20. package/dist/runtime/components/form/fields/2026-04-24/com.shwfed.form.field.combobox.single/config.vue.d.ts +16 -16
  21. package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/config.d.vue.ts +6 -6
  22. package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/config.vue.d.ts +6 -6
  23. package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/config.d.vue.ts +8 -8
  24. package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/config.vue.d.ts +8 -8
  25. package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/config.d.vue.ts +2 -2
  26. package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/config.vue.d.ts +2 -2
  27. package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.combobox.single.remote/config.d.vue.ts +16 -16
  28. package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.combobox.single.remote/config.vue.d.ts +16 -16
  29. package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.d.vue.ts +26 -26
  30. package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.vue.d.ts +26 -26
  31. package/dist/runtime/components/form/fields/2026-05-24/com.shwfed.form.field.monthrange/config.d.vue.ts +6 -6
  32. package/dist/runtime/components/form/fields/2026-05-24/com.shwfed.form.field.monthrange/config.vue.d.ts +6 -6
  33. package/dist/runtime/components/form/fields/2026-05-25/com.shwfed.form.field.combobox.multi/config.d.vue.ts +16 -16
  34. package/dist/runtime/components/form/fields/2026-05-25/com.shwfed.form.field.combobox.multi/config.vue.d.ts +16 -16
  35. package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.multi/config.d.vue.ts +26 -26
  36. package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.multi/config.vue.d.ts +26 -26
  37. package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.single/config.d.vue.ts +26 -26
  38. package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.single/config.vue.d.ts +26 -26
  39. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.d.vue.ts +26 -26
  40. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.vue.d.ts +26 -26
  41. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.d.vue.ts +26 -26
  42. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.vue.d.ts +26 -26
  43. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.d.vue.ts +26 -26
  44. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.vue.d.ts +26 -26
  45. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.d.vue.ts +26 -26
  46. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.vue.d.ts +26 -26
  47. package/dist/runtime/components/form/utils/validation.js +9 -7
  48. package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-multi/config.d.vue.ts +8 -8
  49. package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-multi/config.vue.d.ts +8 -8
  50. package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-single/config.d.vue.ts +8 -8
  51. package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-single/config.vue.d.ts +8 -8
  52. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/config.d.vue.ts +8 -8
  53. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/config.vue.d.ts +8 -8
  54. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/config.d.vue.ts +8 -8
  55. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/config.vue.d.ts +8 -8
  56. package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-multi/config.d.vue.ts +8 -8
  57. package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-multi/config.vue.d.ts +8 -8
  58. package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-single/config.d.vue.ts +8 -8
  59. package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-single/config.vue.d.ts +8 -8
  60. package/dist/runtime/components/table/columns/2026-07-16/com.shwfed.table.column.upload/config.vue +57 -247
  61. package/dist/runtime/components/table/columns/2026-07-16/com.shwfed.table.column.upload/prompt.md +2 -2
  62. package/dist/runtime/components/table/columns/2026-07-16/com.shwfed.table.column.upload/runtime.vue +21 -124
  63. package/dist/runtime/components/table/columns/2026-07-16/com.shwfed.table.column.upload/schema.d.ts +5 -27
  64. package/dist/runtime/components/table/columns/2026-07-16/com.shwfed.table.column.upload/schema.js +10 -37
  65. package/dist/runtime/components/ui/date-picker/DatePickerInput.d.vue.ts +1 -1
  66. package/dist/runtime/components/ui/date-picker/DatePickerInput.vue.d.ts +1 -1
  67. package/dist/runtime/components/ui/date-picker/DatePickerTimeInput.d.vue.ts +1 -1
  68. package/dist/runtime/components/ui/date-picker/DatePickerTimeInput.vue.d.ts +1 -1
  69. package/dist/runtime/components/ui/date-range-picker/DateRangePickerInput.d.vue.ts +1 -1
  70. package/dist/runtime/components/ui/date-range-picker/DateRangePickerInput.vue.d.ts +1 -1
  71. package/dist/runtime/components/ui/date-range-picker/DateRangePickerTimeInput.d.vue.ts +2 -2
  72. package/dist/runtime/components/ui/date-range-picker/DateRangePickerTimeInput.vue.d.ts +2 -2
  73. package/dist/runtime/components/ui/invoice/InvoiceSheet.d.vue.ts +66 -0
  74. package/dist/runtime/components/ui/invoice/InvoiceSheet.vue +182 -0
  75. package/dist/runtime/components/ui/invoice/InvoiceSheet.vue.d.ts +66 -0
  76. package/dist/runtime/components/ui/invoice/index.d.ts +1 -0
  77. package/dist/runtime/components/ui/invoice/index.js +1 -0
  78. package/dist/runtime/components/ui/invoice-config/InvoiceConfigShell.d.vue.ts +36 -0
  79. package/dist/runtime/components/ui/invoice-config/InvoiceConfigShell.vue +41 -0
  80. package/dist/runtime/components/ui/invoice-config/InvoiceConfigShell.vue.d.ts +36 -0
  81. package/dist/runtime/components/ui/invoice-config/InvoiceExprField.d.vue.ts +14 -0
  82. package/dist/runtime/components/ui/invoice-config/InvoiceExprField.vue +39 -0
  83. package/dist/runtime/components/ui/invoice-config/InvoiceExprField.vue.d.ts +14 -0
  84. package/dist/runtime/components/ui/invoice-config/InvoiceJsonScope.d.vue.ts +13 -0
  85. package/dist/runtime/components/ui/invoice-config/InvoiceJsonScope.vue +19 -0
  86. package/dist/runtime/components/ui/invoice-config/InvoiceJsonScope.vue.d.ts +13 -0
  87. package/dist/runtime/components/ui/invoice-config/InvoiceRowScope.d.vue.ts +13 -0
  88. package/dist/runtime/components/ui/invoice-config/InvoiceRowScope.vue +22 -0
  89. package/dist/runtime/components/ui/invoice-config/InvoiceRowScope.vue.d.ts +13 -0
  90. package/dist/runtime/components/ui/invoice-config/index.d.ts +4 -0
  91. package/dist/runtime/components/ui/invoice-config/index.js +4 -0
  92. package/dist/runtime/share/invoice-eval.d.ts +13 -0
  93. package/dist/runtime/share/invoice-eval.js +88 -0
  94. package/dist/runtime/share/invoice.d.ts +68 -0
  95. package/dist/runtime/share/invoice.js +35 -0
  96. package/dist/runtime/share/rmb.d.ts +11 -0
  97. package/dist/runtime/share/rmb.js +58 -0
  98. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ <script setup>
2
+ import { ExpressionEditor } from "../expression-editor";
3
+ import { Field, FieldLabel } from "../field";
4
+ import { Markdown } from "../markdown";
5
+ defineOptions({ name: "ShwfedInvoiceExprField" });
6
+ defineProps({
7
+ label: { type: String, required: true },
8
+ description: { type: String, required: false },
9
+ modelValue: { type: String, required: true },
10
+ placeholder: { type: String, required: false },
11
+ multiline: { type: Boolean, required: false }
12
+ });
13
+ defineEmits(["update:modelValue"]);
14
+ </script>
15
+
16
+ <template>
17
+ <Field orientation="vertical">
18
+ <FieldLabel class="text-xs text-zinc-500">
19
+ <template
20
+ v-if="description"
21
+ #tooltip
22
+ >
23
+ <Markdown
24
+ :source="description"
25
+ block
26
+ class="prose prose-sm prose-zinc"
27
+ />
28
+ </template>
29
+ {{ label }}
30
+ </FieldLabel>
31
+ <ExpressionEditor
32
+ :model-value="modelValue"
33
+ :placeholder="placeholder"
34
+ :multiline="multiline"
35
+ :class="multiline ? 'min-h-16' : void 0"
36
+ @update:model-value="(v) => $emit('update:modelValue', v)"
37
+ />
38
+ </Field>
39
+ </template>
@@ -0,0 +1,14 @@
1
+ type __VLS_Props = {
2
+ label: string;
3
+ description?: string;
4
+ modelValue: string;
5
+ placeholder?: string;
6
+ multiline?: boolean;
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
+ "update:modelValue": (payload: string) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:modelValue"?: ((payload: string) => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
@@ -0,0 +1,13 @@
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
@@ -0,0 +1,19 @@
1
+ <script setup>
2
+ import { injectCELContext, provideCELContext } from "../../../utils/cel-context";
3
+ import { JSON_VAR } from "../../../share/invoice";
4
+ defineOptions({ name: "ShwfedInvoiceJsonScope" });
5
+ if (!injectCELContext().json) {
6
+ provideCELContext({
7
+ json: {
8
+ type: JSON_VAR.type,
9
+ label: JSON_VAR.label,
10
+ description: JSON_VAR.description,
11
+ value: void 0
12
+ }
13
+ });
14
+ }
15
+ </script>
16
+
17
+ <template>
18
+ <slot />
19
+ </template>
@@ -0,0 +1,13 @@
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
@@ -0,0 +1,13 @@
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
@@ -0,0 +1,22 @@
1
+ <script setup>
2
+ import { provideCELContext } from "../../../utils/cel-context";
3
+ defineOptions({ name: "ShwfedInvoiceRowScope" });
4
+ provideCELContext({
5
+ item: {
6
+ type: "dyn",
7
+ label: "item",
8
+ description: "\u5F53\u524D\u660E\u7EC6\u9879",
9
+ value: void 0
10
+ },
11
+ index: {
12
+ type: "number",
13
+ label: "index",
14
+ description: "\u5F53\u524D\u660E\u7EC6\u9879\u5E8F\u53F7\uFF0C\u4ECE 0 \u5F00\u59CB",
15
+ value: void 0
16
+ }
17
+ });
18
+ </script>
19
+
20
+ <template>
21
+ <slot />
22
+ </template>
@@ -0,0 +1,13 @@
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
@@ -0,0 +1,4 @@
1
+ export { default as InvoiceConfigShell } from './InvoiceConfigShell.vue.js';
2
+ export { default as InvoiceExprField } from './InvoiceExprField.vue.js';
3
+ export { default as InvoiceJsonScope } from './InvoiceJsonScope.vue.js';
4
+ export { default as InvoiceRowScope } from './InvoiceRowScope.vue.js';
@@ -0,0 +1,4 @@
1
+ export { default as InvoiceConfigShell } from "./InvoiceConfigShell.vue";
2
+ export { default as InvoiceExprField } from "./InvoiceExprField.vue";
3
+ export { default as InvoiceJsonScope } from "./InvoiceJsonScope.vue";
4
+ export { default as InvoiceRowScope } from "./InvoiceRowScope.vue";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @param requestExpr 读「请求」表达式的 getter(可选字段,未配置时返回 `undefined`)。
3
+ * getter 而不是值 —— 编辑器里改表达式要能重取,composable 自己 watch 它。
4
+ */
5
+ export declare function useInvoiceEval(requestExpr: () => string | undefined): {
6
+ json: import("vue").Ref<unknown, unknown>;
7
+ evaluate: (expression: string | undefined, scope?: Record<string, unknown>) => unknown;
8
+ text: (expression: string | undefined, scope?: Record<string, unknown>) => string;
9
+ money: (expression: string | undefined, scope?: Record<string, unknown>) => string;
10
+ plain: (expression: string | undefined, scope?: Record<string, unknown>) => string;
11
+ bool: (expression: string | undefined, scope?: Record<string, unknown>) => boolean;
12
+ capital: (expression: string | undefined) => string;
13
+ };
@@ -0,0 +1,88 @@
1
+ import { computed, onMounted, ref, watch } from "vue";
2
+ import { Effect, Option } from "effect";
3
+ import { Fetch } from "fx-fetch";
4
+ import { cel } from "../utils/cel.js";
5
+ import { celBindings, injectCELContext } from "../utils/cel-context.js";
6
+ import { fetchJsonOption } from "./request.js";
7
+ import { toCapital } from "./rmb.js";
8
+ const MONEY_FORMAT = new Intl.NumberFormat("zh-CN", {
9
+ minimumFractionDigits: 2,
10
+ maximumFractionDigits: 2
11
+ });
12
+ function toFiniteNumber(v) {
13
+ if (typeof v === "number") return Number.isFinite(v) ? v : null;
14
+ if (typeof v === "string" && v.trim() !== "") {
15
+ const n = Number(v);
16
+ return Number.isFinite(n) ? n : null;
17
+ }
18
+ return null;
19
+ }
20
+ export function useInvoiceEval(requestExpr) {
21
+ const inheritedContext = injectCELContext();
22
+ const json = ref(void 0);
23
+ const jsonOption = computed(
24
+ () => json.value === void 0 ? Option.none() : Option.some(json.value)
25
+ );
26
+ const hasRequest = computed(() => {
27
+ const expr = requestExpr();
28
+ return !!expr && expr.trim().length > 0;
29
+ });
30
+ function baseContext() {
31
+ const inherited = celBindings(inheritedContext);
32
+ if (!hasRequest.value && "json" in inherited) return inherited;
33
+ return { ...inherited, json: jsonOption.value };
34
+ }
35
+ async function refresh() {
36
+ const expr = requestExpr();
37
+ if (!expr || expr.trim().length === 0) {
38
+ json.value = void 0;
39
+ return;
40
+ }
41
+ const program = Effect.gen(function* () {
42
+ const body = yield* fetchJsonOption(
43
+ yield* cel(expr, celBindings(inheritedContext))
44
+ );
45
+ return Option.getOrUndefined(body);
46
+ });
47
+ try {
48
+ json.value = await Effect.runPromise(Effect.provide(program, Fetch.layer));
49
+ } catch (err) {
50
+ console.warn("[shwfed-invoice] request failed", err);
51
+ json.value = void 0;
52
+ }
53
+ }
54
+ onMounted(() => void refresh());
55
+ watch(() => requestExpr() ?? "", () => void refresh());
56
+ function evaluate(expression, scope) {
57
+ if (!expression || expression.trim().length === 0) return void 0;
58
+ try {
59
+ return Effect.runSync(cel(expression, { ...baseContext(), ...scope }));
60
+ } catch (err) {
61
+ console.warn("[shwfed-invoice] expression evaluation failed", expression, err);
62
+ return void 0;
63
+ }
64
+ }
65
+ function text(expression, scope) {
66
+ const v = evaluate(expression, scope);
67
+ return v === null || v === void 0 ? "" : String(v);
68
+ }
69
+ function money(expression, scope) {
70
+ const v = evaluate(expression, scope);
71
+ if (v === null || v === void 0) return "";
72
+ if (typeof v === "number") return Number.isFinite(v) ? MONEY_FORMAT.format(v) : "";
73
+ return String(v);
74
+ }
75
+ function plain(expression, scope) {
76
+ const v = evaluate(expression, scope);
77
+ if (v === null || v === void 0) return "";
78
+ return String(v);
79
+ }
80
+ function bool(expression, scope) {
81
+ return evaluate(expression, scope) === true;
82
+ }
83
+ function capital(expression) {
84
+ const n = toFiniteNumber(evaluate(expression));
85
+ return n === null ? "" : toCapital(n) ?? "";
86
+ }
87
+ return { json, evaluate, text, money, plain, bool, capital };
88
+ }
@@ -0,0 +1,68 @@
1
+ import { Schema } from 'effect';
2
+ import type { Environment } from '../vendor/cel-js/lib/index.js';
3
+ import type { ResultType } from './expression.js';
4
+ /**
5
+ * The pieces every 数电票 block shares. The 税总 invoice family (通用数电票、不动产
6
+ * 经营租赁服务、不动产销售、建筑服务…) is one 版式 with a per-业务 label, per-业务
7
+ * 明细 columns and a per-业务 备注 — everything else (抬头 / 购销双方 / 合计 /
8
+ * 价税合计 / 开票人) is byte-identical across members. This module holds the schema
9
+ * half of that overlap; `ui/invoice` holds the rendering half and `share/
10
+ * invoice-eval.ts` the per-栏 evaluation.
11
+ *
12
+ * Deliberately NOT a "common fields" factory: each block composes its own
13
+ * `Schema.Struct` so that `type` / `compatibilityDate` stay literal `Schema.tag`s
14
+ * at the folder that owns them. A factory would have to take those as arguments
15
+ * and hand back a half-built struct — more indirection than the duplication it
16
+ * would remove.
17
+ */
18
+ export type Configure = (env: Environment) => void;
19
+ /**
20
+ * 票面绝大多数栏位是文本。上下文取值的表达式常被 CEL 推断为 `dyn`(只在运行时收
21
+ * 窄),所以与 animated-number / card 的字符串字段一样容忍 `dyn` / `optional`。
22
+ */
23
+ export declare const textResult: ResultType;
24
+ /**
25
+ * 金额类栏位同时接受 `number` 与 `string`:格式化规则是「返回 string 原样打印,
26
+ * 返回 number 按票面惯例格式化」(见 `share/invoice-eval.ts` 的 `money`)。后端常以
27
+ * string 传小数以免丢精度,作者也可借此完全接管格式。
28
+ */
29
+ export declare const moneyResult: ResultType;
30
+ export declare const listResult: ResultType;
31
+ export declare const boolResult: ResultType;
32
+ /**
33
+ * 票面自己的(可选)取数:`request` 求值出的 HTTP 响应体,票面**每一栏**都能读。
34
+ *
35
+ * 与「不内建 DataSource」的边界不冲突 —— 只有 `request`,没有 `data`:票面各栏本来
36
+ * 就是逐栏 CEL 映射,`json` 只是多了一个可读的上下文变量,而不是又一层「列表 → 行」
37
+ * 的取数抽象。不配置时 `json` 为 `none`,票面照旧从外层上下文(`item` / 详情页变量)
38
+ * 取值。
39
+ *
40
+ * 也导出给各块的 `config.vue` —— 它直接渲染 `ExpressionEditor`(不经过 schema),
41
+ * 不共享这份声明的话,编辑器会把 `json` 误报成 `Unknown variable`。镜像 card 块的
42
+ * `JSON_VAR`。
43
+ */
44
+ export declare const JSON_VAR: {
45
+ readonly type: "optional<dyn>";
46
+ readonly label: "HTTP 响应体";
47
+ readonly description: "HTTP 响应体(配置了「请求」时为已解析 JSON,否则为 none)";
48
+ };
49
+ /**
50
+ * 登记 `json`,但外层 `configure` 已经声明过就跳过 —— 宿主(详情页)本来就可能把自己
51
+ * 的响应体以 `json` 喂进来,重复声明会被 CEL 注册表拒掉(`'json' is already
52
+ * registered`),整个配置面直接抛错。与 `registerLoopVariablesIfAbsent` 同解。
53
+ *
54
+ * 外层已有时以**外层的声明为准**(类型通常是 `dyn` 而不是这里的 `optional<dyn>`)。
55
+ * 运行期的对应规则见 `share/invoice-eval.ts` 的 `baseContext`:配了「请求」本块的
56
+ * 响应体遮蔽外层的 `json`,没配则外层的 `json` 原样透传。
57
+ */
58
+ export declare function registerJsonIfAbsent(env: Environment): void;
59
+ /**
60
+ * 购买方 / 销售方信息栏。票面只有「名称」与「统一社会信用代码/纳税人识别号」两栏 ——
61
+ * 开户行与账号在真实发票上属于「备注」栏的自由文本(不是独立栏位),因此不建模,
62
+ * 由各块的备注承载。整个发票家族逐字相同,故在此共享。
63
+ */
64
+ export declare function partySchema(configure: Configure, role: '购买方' | '销售方'): Schema.Struct<{
65
+ name: Schema.Schema<string, string, never>;
66
+ taxId: Schema.Schema<string, string, never>;
67
+ }>;
68
+ export type PartyValue = Schema.Schema.Type<ReturnType<typeof partySchema>>;
@@ -0,0 +1,35 @@
1
+ import { Schema } from "effect";
2
+ import { Expression } from "./expression.js";
3
+ export const textResult = (t) => t === "string" || t === "dyn" || t.startsWith("optional");
4
+ export const moneyResult = (t) => t === "number" || t === "string" || t === "dyn" || t.startsWith("optional");
5
+ export const listResult = (t) => t === "dyn" || t.startsWith("list") || t.startsWith("optional");
6
+ export const boolResult = (t) => t === "bool" || t === "dyn" || t.startsWith("optional");
7
+ export const JSON_VAR = {
8
+ type: "optional<dyn>",
9
+ label: "HTTP \u54CD\u5E94\u4F53",
10
+ description: "HTTP \u54CD\u5E94\u4F53\uFF08\u914D\u7F6E\u4E86\u300C\u8BF7\u6C42\u300D\u65F6\u4E3A\u5DF2\u89E3\u6790 JSON\uFF0C\u5426\u5219\u4E3A none\uFF09"
11
+ };
12
+ export function registerJsonIfAbsent(env) {
13
+ const declared = env.getDefinitions().variables.some((v) => v.name === "json");
14
+ if (declared) return;
15
+ env.registerVariable("json", JSON_VAR.type, {
16
+ label: JSON_VAR.label,
17
+ description: JSON_VAR.description
18
+ });
19
+ }
20
+ export function partySchema(configure, role) {
21
+ const CelText = Expression({ configure, resultType: textResult });
22
+ return Schema.Struct({
23
+ name: CelText.annotations({
24
+ title: "\u540D\u79F0",
25
+ description: `\u8FD4\u56DE${role}\u540D\u79F0\uFF08\`string\`\uFF09\u7684 CEL \u8868\u8FBE\u5F0F`
26
+ }),
27
+ taxId: CelText.annotations({
28
+ title: "\u7EDF\u4E00\u793E\u4F1A\u4FE1\u7528\u4EE3\u7801/\u7EB3\u7A0E\u4EBA\u8BC6\u522B\u53F7",
29
+ description: `\u8FD4\u56DE${role}\u7EDF\u4E00\u793E\u4F1A\u4FE1\u7528\u4EE3\u7801\u6216\u7EB3\u7A0E\u4EBA\u8BC6\u522B\u53F7\uFF08\`string\`\uFF09\u7684 CEL \u8868\u8FBE\u5F0F`
30
+ })
31
+ }).annotations({
32
+ title: `${role}\u4FE1\u606F`,
33
+ description: `${role}\u7684\u540D\u79F0\u4E0E\u7EB3\u7A0E\u4EBA\u8BC6\u522B\u53F7\uFF1B\u5F00\u6237\u884C / \u8D26\u53F7\u8BF7\u5199\u5165\u300C\u5907\u6CE8\u300D`
34
+ });
35
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 人民币金额小写 → 中文大写(票面「价税合计(大写)」栏)。
3
+ *
4
+ * 规则是国标固定的,所以在块内本地推导而不是多开一个配置字段 —— 大写与小写永远
5
+ * 不会不一致。负数(红字发票)走「(负数)」前缀,与税务总局版式一致。
6
+ */
7
+ /**
8
+ * 金额 → 中文大写。`6706.1` → `陆仟柒佰零陆圆壹角整`,`-308` → `(负数)叁佰零捌圆整`。
9
+ * 超出「万亿」量级或非有限数返回 `null`,由调用方决定回退(票面留空)。
10
+ */
11
+ export declare function toCapital(value: number): string | null;
@@ -0,0 +1,58 @@
1
+ const DIGITS = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
2
+ const UNITS = ["", "\u62FE", "\u4F70", "\u4EDF"];
3
+ const GROUPS = ["", "\u4E07", "\u4EBF", "\u4E07\u4EBF"];
4
+ function groupToCapital(group) {
5
+ let out = "";
6
+ let zero = false;
7
+ for (let i = 0; i < group.length; i++) {
8
+ const digit = Number(group[i]);
9
+ if (digit === 0) {
10
+ zero = true;
11
+ continue;
12
+ }
13
+ if (zero && out !== "") out += "\u96F6";
14
+ zero = false;
15
+ out += DIGITS[digit] + UNITS[group.length - 1 - i];
16
+ }
17
+ return out;
18
+ }
19
+ function integerToCapital(digits) {
20
+ const trimmed = digits.replace(/^0+/, "");
21
+ if (trimmed === "") return "\u96F6";
22
+ const groups = [];
23
+ for (let end = trimmed.length; end > 0; end -= 4) {
24
+ groups.unshift(trimmed.slice(Math.max(0, end - 4), end));
25
+ }
26
+ let out = "";
27
+ let pendingZero = false;
28
+ groups.forEach((group, i) => {
29
+ if (Number(group) === 0) {
30
+ pendingZero = out !== "";
31
+ return;
32
+ }
33
+ let text = groupToCapital(group);
34
+ const leadingZero = group.length === 4 && group[0] === "0";
35
+ if ((pendingZero || leadingZero) && out !== "") text = `\u96F6${text}`;
36
+ pendingZero = false;
37
+ out += text + GROUPS[groups.length - 1 - i];
38
+ });
39
+ return out;
40
+ }
41
+ export function toCapital(value) {
42
+ if (!Number.isFinite(value)) return null;
43
+ const negative = value < 0;
44
+ const cents = Math.round(Math.abs(value) * 100);
45
+ const yuan = Math.floor(cents / 100);
46
+ const jiao = Math.floor(cents % 100 / 10);
47
+ const fen = cents % 10;
48
+ if (String(yuan).length > 16) return null;
49
+ let out = `${integerToCapital(String(yuan))}\u5706`;
50
+ if (jiao === 0 && fen === 0) {
51
+ out += "\u6574";
52
+ } else {
53
+ if (jiao > 0) out += `${DIGITS[jiao]}\u89D2`;
54
+ if (fen > 0) out += `${jiao === 0 ? "\u96F6" : ""}${DIGITS[fen]}\u5206`;
55
+ else out += "\u6574";
56
+ }
57
+ return negative ? `\uFF08\u8D1F\u6570\uFF09${out}` : out;
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/config",
3
- "version": "3.0.11",
3
+ "version": "3.0.13",
4
4
  "description": "Configurable UI for SHWFED",
5
5
  "type": "module",
6
6
  "publishConfig": {