@marianmeres/stuic 1.23.0 → 1.25.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.
@@ -2,6 +2,7 @@
2
2
  import {
3
3
  AlertConfirmPromptType,
4
4
  Button,
5
+ FieldSelect,
5
6
  createAlertConfirmPromptStore,
6
7
  focusTrap
7
8
  } from "../../index.js";
@@ -27,14 +28,14 @@ export class AlertConfirmPromptConfig {
27
28
  `.trim(),
28
29
  icon: `
29
30
  size-12 sm:size-10
30
- mt-1 mb-4 sm:my-0
31
+ mt-1 mb-4 sm:my-0 sm:mr-5
31
32
  mx-auto
32
33
  flex flex-shrink-0 items-center justify-center
33
34
  rounded-full
34
35
  bg-neutral-100 text-black/50
35
36
  `.trim(),
36
37
  contentBlock: `
37
- mt-3 sm:ml-4 sm:mt-0 sm:flex-1
38
+ mt-3 sm:mt-0 sm:flex-1
38
39
  `.trim(),
39
40
  title: `
40
41
  text-center sm:text-left
@@ -275,8 +276,6 @@ $:
275
276
  } else {
276
277
  iconFn = false;
277
278
  }
278
- $:
279
- clog(dialog);
280
279
  </script>
281
280
 
282
281
  <dialog
@@ -336,15 +335,29 @@ $:
336
335
  data-acp-variant={dialog?.variant}
337
336
  data-acp-is-pending={isPending}
338
337
  >
339
- <Field
340
- class={_inputFieldClass}
341
- bind:value
342
- data-acp-type={dialog?.type}
343
- data-acp-variant={dialog?.variant}
344
- data-acp-is-pending={isPending}
345
- on:input_mounted={({ detail }) => detail.focus()}
346
- size="sm"
347
- />
338
+ {#if dialog?.promptFieldProps?.options?.length}
339
+ <FieldSelect
340
+ class={_inputFieldClass}
341
+ bind:value
342
+ data-acp-type={dialog?.type}
343
+ data-acp-variant={dialog?.variant}
344
+ data-acp-is-pending={isPending}
345
+ on:input_mounted={({ detail }) => detail.focus()}
346
+ size="sm"
347
+ {...dialog.promptFieldProps}
348
+ />
349
+ {:else}
350
+ <Field
351
+ class={_inputFieldClass}
352
+ bind:value
353
+ data-acp-type={dialog?.type}
354
+ data-acp-variant={dialog?.variant}
355
+ data-acp-is-pending={isPending}
356
+ on:input_mounted={({ detail }) => detail.focus()}
357
+ size="sm"
358
+ {...dialog?.promptFieldProps || {}}
359
+ />
360
+ {/if}
348
361
  </div>
349
362
  {/if}
350
363
  </div>
@@ -461,5 +474,5 @@ $:
461
474
  }
462
475
  }
463
476
  .rotating-cw {
464
- animation: rotating-cw 0.6s linear infinite;
477
+ animation: rotating-cw 0.5s linear infinite;
465
478
  }</style>
