@es-joy/jsoe 0.18.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,5 +1,10 @@
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
+
3
8
  ## 0.18.0
4
9
 
5
10
  - feat: give option to disable `autoTrigger` for building type choices, e.g.,
@@ -57,7 +57,11 @@ export function formatAndTypeChoices({ schemas, getSchemaContent, hasValue, sing
57
57
  $buildTypeChoices: (this: HTMLSelectElement & {
58
58
  $buildTypeChoices: any;
59
59
  }, autoTrigger?: boolean | undefined) => Promise<void>;
60
- }, valueFormat: string, 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
67
  }, autoTrigger?: boolean | undefined) => Promise<void>;
@@ -68,7 +72,11 @@ export function formatAndTypeChoices({ schemas, getSchemaContent, hasValue, sing
68
72
  $buildTypeChoices: (this: HTMLSelectElement & {
69
73
  $buildTypeChoices: any;
70
74
  }, autoTrigger?: boolean | undefined) => Promise<void>;
71
- }, valueFormat: string, 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
82
  }, autoTrigger?: boolean | undefined) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"formatAndTypeChoices.d.ts","sourceRoot":"","sources":["../src/formatAndTypeChoices.js"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,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,8 +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
21826
- * @param {boolean} [autoTrigger]
21825
+ * @param {{
21826
+ * valueFormat?: import('./formats.js').AvailableFormat,
21827
+ * autoTrigger: boolean,
21828
+ * schema?: string
21829
+ * }} cfg
21827
21830
  * @this {HTMLSelectElement & {
21828
21831
  * $buildTypeChoices: TypeChoiceBuilder
21829
21832
  * }}
@@ -21850,8 +21853,15 @@ async function formatAndTypeChoices ({
21850
21853
  /**
21851
21854
  * @type {SetFormat}
21852
21855
  */
21853
- async $setFormat (valueFormat, autoTrigger) {
21854
- this.value = valueFormat;
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
+ }
21855
21865
  await this.$buildTypeChoices(autoTrigger);
21856
21866
  },
21857
21867
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-joy/jsoe",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./src/index.js",
@@ -118,8 +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
122
- * @param {boolean} [autoTrigger]
121
+ * @param {{
122
+ * valueFormat?: import('./formats.js').AvailableFormat,
123
+ * autoTrigger: boolean,
124
+ * schema?: string
125
+ * }} cfg
123
126
  * @this {HTMLSelectElement & {
124
127
  * $buildTypeChoices: TypeChoiceBuilder
125
128
  * }}
@@ -146,8 +149,15 @@ export async function formatAndTypeChoices ({
146
149
  /**
147
150
  * @type {SetFormat}
148
151
  */
149
- async $setFormat (valueFormat, autoTrigger) {
150
- this.value = valueFormat;
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
+ }
151
161
  await this.$buildTypeChoices(autoTrigger);
152
162
  },
153
163