@es-joy/jsoe 0.17.0 → 0.19.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.
package/CHANGES.md CHANGED
@@ -1,7 +1,20 @@
1
1
  # CHANGES TO `@es-joy/jsoe`
2
2
 
3
+ ## 0.19.0
4
+
5
+ - feat: change API for `$setFormat` to accept `schema` and change API to object with
6
+ `valueFormat`, `autoTrigger`, and `schema` properties.
7
+
8
+ ## 0.18.0
9
+
10
+ - feat: give option to disable `autoTrigger` for building type choices, e.g.,
11
+ with `$setFormat(format, autoTrigger)`
12
+
3
13
  ## 0.17.0
4
14
 
15
+ BREAKING CHANGES: API changes to `formatAndTypeChoices` and
16
+ `getFormatAndSchemaChoices`
17
+
5
18
  - feat: Zodex schema support
6
19
 
7
20
  ## 0.16.0
@@ -56,22 +56,30 @@ export function formatAndTypeChoices({ schemas, getSchemaContent, hasValue, sing
56
56
  $setFormat: (this: HTMLSelectElement & {
57
57
  $buildTypeChoices: (this: HTMLSelectElement & {
58
58
  $buildTypeChoices: any;
59
- }) => Promise<void>;
60
- }, valueFormat: string) => Promise<void>;
59
+ }, autoTrigger?: boolean | undefined) => Promise<void>;
60
+ }, cfg: {
61
+ valueFormat?: import("./formats.js").AvailableFormat;
62
+ autoTrigger: boolean;
63
+ schema?: string;
64
+ }) => Promise<void>;
61
65
  $buildTypeChoices: (this: HTMLSelectElement & {
62
66
  $buildTypeChoices: any;
63
- }) => Promise<void>;
67
+ }, autoTrigger?: boolean | undefined) => Promise<void>;
64
68
  };
65
69
  typesHolder: HTMLDivElement;
66
70
  domArray: [formatChoices: HTMLSelectElement & {
67
71
  $setFormat: (this: HTMLSelectElement & {
68
72
  $buildTypeChoices: (this: HTMLSelectElement & {
69
73
  $buildTypeChoices: any;
70
- }) => Promise<void>;
71
- }, valueFormat: string) => Promise<void>;
74
+ }, autoTrigger?: boolean | undefined) => Promise<void>;
75
+ }, cfg: {
76
+ valueFormat?: import("./formats.js").AvailableFormat;
77
+ autoTrigger: boolean;
78
+ schema?: string;
79
+ }) => Promise<void>;
72
80
  $buildTypeChoices: (this: HTMLSelectElement & {
73
81
  $buildTypeChoices: any;
74
- }) => Promise<void>;
82
+ }, autoTrigger?: boolean | undefined) => Promise<void>;
75
83
  }, typesHolder: HTMLDivElement];
76
84
  getValue: (stateObj: import("./types.js").StateObject, currentPath: string) => import("./formats.js").StructuredCloneValue;
77
85
  getType: () => string;
