@thi.ng/rdom-forms 0.3.33 → 0.4.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-09-19T21:09:34Z
3
+ - **Last updated**: 2024-10-05T12:12:32Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,15 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom-forms@0.4.0) (2024-10-05)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update attrib & value config handling ([7495584](https://github.com/thi-ng/umbrella/commit/7495584))
17
+ - allow reactive attributes in more places
18
+ - don't generate event handlers if widget spec has no `value` option
19
+ - always apply user provided attribs (incl. event handlers) last
20
+
12
21
  ### [0.3.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom-forms@0.3.1) (2024-03-28)
13
22
 
14
23
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -132,7 +132,7 @@ Browser ESM import:
132
132
 
133
133
  [JSDelivr documentation](https://www.jsdelivr.com/)
134
134
 
135
- Package sizes (brotli'd, pre-treeshake): ESM: 2.28 KB
135
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.30 KB
136
136
 
137
137
  ## Dependencies
138
138
 
package/api.d.ts CHANGED
@@ -33,14 +33,22 @@ export interface Custom extends Pick<FormItem, "type"> {
33
33
  export interface Group extends FormItem {
34
34
  type: "group";
35
35
  items: FormItem[];
36
- label?: string | false;
36
+ label?: StringAttrib | false;
37
37
  }
38
38
  export interface Value extends FormItem, Partial<CommonAttribs> {
39
39
  id: string;
40
40
  name?: string;
41
- label?: string | false;
41
+ /**
42
+ * If false, no `<label>` element will be generated for this control and the
43
+ * {@link Value.desc} value will be unused.
44
+ */
45
+ label?: StringAttrib | false;
42
46
  desc?: any;
43
47
  required?: boolean;
48
+ /**
49
+ * If true, no input/change event handlers will be generated and the
50
+ * `readonly` attribute will be set on the input DOM element.
51
+ */
44
52
  readonly?: boolean;
45
53
  attribs?: Partial<InputAttribs>;
46
54
  }
@@ -59,7 +67,7 @@ export interface Num extends Value, WithPresets<number> {
59
67
  type: "num";
60
68
  min?: number;
61
69
  max?: number;
62
- placeholder?: string;
70
+ placeholder?: StringAttrib;
63
71
  size?: number;
64
72
  step?: number;
65
73
  value?: ISubscription<number, number>;
@@ -74,7 +82,7 @@ export interface Str extends Value, WithPresets<string> {
74
82
  min?: number;
75
83
  max?: number;
76
84
  pattern?: string | RegExp | Predicate<string>;
77
- placeholder?: string;
85
+ placeholder?: StringAttrib;
78
86
  size?: number;
79
87
  value?: ISubscription<string, string>;
80
88
  attribs?: Partial<InputTextAttribs>;
@@ -98,7 +106,7 @@ export interface Text extends Value {
98
106
  type: "text";
99
107
  cols?: number;
100
108
  rows?: number;
101
- placeholder?: string;
109
+ placeholder?: StringAttrib;
102
110
  value?: ISubscription<string, string>;
103
111
  attribs?: Partial<TextAreaAttribs>;
104
112
  }
@@ -164,18 +172,18 @@ export interface Toggle extends Value {
164
172
  }
165
173
  export interface Trigger extends Value {
166
174
  type: "trigger";
167
- title: string;
175
+ title: StringAttrib;
168
176
  value?: ISubscriber<boolean>;
169
177
  }
170
178
  export interface Submit extends Omit<Value, "required" | "readonly"> {
171
179
  type: "submit";
172
- title: string;
180
+ title: StringAttrib;
173
181
  value?: ISubscriber<boolean>;
174
182
  attribs?: Partial<InputSubmitAttribs>;
175
183
  }
176
184
  export interface Reset extends Omit<Value, "required" | "readonly"> {
177
185
  type: "submit";
178
- title: string;
186
+ title: StringAttrib;
179
187
  value?: ISubscriber<boolean>;
180
188
  }
181
189
  export interface Radio<T> extends Value {
@@ -268,7 +276,8 @@ export interface BehaviorOpts {
268
276
  */
269
277
  labels: boolean;
270
278
  /**
271
- * If false, no `value` attributes and event handlers will be generated.
279
+ * If false, no `value` attributes and event handlers will be generated,
280
+ * even if a `value` option has been specified.
272
281
  *
273
282
  * @defaultValue true
274
283
  */
package/compile.js CHANGED
@@ -112,25 +112,22 @@ const __genCommon = (val, opts) => {
112
112
  };
113
113
  const __attribs = (attribs, events, val, opts, value = "value") => {
114
114
  const id = __genID(val.id, opts);
115
- Object.assign(
116
- attribs,
117
- {
118
- id,
119
- name: val.name || val.id,
120
- list: val.list ? id + "--list" : void 0,
121
- required: val.required,
122
- readonly: val.readonly
123
- },
124
- val.attribs
125
- );
115
+ Object.assign(attribs, {
116
+ id,
117
+ name: val.name || val.id,
118
+ list: val.list ? id + "--list" : void 0,
119
+ required: val.required,
120
+ readonly: val.readonly
121
+ });
126
122
  if (__useValues(opts)) {
127
- if (!val.readonly) {
123
+ if (!val.readonly && val.value !== void 0) {
128
124
  Object.assign(attribs, events);
129
125
  }
130
126
  if (value !== false) {
131
127
  attribs[value] = val.value;
132
128
  }
133
129
  }
130
+ if (val.attribs) Object.assign(attribs, val.attribs);
134
131
  return attribs;
135
132
  };
136
133
  const __component = (val, opts, el, attribs, events, value = "value", ...body) => div(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rdom-forms",
3
- "version": "0.3.33",
3
+ "version": "0.4.1",
4
4
  "description": "Data-driven declarative & extensible HTML form generation",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,16 +36,16 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.10",
40
- "@thi.ng/checks": "^3.6.12",
41
- "@thi.ng/defmulti": "^3.0.48",
42
- "@thi.ng/hiccup-html": "^2.7.7",
43
- "@thi.ng/rdom": "^1.7.5",
44
- "@thi.ng/rstream": "^9.0.4"
39
+ "@thi.ng/api": "^8.11.11",
40
+ "@thi.ng/checks": "^3.6.13",
41
+ "@thi.ng/defmulti": "^3.0.49",
42
+ "@thi.ng/hiccup-html": "^2.7.8",
43
+ "@thi.ng/rdom": "^1.7.7",
44
+ "@thi.ng/rstream": "^9.0.6"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@microsoft/api-extractor": "^7.47.9",
48
- "esbuild": "^0.23.1",
48
+ "esbuild": "^0.24.0",
49
49
  "typedoc": "^0.26.7",
50
50
  "typescript": "^5.6.2"
51
51
  },
@@ -96,5 +96,5 @@
96
96
  "status": "alpha",
97
97
  "year": 2023
98
98
  },
99
- "gitHead": "dadc6e71940c091e50fbf9f88ea3ba115d3937df\n"
99
+ "gitHead": "241df2019d93359c34da1a11a94e416b6ea73f32\n"
100
100
  }