@marianmeres/stuic 1.22.0 → 1.24.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
@@ -145,10 +146,10 @@ export class AlertConfirmPromptConfig {
145
146
  };
146
147
  }
147
148
  const _isFn = (v) => typeof v === "function";
148
- const { ALERT, CONFIRM, PROMPT } = AlertConfirmPromptType;
149
149
  </script>
150
150
 
151
- <script>const clog = createClog("AlertConfirmPrompt");
151
+ <script>const { ALERT, CONFIRM, PROMPT } = AlertConfirmPromptType;
152
+ const clog = createClog("AlertConfirmPrompt");
152
153
  export let acp;
153
154
  $:
154
155
  dialog = $acp[0];
@@ -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<{
@@ -1,6 +1,11 @@
1
1
  import { createStore } from '@marianmeres/store';
2
2
  import { createClog } from '@marianmeres/clog';
3
3
  const clog = createClog('alert-confirm-prompt');
4
+ // export class AlertConfirmPromptType {
5
+ // static readonly ALERT: 'alert';
6
+ // static readonly CONFIRM: 'confirm';
7
+ // static readonly PROMPT: 'prompt';
8
+ // }
4
9
  export var AlertConfirmPromptType;
5
10
  (function (AlertConfirmPromptType) {
6
11
  AlertConfirmPromptType["ALERT"] = "alert";
@@ -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]
@@ -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,7 +23,7 @@ let _class = "";
23
23
  export { _class as class };
24
24
  export let labelClass = "";
25
25
  export let wrapClass = "";
26
- export let textareaClass = "";
26
+ export let inputClass = "";
27
27
  export let invalidClass = "border-primary";
28
28
  export let size = "md";
29
29
  export let id = getId();
@@ -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
@@ -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}
@@ -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;
@@ -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",
@@ -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
@@ -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}
@@ -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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package && node ./scripts/date.js",