@@ -1 +1 @@
1
- {"version":3,"file":"formatAndTypeChoices.d.ts","sourceRoot":"","sources":["../src/formatAndTypeChoices.js"],"names":[],"mappings":"AAuDA;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,sJA/BG;IAAuB,OAAO;IACyB,gBAAgB,aAAtD,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC;IAE1B,QAAQ;IAGR,WAAW;IACX,UAAU;IAKX,aAAa;IAEb,cAAc;IACU,OAAO;IACT,KAAK;CAChD,GAAU,OAAO,CAAC;IACpB,aAAiB;;;;kBA8CC,OAAO,CAAC,IAAI,CAAC;wBAbf,MAAM,KAIJ,OAAO,CAAC,IAAI,CAAC;;;cASb,OAAO,CAAC,IAAI,CAAC;MA9CE;IACjC,WAAe,iBAAc;IAC7B,QAAY,EAAE,CAAC,aAAa;;;;kBA4CV,OAAO,CAAC,IAAI,CAAC;wBAbf,MAAM,KAIJ,OAAO,CAAC,IAAI,CAAC;;;cASb,OAAO,CAAC,IAAI,CAAC;KA5CY,EAAE,WAAW,gBAAa,CAAC,CAAC;IACvE,QAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,YAAY,EAAE,WAAW,EACnD,WAAW,EAAE,MAAM,KAAK,OAAO,cAAc,EAAE,oBAAoB,CAAC;IAC1E,OAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,cAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,QAAY,EAAE,QAAQ,CAAC;IACvB,OAAW,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AAC;;;iDAUb,OAAO,CAAC,IAAI,CAAC;KAjDY,EAAE,WAAW,gBAAa,CAAC,CAAC;IACvE,QAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,YAAY,EAAE,WAAW,EACnD,WAAW,EAAE,MAAM,KAAK,OAAO,cAAc,EAAE,oBAAoB,CAAC;IAC1E,OAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,cAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,QAAY,EAAE,QAAQ,CAAC;IACvB,OAAW,EAAE,OAAO,cAAc,EAAE,OAAO,CAAC;IAC5C,KAAS,EAAE,OAAO,YAAY,EAAE,OAAO,CAAA;CACpC,CAAC,CA2OJ;AAtTM,oFAPJ;IAAuB,OAAO;IACT,cAAc;IACb,UAAU;CAGhC,GAAU,gBAAgB,CAiC5B;+BAIU,OAAO,cAAc,EAAE,oBAAoB,YAC3C,OAAO,YAAY,EAAE,WAAW,KAC9B,OAAO,CAAC,IAAI,CAAC;0BAIb,OAAO,qBAAqB,EAAE,WAAW;mCAvDzC,cAAc,GAAC,IAAI;oBALZ,cAAc;kBADhB,YAAY"}
package/dist/index.js CHANGED
@@ -21822,7 +21822,11 @@ async function formatAndTypeChoices ({
21822
21822
  /**
21823
21823
  * Sets the desired format and rebuilds the type choices.
21824
21824
  * @callback SetFormat
21825
- * @param {string} valueFormat
21825
+ * @param {{
21826
+ * valueFormat?: import('./formats.js').AvailableFormat,
21827
+ * autoTrigger: boolean,
21828
+ * schema?: string
21829
+ * }} cfg
21826
21830
  * @this {HTMLSelectElement & {
21827
21831
  * $buildTypeChoices: TypeChoiceBuilder
21828
21832
  * }}
@@ -21832,6 +21836,7 @@ async function formatAndTypeChoices ({
21832
21836
  /**
21833
21837
  * Rebuilds the type choices.
21834
21838
  * @callback TypeChoiceBuilder
21839
+ * @param {boolean} [autoTrigger]
21835
21840
  * @this {HTMLSelectElement & {
21836
21841
  * $buildTypeChoices: TypeChoiceBuilder
21837
21842
  * }}
@@ -21848,18 +21853,26 @@ async function formatAndTypeChoices ({
21848
21853
  /**
21849
21854
  * @type {SetFormat}
21850
21855
  */
21851
- async $setFormat (valueFormat) {
21852
- this.value = valueFormat;
21853
- await this.$buildTypeChoices();
21856
+ async $setFormat ({valueFormat, autoTrigger, schema}) {
21857
+ if (schema) {
21858
+ const idx = [...this.options].findIndex((option) => {
21859
+ return option.dataset.schema === schema;
21860
+ });
21861
+ this.selectedIndex = idx === -1 ? 0 : idx;
21862
+ } else if (valueFormat) {
21863
+ this.value = valueFormat;
21864
+ }
21865
+ await this.$buildTypeChoices(autoTrigger);
21854
21866
  },
21855
21867
 
21856
21868
  /**
21857
21869
  * @type {TypeChoiceBuilder}
21858
21870
  */
21859
- async $buildTypeChoices () {
21871
+ async $buildTypeChoices (autoTrigger) {
21860
21872
  DOM.removeChildren(typesHolder);
21861
21873
  const {schema} = this.selectedOptions[0].dataset;
21862
21874
  jml({'#': buildTypeChoices({
21875
+ autoTrigger,
21863
21876
  topRoot: /** @type {HTMLDivElement} */ (
21864
21877
  $e(typesHolder, 'div[data-type]')
21865
21878
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-joy/jsoe",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./src/index.js",
@@ -118,7 +118,11 @@ export async function formatAndTypeChoices ({
118
118
  /**
119
119
  * Sets the desired format and rebuilds the type choices.
120
120
  * @callback SetFormat
121
- * @param {string} valueFormat
121
+ * @param {{
122
+ * valueFormat?: import('./formats.js').AvailableFormat,
123
+ * autoTrigger: boolean,
124
+ * schema?: string
125
+ * }} cfg
122
126
  * @this {HTMLSelectElement & {
123
127
  * $buildTypeChoices: TypeChoiceBuilder
124
128
  * }}
@@ -128,6 +132,7 @@ export async function formatAndTypeChoices ({
128
132
  /**
129
133
  * Rebuilds the type choices.
130
134
  * @callback TypeChoiceBuilder
135
+ * @param {boolean} [autoTrigger]
131
136
  * @this {HTMLSelectElement & {
132
137
  * $buildTypeChoices: TypeChoiceBuilder
133
138
  * }}
@@ -144,18 +149,26 @@ export async function formatAndTypeChoices ({
144
149
  /**
145
150
  * @type {SetFormat}
146
151
  */
147
- async $setFormat (valueFormat) {
148
- this.value = valueFormat;
149
- await this.$buildTypeChoices();
152
+ async $setFormat ({valueFormat, autoTrigger, schema}) {
153
+ if (schema) {
154
+ const idx = [...this.options].findIndex((option) => {
155
+ return option.dataset.schema === schema;
156
+ });
157
+ this.selectedIndex = idx === -1 ? 0 : idx;
158
+ } else if (valueFormat) {
159
+ this.value = valueFormat;
160
+ }
161
+ await this.$buildTypeChoices(autoTrigger);
150
162
  },
151
163
 
152
164
  /**
153
165
  * @type {TypeChoiceBuilder}
154
166
  */
155
- async $buildTypeChoices () {
167
+ async $buildTypeChoices (autoTrigger) {
156
168
  DOM.removeChildren(typesHolder);
157
169
  const {schema} = this.selectedOptions[0].dataset;
158
170
  jml({'#': buildTypeChoices({
171
+ autoTrigger,
159
172
  topRoot: /** @type {HTMLDivElement} */ (
160
173
  $e(typesHolder, 'div[data-type]')
161
174
  ),