odf.js 7.1.0 → 7.1.2

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.
@@ -79,6 +79,14 @@ const CONTROL_TYPE_BY_TAG = /* @__PURE__ */ new Map([
79
79
  ["form:grid", "group"],
80
80
  ["form:hidden", "richText"]
81
81
  ]);
82
+ function readListboxOptions(element) {
83
+ const options = [];
84
+ for (const option of require_xml_query.childrenWithTag(element, "form:option")) {
85
+ const text = formAttr(option, "form:label") ?? formAttr(option, "form:value");
86
+ if (text !== void 0) options.push(text);
87
+ }
88
+ return options;
89
+ }
82
90
  function controlConstruct(element, format) {
83
91
  const mapped = CONTROL_TYPE_BY_TAG.get(element.tag);
84
92
  const descriptor = {
@@ -91,6 +99,7 @@ function controlConstruct(element, format) {
91
99
  const value = formAttr(element, "form:current-value") ?? formAttr(element, "form:value");
92
100
  if (value !== void 0) descriptor.value = value;
93
101
  if (element.tag === "form:checkbox" || element.tag === "form:radio") descriptor.checked = formAttr(element, "form:current-state") === "checked";
102
+ if (element.tag === "form:listbox") descriptor.options = readListboxOptions(element);
94
103
  const properties = require_xml_query.childrenWithTag(element, FORM_PROPERTIES_TAG)[0];
95
104
  if (properties !== void 0) descriptor.source = require_typed_shared_constructs.odfResidue(format, properties);
96
105
  } else descriptor.source = require_typed_shared_constructs.odfResidue(format, element);
@@ -78,6 +78,14 @@ const CONTROL_TYPE_BY_TAG = /* @__PURE__ */ new Map([
78
78
  ["form:grid", "group"],
79
79
  ["form:hidden", "richText"]
80
80
  ]);
81
+ function readListboxOptions(element) {
82
+ const options = [];
83
+ for (const option of childrenWithTag(element, "form:option")) {
84
+ const text = formAttr(option, "form:label") ?? formAttr(option, "form:value");
85
+ if (text !== void 0) options.push(text);
86
+ }
87
+ return options;
88
+ }
81
89
  function controlConstruct(element, format) {
82
90
  const mapped = CONTROL_TYPE_BY_TAG.get(element.tag);
83
91
  const descriptor = {
@@ -90,6 +98,7 @@ function controlConstruct(element, format) {
90
98
  const value = formAttr(element, "form:current-value") ?? formAttr(element, "form:value");
91
99
  if (value !== void 0) descriptor.value = value;
92
100
  if (element.tag === "form:checkbox" || element.tag === "form:radio") descriptor.checked = formAttr(element, "form:current-state") === "checked";
101
+ if (element.tag === "form:listbox") descriptor.options = readListboxOptions(element);
93
102
  const properties = childrenWithTag(element, FORM_PROPERTIES_TAG)[0];
94
103
  if (properties !== void 0) descriptor.source = odfResidue(format, properties);
95
104
  } else descriptor.source = odfResidue(format, element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odf.js",
3
- "version": "7.1.0",
3
+ "version": "7.1.2",
4
4
  "description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, plus read support for the pre-OASIS OpenOffice.org 1.x documents ODF was based on (sxw, sxc, sxi, sxd), hand-written and dependency-minimal, built on Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -87,7 +87,7 @@
87
87
  "license": "MIT",
88
88
  "packageManager": "pnpm@11.6.0",
89
89
  "dependencies": {
90
- "document-schema.js": "^6.1.0",
90
+ "document-schema.js": "^6.2.0",
91
91
  "fast-xml-parser": "^5.10.1",
92
92
  "fflate": "^0.8.3",
93
93
  "zod": "^4.4.3"