@marianmeres/stuic 1.60.0 → 1.62.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.
@@ -0,0 +1,3 @@
1
+ export declare const preSubmitValidityCheck: (node: HTMLFormElement) => {
2
+ destroy(): void;
3
+ };
@@ -0,0 +1,21 @@
1
+ // this smells like a hack...
2
+ // The problem: custom validity checks via `validate` action are registered on "input" or "change" events.
3
+ // When a form is submitted without touching those custom validated elements, those will not be
4
+ // validity-checked which is not desired... I'm not able to come up with better solution
5
+ // than to manually trigger events which will then trigger the custom validation...
6
+ export const preSubmitValidityCheck = (node) => {
7
+ const onSubmit = () => {
8
+ for (let i = 0; i < node.elements?.length; i++) {
9
+ let el = node.elements[i];
10
+ el.dispatchEvent(new Event('input', { bubbles: true }));
11
+ el.dispatchEvent(new Event('change', { bubbles: true }));
12
+ typeof el.checkValidity === 'function' && !el.checkValidity();
13
+ }
14
+ };
15
+ node.addEventListener('submit', onSubmit, true);
16
+ return {
17
+ destroy() {
18
+ node.removeEventListener('submit', onSubmit, true);
19
+ },
20
+ };
21
+ };
@@ -11,10 +11,10 @@ export declare class DismissibleMessageConfig {
11
11
  declare const __propDef: {
12
12
  props: {
13
13
  class?: {
14
- box?: "" | undefined;
15
- content?: "" | undefined;
16
- dismiss?: "" | undefined;
17
- x?: "" | undefined;
14
+ box?: string | undefined;
15
+ content?: string | undefined;
16
+ dismiss?: string | undefined;
17
+ x?: string | undefined;
18
18
  } | undefined;
19
19
  duration?: number | undefined;
20
20
  message: THC;
@@ -41,9 +41,9 @@ const _PRESET = {
41
41
  placeholder:text-black/35 placeholder:tracking-tight
42
42
  `,
43
43
  invalid: `border-stuic-primary`,
44
- validationMessage: `mt-1 text-xs text-stuic-primary px-2 tracking-tight`,
44
+ validationMessage: `my-1 text-xs text-stuic-primary px-2 tracking-tight`,
45
45
  description: `mx-2 mt-1 text-sm opacity-50`,
46
- below: `mx-2 mt-1`,
46
+ below: `mx-2 my-1`,
47
47
  asterix: `after:content-['*'] after:opacity-30 after:pl-1`
48
48
  };
49
49
  const _PRESET_BY_SIZE = {
@@ -183,7 +183,7 @@ $:
183
183
  class:cursor-not-allowed={disabled}
184
184
  class:opacity-50={disabled}
185
185
  >
186
- <div class="flex items-center">
186
+ <div class="flex">
187
187
  <slot name="input_before" {id} />
188
188
  {#if type === 'textarea'}
189
189
  <textarea
@@ -21,7 +21,6 @@ const _PRESET = {
21
21
  box: "mb-4 grid",
22
22
  // gap-4
23
23
  wrap: `
24
- flex items-center
25
24
  rounded-md border border-gray-300
26
25
  bg-gray-100
27
26
  focus-within:border-stuic-primary
@@ -38,9 +37,9 @@ const _PRESET = {
38
37
  placeholder:text-black/35 placeholder:tracking-tight
39
38
  `,
40
39
  invalid: `border-stuic-primary`,
41
- validationMessage: `mt-1 text-xs text-stuic-primary px-2 tracking-tight`,
40
+ validationMessage: `my-1 text-xs text-stuic-primary px-2 tracking-tight`,
42
41
  description: `mx-2 mt-1 text-sm opacity-50`,
43
- below: `mx-2 mt-1`,
42
+ below: `mx-2 my-1`,
44
43
  asterix: `after:content-['*'] after:opacity-30 after:pl-1`
45
44
  };
46
45
  const _PRESET_BY_SIZE = {
@@ -175,27 +174,29 @@ $:
175
174
  class:cursor-not-allowed={disabled}
176
175
  class:opacity-50={disabled}
177
176
  >
178
- <slot name="input_before" {id} />
179
- <select
180
- class={_inputClass}
181
- bind:value
182
- bind:this={_inputEl}
183
- {id}
184
- {disabled}
185
- {required}
186
- {tabindex}
187
- {autofocus}
188
- {name}
189
- use:validateAction={validate
190
- ? { ...(validate === true ? {} : validate), setValidationResult }
191
- : undefined}
192
- >
193
- {#each _options as o, i}
194
- <option value={o.value}>{o.label}</option>
195
- {/each}
196
- </select>
177
+ <div class="flex">
178
+ <slot name="input_before" {id} />
179
+ <select
180
+ class={_inputClass}
181
+ bind:value
182
+ bind:this={_inputEl}
183
+ {id}
184
+ {disabled}
185
+ {required}
186
+ {tabindex}
187
+ {autofocus}
188
+ {name}
189
+ use:validateAction={validate
190
+ ? { ...(validate === true ? {} : validate), setValidationResult }
191
+ : undefined}
192
+ >
193
+ {#each _options as o, i}
194
+ <option value={o.value}>{o.label}</option>
195
+ {/each}
196
+ </select>
197
197
 
198
- <slot name="input_after" {id} />
198
+ <slot name="input_after" {id} />
199
+ </div>
199
200
  </div>
200
201
  {#if validation && !validation?.valid}
201
202
  <div transition:slide={{ duration: 150 }} class={_validationMessageClass}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.60.0",
3
+ "version": "1.62.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",