@ticatec/uniface-flexi-module 0.0.11 → 0.1.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.
@@ -2,10 +2,10 @@
2
2
  import SearchField from "./components/SearchField.svelte";
3
3
  export let criteriaSet;
4
4
  export let criteria;
5
- let variant = criteriaSet.variant;
5
+ let variant = criteriaSet._variant;
6
6
  let fields = [...criteriaSet.fields];
7
- let arrangement = criteriaSet.arrangement;
8
- let label$style = criteriaSet.label$style;
7
+ let arrangement = criteriaSet._arrangement;
8
+ let label$style = criteriaSet._label$style;
9
9
  onMount(async () => {
10
10
  criteriaSet.setInvalidateHandler(() => {
11
11
  fields = [...criteriaSet.fields];
@@ -12,13 +12,15 @@ export default class FlexiCriteriaSet {
12
12
  protected field: {
13
13
  [key: string]: FlexiCriteriaField;
14
14
  };
15
- readonly arrangement: Arrangement;
16
- readonly label$style?: string;
17
- readonly variant?: "outlined" | 'filled';
18
- constructor(schema: FlexiCriteriaSetSchema);
19
- initialize(): Promise<void>;
15
+ private _arrangement;
16
+ private _label$style?;
17
+ private _variant?;
18
+ initialize(schema: FlexiCriteriaSetSchema): Promise<void>;
20
19
  setInvalidateHandler(value: InvalidateHandler | null): void;
21
20
  invalidate(): void;
22
21
  get fields(): Array<FlexiCriteriaField>;
23
22
  getDictionary(key: string): any;
23
+ get arrangement(): Arrangement;
24
+ get label$style(): string | undefined;
25
+ get variant(): "outlined" | "filled" | undefined;
24
26
  }
@@ -5,33 +5,27 @@ export default class FlexiCriteriaSet {
5
5
  field = {};
6
6
  #onInvalidate = null;
7
7
  #dictionaries;
8
- arrangement;
9
- label$style;
10
- variant;
11
- #schema;
12
- constructor(schema) {
8
+ _arrangement;
9
+ _label$style;
10
+ _variant;
11
+ async initialize(schema) {
13
12
  this.#fields = [];
14
13
  this.#dictionaries = {};
15
- this.#schema = schema;
16
- this.arrangement = schema.arrangement ?? 'vertical';
17
- this.label$style = schema.label$style;
18
- this.variant = schema.variant ?? 'outlined';
19
- }
20
- async initialize() {
14
+ this._arrangement = schema.arrangement ?? 'vertical';
15
+ this._label$style = schema.label$style;
16
+ this._variant = schema.variant ?? 'outlined';
21
17
  const dicts = [];
22
- for (const schema of this.#schema.fields) {
23
- if (schema.dictName && !dicts.includes(schema.dictName)) {
24
- dicts.push(schema.dictName);
18
+ for (const fieldSchema of schema.fields) {
19
+ if (fieldSchema.dictName && !dicts.includes(fieldSchema.dictName)) {
20
+ dicts.push(fieldSchema.dictName);
25
21
  }
26
- }
27
- this.#dictionaries = FlexiContext.getInstance().loadDictionaries(dicts);
28
- for (const schema of this.#schema.fields) {
29
- const field = new FlexiCriteriaField(this, schema);
22
+ const field = new FlexiCriteriaField(this, fieldSchema);
30
23
  this.#fields.push(field);
31
- if (schema.name) {
32
- this.field[schema.name] = field;
24
+ if (fieldSchema.name) {
25
+ this.field[fieldSchema.name] = field;
33
26
  }
34
27
  }
28
+ this.#dictionaries = await FlexiContext.getInstance().loadDictionaries(dicts);
35
29
  }
36
30
  setInvalidateHandler(value) {
37
31
  this.#onInvalidate = value;
@@ -45,4 +39,13 @@ export default class FlexiCriteriaSet {
45
39
  getDictionary(key) {
46
40
  return this.#dictionaries[key] ?? [];
47
41
  }
42
+ get arrangement() {
43
+ return this._arrangement ?? "vertical";
44
+ }
45
+ get label$style() {
46
+ return this._label$style;
47
+ }
48
+ get variant() {
49
+ return this._variant;
50
+ }
48
51
  }
@@ -76,18 +76,18 @@ export interface ActionsColumnSchema {
76
76
  }
77
77
  export interface FlexiDataTableSchema {
78
78
  round?: boolean;
79
- indicatorColumn: IndicatorColumnSchema;
79
+ indicatorColumn?: IndicatorColumnSchema;
80
80
  actionsColumn?: ActionsColumnSchema;
81
81
  columns: Array<FlexiDataTableColumnSchema>;
82
82
  dicts?: Array<string>;
83
83
  }
84
84
  export default class FlexiDataTable {
85
85
  #private;
86
- readonly round?: boolean;
87
- readonly indicatorColumn: IndicatorColumn;
88
- constructor(schema: FlexiDataTableSchema);
89
- initialize(): Promise<void>;
86
+ protected _round: boolean;
87
+ protected _indicatorColumn?: IndicatorColumn;
88
+ initialize(schema: FlexiDataTableSchema): Promise<void>;
90
89
  protected set actionsColumn(value: ActionsColumn);
90
+ get isRound(): boolean;
91
91
  get actionsColumn(): ActionsColumn | undefined;
92
92
  /**
93
93
  * 设置数据列
@@ -2,52 +2,50 @@ import utils from "../flexi-form/lib/utils";
2
2
  import FlexiContext from "..";
3
3
  export default class FlexiDataTable {
4
4
  #columns = [];
5
- round;
6
- indicatorColumn;
5
+ _round;
6
+ _indicatorColumn;
7
7
  #actionsColumn;
8
- #schema;
9
8
  #dictionaries;
10
- constructor(schema) {
11
- this.#schema = schema;
12
- this.round = schema.round;
13
- this.indicatorColumn = { displayNo: true, ...schema.indicatorColumn };
14
- }
15
- async initialize() {
16
- if (this.#schema.dicts && this.#schema.dicts.length > 0) {
17
- this.#dictionaries = FlexiContext.getInstance().loadDictionaries(this.#schema.dicts);
9
+ async initialize(schema) {
10
+ this._round = schema.round == true;
11
+ if (schema.indicatorColumn) {
12
+ this._indicatorColumn = { displayNo: true, ...schema.indicatorColumn };
13
+ }
14
+ if (schema.dicts && schema.dicts.length > 0) {
15
+ this.#dictionaries = FlexiContext.getInstance().loadDictionaries(schema.dicts);
18
16
  }
19
- if (this.#schema.actionsColumn) {
20
- const getActions = this[this.#schema.actionsColumn.getActions];
17
+ if (schema.actionsColumn) {
18
+ const getActions = this[schema.actionsColumn.getActions];
21
19
  if (getActions) {
22
20
  this.#actionsColumn = {
23
- width: this.#schema.actionsColumn.width,
24
- align: this.#schema.actionsColumn.align,
21
+ width: schema.actionsColumn.width,
22
+ align: schema.actionsColumn.align,
25
23
  getActions: getActions.bind(this)
26
24
  };
27
25
  }
28
26
  }
29
27
  this.#columns = [];
30
- for (const schema of this.#schema.columns) {
31
- const formatter = schema.formatter ? this[schema.formatter] : null;
32
- const href = schema.href ? this[schema.href] : null;
33
- const hint = schema.hint ? this[schema.hint] : null;
34
- const render = schema.render ? this[schema.render] : null;
35
- const compareFunction = schema.compareFunction ? this[schema.compareFunction] : null;
28
+ for (const colSchema of schema.columns) {
29
+ const formatter = colSchema.formatter ? this[colSchema.formatter] : null;
30
+ const href = colSchema.href ? this[colSchema.href] : null;
31
+ const hint = colSchema.hint ? this[colSchema.hint] : null;
32
+ const render = colSchema.render ? this[colSchema.render] : null;
33
+ const compareFunction = colSchema.compareFunction ? this[colSchema.compareFunction] : null;
36
34
  const column = {
37
- text: schema.text,
38
- field: schema.field,
39
- frozen: schema.frozen,
40
- align: schema.align,
41
- width: schema.width,
42
- minWidth: schema.minWidth,
43
- warp: schema.warp,
35
+ text: colSchema.text,
36
+ field: colSchema.field,
37
+ frozen: colSchema.frozen,
38
+ align: colSchema.align,
39
+ width: colSchema.width,
40
+ minWidth: colSchema.minWidth,
41
+ warp: colSchema.warp,
44
42
  formatter: formatter ? formatter.bind(this) : undefined,
45
- escapeHTML: schema.escapeHTML,
43
+ escapeHTML: colSchema.escapeHTML,
46
44
  href: href ? href.bind(this) : undefined,
47
45
  hint: hint ? hint.bind(this) : undefined,
48
- render: render ? render.apply(this) : undefined,
49
- visible: schema.visible,
50
- resizable: schema.resizable,
46
+ render: render ? render.bind(this) : undefined,
47
+ visible: colSchema.visible,
48
+ resizable: colSchema.resizable,
51
49
  compareFunction: compareFunction ? compareFunction.bind(this) : undefined
52
50
  };
53
51
  this.#columns.push(column);
@@ -56,6 +54,9 @@ export default class FlexiDataTable {
56
54
  set actionsColumn(value) {
57
55
  this.#actionsColumn = value;
58
56
  }
57
+ get isRound() {
58
+ return this._round;
59
+ }
59
60
  get actionsColumn() {
60
61
  return this.#actionsColumn;
61
62
  }
@@ -3,8 +3,8 @@ import FlexiFormPanel from "./flexi_form/FlexiFormPanel.svelte";
3
3
  import { onMount } from "svelte";
4
4
  export let form;
5
5
  let title = form.getTitle();
6
- let width = form.props.width ?? "800px";
7
- let height = form.props.height ?? "600px";
6
+ let width = form._props.width ?? "800px";
7
+ let height = form._props.height ?? "600px";
8
8
  let actions = [];
9
9
  const closeConfirm = async () => {
10
10
  let confirm = form.closeConfirm;
@@ -46,18 +46,18 @@ export interface FlexiFormSchema {
46
46
  export type FormInvalidateHandler = () => void;
47
47
  export default abstract class FlexiForm {
48
48
  #private;
49
- readonly mode: LayoutMode;
50
- readonly props: any;
51
- readonly arrangement: Arrangement;
52
- readonly label$style?: string;
53
- readonly variant: 'filled' | 'outlined' | '';
54
- protected readonly elements: FormElements;
55
- readonly style: string;
56
- protected constructor(data: any, formSchema: FlexiFormSchema);
49
+ private _mode;
50
+ private _props;
51
+ private _arrangement;
52
+ private _label$style?;
53
+ private _variant;
54
+ private _elements;
55
+ private _style;
56
+ protected constructor(data: any);
57
57
  /**
58
58
  * 构造表单
59
59
  */
60
- initialize(): Promise<void>;
60
+ initialize(formSchema: FlexiFormSchema): Promise<void>;
61
61
  /**
62
62
  * 构造所有的卡片
63
63
  * @protected
@@ -124,4 +124,11 @@ export default abstract class FlexiForm {
124
124
  */
125
125
  get actions(): ButtonActions;
126
126
  getBlocks(): Array<FormBlockSchema> | undefined;
127
+ get mode(): LayoutMode;
128
+ get props(): any;
129
+ get arrangement(): Arrangement;
130
+ get label$style(): string | undefined;
131
+ get variant(): "" | "outlined" | "filled";
132
+ get style(): string;
133
+ protected get elements(): FormElements;
127
134
  }
@@ -4,35 +4,33 @@ import FlexiContext from "../..";
4
4
  export default class FlexiForm {
5
5
  #blocks;
6
6
  #cards = [];
7
- mode = "flex";
8
- props = {};
9
- arrangement = "vertical";
7
+ _mode = "flex";
8
+ _props = {};
9
+ _arrangement = "vertical";
10
10
  #data;
11
- label$style = '';
12
- variant;
13
- elements;
11
+ _label$style = '';
12
+ _variant;
13
+ _elements;
14
14
  #invalidateHandler;
15
15
  #actions;
16
16
  #dictionaries;
17
- style;
18
- constructor(data, formSchema) {
19
- this.#blocks = formSchema.blocks;
17
+ _style;
18
+ constructor(data) {
20
19
  this.#data = data;
21
- this.mode = formSchema.mode ?? 'flex';
22
- this.arrangement = formSchema.arrangement ?? 'vertical';
23
- this.props = formSchema.props ?? {};
24
- this.label$style = formSchema.label$style;
25
- this.variant = formSchema.variant ?? 'filled';
26
- this.elements = formSchema.elements;
27
- this.#actions = this.parseFormActions(formSchema.actions);
28
- this.#dictionaries = {};
29
- this.style = formSchema.style ?? '';
30
20
  }
31
21
  /**
32
22
  * 构造表单
33
23
  */
34
- async initialize() {
35
- console.log('构造表单');
24
+ async initialize(formSchema) {
25
+ this.#blocks = formSchema.blocks;
26
+ this._mode = formSchema.mode ?? 'flex';
27
+ this._arrangement = formSchema.arrangement ?? 'vertical';
28
+ this._props = formSchema.props ?? {};
29
+ this._label$style = formSchema.label$style;
30
+ this._variant = formSchema.variant ?? 'filled';
31
+ this._elements = formSchema.elements;
32
+ this.#actions = this.parseFormActions(formSchema.actions);
33
+ this._style = formSchema.style ?? '';
36
34
  let dicts = this.extractDictionaries();
37
35
  this.#dictionaries = await FlexiContext.getInstance().loadDictionaries(dicts);
38
36
  this.buildCards();
@@ -43,7 +41,7 @@ export default class FlexiForm {
43
41
  * @param name
44
42
  */
45
43
  getCompositeSchema(name) {
46
- return this.elements[name];
44
+ return this._elements[name];
47
45
  }
48
46
  /**
49
47
  *
@@ -86,8 +84,8 @@ export default class FlexiForm {
86
84
  }
87
85
  extractDictionaries() {
88
86
  let dicts = [];
89
- for (let key in this.elements) {
90
- const element = this.elements[key];
87
+ for (let key in this._elements) {
88
+ const element = this._elements[key];
91
89
  if (element.type == "block") {
92
90
  this.extractDictFromFields(dicts, element.fields);
93
91
  }
@@ -157,4 +155,25 @@ export default class FlexiForm {
157
155
  getBlocks() {
158
156
  return this.#blocks;
159
157
  }
158
+ get mode() {
159
+ return this._mode;
160
+ }
161
+ get props() {
162
+ return this._props;
163
+ }
164
+ get arrangement() {
165
+ return this._arrangement;
166
+ }
167
+ get label$style() {
168
+ return this._label$style;
169
+ }
170
+ get variant() {
171
+ return this._variant;
172
+ }
173
+ get style() {
174
+ return this._style;
175
+ }
176
+ get elements() {
177
+ return this._elements;
178
+ }
160
179
  }
@@ -7,7 +7,7 @@ export let actions = null;
7
7
  export let readonly = false;
8
8
  export let form;
9
9
  export let onFormInvalidate = null;
10
- let style = form.style;
10
+ let style = form._style;
11
11
  let blocks;
12
12
  onMount(async () => {
13
13
  form.setInvalidateHandler(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/uniface-flexi-module",
3
- "version": "0.0.11",
3
+ "version": "0.1.0",
4
4
  "description": "A flexible form framework for Svelte applications with dynamic field types, criteria panels, and modular components",
5
5
  "keywords": [
6
6
  "svelte",
@@ -113,7 +113,7 @@
113
113
  "@ticatec/uniface-element": "^0.3.4",
114
114
  "@ticatec/uniface-filter-panel": "^0.1.1",
115
115
  "@ticatec/uniface-google-material-icons": "^0.1.2",
116
- "@ticatec/uniface-micro-frame": "^0.0.1",
116
+ "@ticatec/uniface-micro-frame": "^0.0.2",
117
117
  "@ticatec/web-bean-validator": "^0.1.9",
118
118
  "dayjs": "^1.11.13",
119
119
  "dotenv": "^16.5.0",
@@ -124,11 +124,11 @@
124
124
  "svelte-preprocess": "^6.0.3",
125
125
  "tslib": "^2.3.1",
126
126
  "typescript": "^5.7.3",
127
- "vite": "^6.3.5"
127
+ "vite": "^6.3.5",
128
+ "@ticatec/dyna-js": "^0.1.1"
128
129
  },
129
130
  "peerDependencies": {
130
- "svelte": "^5.0.0",
131
- "@ticatec/dyna-js": "^0.0.2"
131
+ "svelte": "^5.0.0"
132
132
  },
133
133
  "author": "Henry Feng",
134
134
  "license": "MIT",