@@ -21,6 +21,7 @@ interface Dialog extends Record<string, any> {
21
21
  onEscape: FnOnEscape;
22
22
  labelCustom?: THC;
23
23
  onCustom?: FnOnCustom;
24
+ promptFieldProps?: any;
24
25
  variant: AlertConfirmPromptVariant;
25
26
  iconFn: (() => string) | boolean;
26
27
  class?: Partial<{
@@ -5,7 +5,7 @@ export class ButtonConfig {
5
5
  static defaultRounded = true;
6
6
  static defaultVariant = void 0;
7
7
  static presetBase = `
8
- text-center whitespace-nowrap
8
+ text-center
9
9
  inline-flex items-center gap-x-2
10
10
  hover:brightness-[1.05]
11
11
  active:brightness-[0.95]
@@ -49,13 +49,9 @@ export class ButtonConfig {
49
49
  static class = "";
50
50
  // to be defined at consumer level...
51
51
  static variant = {
52
- // primary: `
53
- // bg-[rgb(var(--primary))] text-[rgb(var(--on-primary))]
54
- // dark:bg-[rgb(var(--primary-dark))] dark:text-[rgb(var(--on-primary-dark))]
55
- // `.trim(),
56
52
  primary: `
57
- bg-primary text-on-primary
58
- dark:bg-primary-dark dark:text-on-primary-dark
53
+ bg-stuic-primary text-stuic-on-primary
54
+ dark:bg-stuic-primary-dark dark:text-stuic-on-primary-dark
59
55
  `.trim()
60
56
  };
61
57
  }
@@ -1,4 +1,5 @@
1
- <script>import { slide } from "svelte/transition";
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { slide } from "svelte/transition";
2
3
  import { twMerge } from "tailwind-merge";
3
4
  import {
4
5
  autogrow,
@@ -6,7 +7,6 @@ import {
6
7
  trim,
7
8
  validate as validateAction
8
9
  } from "../../index.js";
9
- import { createEventDispatcher } from "svelte";
10
10
  const dispatch = createEventDispatcher();
11
11
  const setType = (el, t) => el.type = t;
12
12
  const inputSizePreset = {
@@ -23,8 +23,8 @@ let _class = "";
23
23
  export { _class as class };
24
24
  export let labelClass = "";
25
25
  export let wrapClass = "";
26
- export let textareaClass = "";
27
- export let invalidClass = "border-primary";
26
+ export let inputClass = "";
27
+ export let invalidClass = "border-stuic-primary";
28
28
  export let size = "md";
29
29
  export let id = getId();
30
30
  export let value;
@@ -56,7 +56,7 @@ $:
56
56
  if (_inputEl)
57
57
  dispatch("input_mounted", _inputEl);
58
58
  $:
59
- inputClass = twMerge(`
59
+ _inputClass = twMerge(`
60
60
  form-input
61
61
  rounded-md border-0 w-full flex-1
62
62
  bg-transparent
@@ -93,9 +93,9 @@ $:
93
93
  class={twMerge(`
94
94
  rounded-md border border-gray-300
95
95
  bg-gray-100
96
- focus-within:border-primary
96
+ focus-within:border-stuic-primary
97
97
  focus-within:ring-4
98
- focus-within:ring-primary
98
+ focus-within:ring-stuic-primary
99
99
  focus-within:ring-opacity-20
100
100
  ${wrapClass}
101
101
  ${validation && !validation.valid ? invalidClass : ''}
@@ -110,7 +110,7 @@ $:
110
110
  bind:value
111
111
  bind:this={_inputEl}
112
112
  {id}
113
- class={twMerge(`${inputClass} min-h-16 ${textareaClass}`)}
113
+ class={twMerge(`${_inputClass} min-h-16 ${inputClass}`)}
114
114
  class:cursor-not-allowed={disabled}
115
115
  {name}
116
116
  {disabled}
@@ -130,7 +130,7 @@ $:
130
130
  bind:this={_inputEl}
131
131
  use:setType={type}
132
132
  {id}
133
- class={inputClass}
133
+ class={twMerge(`${_inputClass} ${inputClass}`)}
134
134
  class:cursor-not-allowed={disabled}
135
135
  {name}
136
136
  {placeholder}
@@ -160,7 +160,7 @@ $:
160
160
  <div
161
161
  transition:slide={{ duration: 150 }}
162
162
  class={twMerge(
163
- `mt-1 text-xs text-primary px-2 tracking-tight ${validationMessageClass}`
163
+ `mt-1 text-xs text-stuic-primary px-2 tracking-tight ${validationMessageClass}`
164
164
  )}
165
165
  >
166
166
  {@html validation.message}
@@ -6,7 +6,7 @@ declare const __propDef: {
6
6
  class?: string | undefined;
7
7
  labelClass?: string | undefined;
8
8
  wrapClass?: string | undefined;
9
- textareaClass?: string | undefined;
9
+ inputClass?: string | undefined;
10
10
  invalidClass?: string | undefined;
11
11
  size?: "sm" | "md" | "lg" | undefined;
12
12
  id?: string | undefined;
@@ -6,7 +6,7 @@ import { slide } from "svelte/transition";
6
6
  import { getId } from "../../index.js";
7
7
  let _class = "";
8
8
  export { _class as class };
9
- export let invalidClass = "border-primary";
9
+ export let invalidClass = "border-stuic-primary";
10
10
  export let labelClass = "";
11
11
  export let descriptionClass = "";
12
12
  export let size = "md";
@@ -45,12 +45,12 @@ let idDesc = getId();
45
45
  bg-gray-100
46
46
  border-gray-300
47
47
  shadow-sm
48
- text-primary
48
+ text-stuic-primary
49
49
  cursor-pointer
50
- focus:border-primary
50
+ focus:border-stuic-primary
51
51
  focus:ring-4
52
52
  focus:ring-offset-0
53
- focus:ring-primary
53
+ focus:ring-stuic-primary
54
54
  focus:ring-opacity-20
55
55
  disabled:cursor-not-allowed
56
56
  ${validation && !validation.valid ? invalidClass : ''}
@@ -78,7 +78,9 @@ let idDesc = getId();
78
78
  {#if validation && !validation?.valid}
79
79
  <div
80
80
  transition:slide={{ duration: 150 }}
81
- class={twMerge(`text-xs text-primary tracking-tight ${validationMessageClass}`)}
81
+ class={twMerge(
82
+ `text-xs text-stuic-primary tracking-tight ${validationMessageClass}`
83
+ )}
82
84
  >
83
85
  {@html validation.message}
84
86
  </div>
@@ -1,9 +1,11 @@
1
- <script>import { slide } from "svelte/transition";
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { slide } from "svelte/transition";
2
3
  import { twMerge } from "tailwind-merge";
3
4
  import {
4
5
  getId,
5
6
  validate as validateAction
6
7
  } from "../../index.js";
8
+ const dispatch = createEventDispatcher();
7
9
  const inputSizePreset = {
8
10
  sm: "text-sm placeholder:text-sm",
9
11
  md: "text-base placeholder:text-base",
@@ -18,7 +20,7 @@ export let options = [];
18
20
  let _class = "";
19
21
  export { _class as class };
20
22
  export let wrapClass = "";
21
- export let invalidClass = "border-primary";
23
+ export let invalidClass = "border-stuic-primary";
22
24
  export let size = "md";
23
25
  export let id = getId();
24
26
  export let value;
@@ -44,6 +46,10 @@ $:
44
46
  }
45
47
  return v;
46
48
  });
49
+ let _inputEl;
50
+ $:
51
+ if (_inputEl)
52
+ dispatch("input_mounted", _inputEl);
47
53
  $:
48
54
  inputClass = twMerge(`
49
55
  rounded-md border-0 block w-full flex-1
@@ -73,9 +79,9 @@ $:
73
79
  flex items-center
74
80
  rounded-md border border-gray-300
75
81
  bg-gray-100
76
- focus-within:border-primary
82
+ focus-within:border-stuic-primary
77
83
  focus-within:ring-4
78
- focus-within:ring-primary
84
+ focus-within:ring-stuic-primary
79
85
  focus-within:ring-opacity-20
80
86
  ${wrapClass}
81
87
  ${validation && !validation.valid ? invalidClass : ''}
@@ -87,6 +93,7 @@ $:
87
93
  <select
88
94
  class={inputClass}
89
95
  bind:value
96
+ bind:this={_inputEl}
90
97
  {disabled}
91
98
  {required}
92
99
  {tabindex}
@@ -106,7 +113,7 @@ $:
106
113
  <div
107
114
  transition:slide={{ duration: 150 }}
108
115
  class={twMerge(
109
- `mt-1 text-xs text-primary px-2 tracking-tight ${validationMessageClass}`
116
+ `mt-1 text-xs text-stuic-primary px-2 tracking-tight ${validationMessageClass}`
110
117
  )}
111
118
  >
112
119
  {@html validation.message}
@@ -23,6 +23,8 @@ declare const __propDef: {
23
23
  validate?: ValidateOptions | true | undefined;
24
24
  };
25
25
  events: {
26
+ input_mounted: CustomEvent<any>;
27
+ } & {
26
28
  [evt: string]: CustomEvent<any>;
27
29
  };
28
30
  slots: {
@@ -8,7 +8,7 @@ import { createEventDispatcher, onMount } from "svelte";
8
8
  const dispatch = createEventDispatcher();
9
9
  let _class = "";
10
10
  export { _class as class };
11
- export let invalidClass = "border-primary";
11
+ export let invalidClass = "border-stuic-primary";
12
12
  export let labelClass = "";
13
13
  export let descriptionClass = "";
14
14
  export let size = "md";
@@ -50,12 +50,12 @@ let idDesc = getId();
50
50
  bg-gray-100
51
51
  border-gray-300
52
52
  shadow-sm
53
- text-primary
53
+ text-stuic-primary
54
54
  cursor-pointer
55
- focus:border-primary
55
+ focus:border-stuic-primary
56
56
  focus:ring-4
57
57
  focus:ring-offset-0
58
- focus:ring-primary
58
+ focus:ring-stuic-primary
59
59
  focus:ring-opacity-20
60
60
  disabled:cursor-not-allowed
61
61
  ${validation && !validation.valid ? invalidClass : ''}
@@ -82,7 +82,9 @@ let idDesc = getId();
82
82
  {#if validation && !validation?.valid}
83
83
  <div
84
84
  transition:slide={{ duration: 150 }}
85
- class={twMerge(`text-xs text-primary tracking-tight ${validationMessageClass}`)}
85
+ class={twMerge(
86
+ `text-xs text-stuic-primary tracking-tight ${validationMessageClass}`
87
+ )}
86
88
  >
87
89
  {@html validation.message}
88
90
  </div>
@@ -12,4 +12,7 @@ export let thc;
12
12
  {@html thc.html}
13
13
  {:else if thc?.component}
14
14
  <svelte:component this={thc.component} {...thc?.props || {}} />
15
+ {:else}
16
+ <!-- cast to string as the last resort -->
17
+ {thc}
15
18
  {/if}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.23.0",
3
+ "version": "1.25.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",