@marianmeres/stuic 1.61.0 → 1.63.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 = {
@@ -37,9 +37,9 @@ const _PRESET = {
37
37
  placeholder:text-black/35 placeholder:tracking-tight
38
38
  `,
39
39
  invalid: `border-stuic-primary`,
40
- 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`,
41
41
  description: `mx-2 mt-1 text-sm opacity-50`,
42
- below: `mx-2 mt-1`,
42
+ below: `mx-2 my-1`,
43
43
  asterix: `after:content-['*'] after:opacity-30 after:pl-1`
44
44
  };
45
45
  const _PRESET_BY_SIZE = {
package/dist/index.d.ts CHANGED
@@ -20,12 +20,13 @@ export { default as Popover } from './components/Popover/Popover.svelte';
20
20
  export { default as Switch, SwitchConfig } from './components/Switch/Switch.svelte';
21
21
  export { default as Thc, type THC, isTHCNotEmpty } from './components/Thc/Thc.svelte';
22
22
  export { default as X } from './components/X/X.svelte';
23
+ export { autogrow } from './actions/autogrow.js';
23
24
  export { focusTrap } from './actions/focus-trap.js';
24
25
  export { onOutside } from './actions/on-outside.js';
26
+ export { preSubmitValidityCheck } from './actions/pre-submit-validity-check.js';
25
27
  export { tooltip, TooltipConfig, type TooltipOptions, } from './actions/tooltip/tooltip.js';
26
28
  export { validate, type ValidateOptions, type ValidationResult, } from './actions/validate.js';
27
29
  export { trim } from './actions/trim.js';
28
- export { autogrow } from './actions/autogrow.js';
29
30
  export { calculateAlignment } from './utils/calculate-alignment.js';
30
31
  export { DevicePointer } from './utils/device-pointer.js';
31
32
  export { getId } from './utils/get-id.js';
package/dist/index.js CHANGED
@@ -35,12 +35,13 @@ export { default as Thc, isTHCNotEmpty } from './components/Thc/Thc.svelte';
35
35
  //
36
36
  export { default as X } from './components/X/X.svelte';
37
37
  // actions
38
+ export { autogrow } from './actions/autogrow.js';
38
39
  export { focusTrap } from './actions/focus-trap.js';
39
40
  export { onOutside } from './actions/on-outside.js';
41
+ export { preSubmitValidityCheck } from './actions/pre-submit-validity-check.js';
40
42
  export { tooltip, TooltipConfig, } from './actions/tooltip/tooltip.js';
41
43
  export { validate, } from './actions/validate.js';
42
44
  export { trim } from './actions/trim.js';
43
- export { autogrow } from './actions/autogrow.js';
44
45
  // utils
45
46
  export { calculateAlignment } from './utils/calculate-alignment.js';
46
47
  export { DevicePointer } from './utils/device-pointer.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.61.0",
3
+ "version": "1.63.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",