@cloudparker/moldex.js 4.1.3 → 4.1.5

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.
@@ -4,7 +4,7 @@
4
4
  | 'primary'
5
5
  | 'base'
6
6
  | 'border'
7
- | 'border-base'
7
+ | 'border-neutral'
8
8
  | 'border-primary';
9
9
 
10
10
  export type ButtonSize = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
@@ -99,7 +99,7 @@
99
99
  case 'primary':
100
100
  return 'text-primary-100 hover:text-primary-50 bg-primary-600 hover:bg-primary-500 disabled:text-neutral-400 dark:disabled:text-neutral-500 disabled:bg-neutral-200 dark:disabled:bg-neutral-700 disabled:hover:bg-neutral-200 dark:disabled:hover:bg-neutral-700 ';
101
101
  case 'border':
102
- case 'border-base':
102
+ case 'border-neutral':
103
103
  return 'border-2 text-neutral-800 dark:text-neutral-300 hover:text-neutral-900 disabled:text-neutral-400 dark:disabled:text-neutral-500 dark:hover:text-neutral-200 border-neutral-200 hover:border-neutral-300 dark:border-neutral-700 dark:hover:border-neutral-600 dark:disabled:border-neutral-200 dark:disabled:hover:border-neutral-200 dark:disabled:border-neutral-700 dark:disabled:hover:border-neutral-700 ';
104
104
  case 'border-primary':
105
105
  return 'border-2 text-primary hover:text-primary-500 disabled:text-neutral-400 dark:disabled:text-neutral-500 border-primary hover:border-primary-500 dark:border-primary-600 dark:hover:border-primary-500 dark:disabled:border-neutral-200 dark:disabled:hover:border-neutral-200 dark:disabled:border-neutral-700 dark:disabled:hover:border-neutral-700 ';
@@ -1,4 +1,4 @@
1
- export type ButtonAppearance = 'none' | 'primary' | 'base' | 'border' | 'border-base' | 'border-primary';
1
+ export type ButtonAppearance = 'none' | 'primary' | 'base' | 'border' | 'border-neutral' | 'border-primary';
2
2
  export type ButtonSize = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
3
3
  export type ButtonType = 'button' | 'submit' | 'reset';
4
4
  export type ButtonProps = {
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
- import { isSmallScreen } from '../../../../../services';
3
- import { mdiArrowLeft } from '../../../icon';
2
+ import { isSmallScreen } from '../../../../../services/index.js';
3
+ import { mdiArrowLeft } from '../../../icon/index.js';
4
+
4
5
  import Button from '../button/button.svelte';
5
6
 
6
7
  type PropsType = {
@@ -21,11 +22,7 @@
21
22
  onClick
22
23
  }: PropsType = $props();
23
24
 
24
- let isMobileScreen = $state(false);
25
-
26
- $effect(() => {
27
- isMobileScreen = isSmallScreen();
28
- });
25
+ let isMobileScreen = $derived(isSmallScreen() || false);
29
26
  </script>
30
27
 
31
28
  {#snippet button()}
@@ -1,6 +1,8 @@
1
1
  <script lang="ts">
2
- import { isSmallScreen } from '../../../../../services';
3
- import { mdiArrowLeft, mdiChevronRight, mdiClose } from '../../../icon';
2
+ import { isSmallScreen } from '../../../../../services/index.js';
3
+ import { mdiClose } from '../../../icon/index.js';
4
+
5
+
4
6
  import Button from '../button/button.svelte';
5
7
 
6
8
  type PropsType = {
@@ -22,11 +24,8 @@
22
24
  onClick
23
25
  }: PropsType = $props();
24
26
 
25
- let isMobileScreen = $state(false);
27
+ let isMobileScreen = $state(isSmallScreen() || false);
26
28
 
27
- $effect(() => {
28
- isMobileScreen = isSmallScreen();
29
- });
30
29
  </script>
31
30
 
32
31
  {#snippet button()}
@@ -19,11 +19,9 @@
19
19
  sizeClassName = 'w-6 h-6'
20
20
  }: IconPropsType = $props();
21
21
 
22
- $effect(() => {
23
- viewBox = viewBox || `0 0 ${size} ${size}`;
24
- });
22
+ let viewBoxDerived = $derived(viewBox || `0 0 ${size} ${size}`);
25
23
  </script>
26
24
 
27
- <svg class="align-middle {sizeClassName} {className}" {viewBox} fill={color || fill}>
25
+ <svg class="align-middle {sizeClassName} {className}" viewBox={viewBoxDerived} fill={color || fill}>
28
26
  <path d={path} />
29
27
  </svg>
@@ -1,8 +1,10 @@
1
1
  <script lang="ts">
2
- import { ripple } from '../../../../../actions';
3
- import { colorToHex, isValidHexColor } from '../../../../../services';
4
- import { mdiSquare } from '../../../icon';
2
+ import { ripple } from '../../../../../actions/ripple.js';
3
+ import { colorToHex, isValidHexColor } from '../../../../../services/index.js';
4
+
5
+
5
6
  import Icon from '../../../icon/components/icon/icon.svelte';
7
+ import { mdiSquare } from '../../../icon/index.js';
6
8
  import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
7
9
 
8
10
  let {
@@ -15,9 +17,41 @@
15
17
  }: InputFieldProps & { value?: string } = $props();
16
18
 
17
19
  let colorRef: HTMLInputElement;
18
- let btnIconSizeClassName: string = $state('');
19
- let btnRoundedClassName: string = $state('');
20
- let colorValue: string = $state('#000000');
20
+
21
+ let btnIconSizeClassName: string = $derived.by(() => {
22
+ let className = '';
23
+ if (size) {
24
+ switch (size) {
25
+ case 'lg':
26
+ className = '!h-7 !w-7';
27
+ break;
28
+ case 'md':
29
+ className = '!h-6 !w-6';
30
+ break;
31
+ case 'sm':
32
+ className = '!h-5 !w-5';
33
+ break;
34
+ case 'xs':
35
+ className = '!h-4 !w-4';
36
+ break;
37
+ }
38
+ }
39
+ return className;
40
+ });
41
+
42
+ let btnRoundedClassName: string = $derived.by(() => {
43
+ if (!appearance || appearance == 'normal') {
44
+ return 'rounded-tr-lg rounded-br-lg';
45
+ }
46
+ return '';
47
+ });
48
+
49
+ let colorValue: string = $derived.by(() => {
50
+ if (isValidHexColor(value)) {
51
+ colorValue = value;
52
+ }
53
+ return '#000000';
54
+ });
21
55
 
22
56
  let inputRef: any | null = $state(null);
23
57
 
@@ -48,44 +82,18 @@
48
82
 
49
83
  $effect(() => {
50
84
  if (isValidHexColor(value)) {
51
- colorValue = value;
52
85
  if (colorRef) {
53
86
  colorRef.value = colorToHex(value);
54
87
  }
55
88
  }
56
89
  });
57
-
58
- $effect(() => {
59
- if (size) {
60
- switch (size) {
61
- case 'lg':
62
- btnIconSizeClassName = '!h-7 !w-7';
63
- break;
64
- case 'md':
65
- btnIconSizeClassName = '!h-6 !w-6';
66
- break;
67
- case 'sm':
68
- btnIconSizeClassName = '!h-5 !w-5';
69
- break;
70
- case 'xs':
71
- btnIconSizeClassName = '!h-4 !w-4';
72
- break;
73
- }
74
- }
75
- });
76
-
77
- $effect(() => {
78
- if (!appearance || appearance == 'normal') {
79
- btnRoundedClassName = 'rounded-tr-lg rounded-br-lg';
80
- }
81
- });
82
90
  </script>
83
91
 
84
92
  {#snippet colorButton()}
85
93
  <button
86
94
  id="btn-color-picker-{name || id}"
87
95
  type="button"
88
- class="px-2 h-full hover:bg-neutral-100 dark:hover:bg-neutral-900 focus:outline-primary {btnRoundedClassName}"
96
+ class="h-full px-2 hover:bg-neutral-100 focus:outline-primary dark:hover:bg-neutral-900 {btnRoundedClassName}"
89
97
  use:ripple
90
98
  onclick={handleColorBtnClick}
91
99
  >
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
- import { dateFormat, toDate } from '../../../../../services';
2
+ import { dateFormat, toDate } from '../../../../../services/index.js';
3
+
4
+
3
5
  import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
4
6
 
5
7
  let {
@@ -7,15 +9,14 @@
7
9
  ...props
8
10
  }: InputFieldProps & { value?: Date | string | number | null | undefined } = $props();
9
11
 
10
- let _value: string | undefined = $state(undefined);
11
-
12
- $effect(() => {
12
+ let _value: string | undefined = $derived.by(() => {
13
13
  if (value) {
14
- _value = dateFormat(toDate(value)!, 'YYYY-MM-DD') as string;
15
- console.log('_value', _value);
14
+ return dateFormat(toDate(value)!, 'YYYY-MM-DD') as string;
16
15
  }
17
16
  });
18
17
 
18
+
19
+
19
20
  let inputFieldRef: any | null = $state(null);
20
21
 
21
22
  export function focus() {
@@ -1,8 +1,10 @@
1
1
  <script lang="ts">
2
- import { ripple } from '../../../../../actions';
3
- import { openFilePickerDialog } from '../../../../../services';
4
- import { mdiAttachment } from '../../../icon';
2
+ import { ripple } from '../../../../../actions/ripple.js';
3
+ import { openFilePickerDialog } from '../../../../../services/index.js';
4
+
5
+
5
6
  import Icon from '../../../icon/components/icon/icon.svelte';
7
+ import { mdiAttachment } from '../../../icon/index.js';
6
8
  import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
7
9
 
8
10
  let {
@@ -19,8 +21,33 @@
19
21
  value?: File | File[] | null;
20
22
  } = $props();
21
23
 
22
- let btnRoundedClassName = $state('');
23
- let btnIconSizeClassName = $state('');
24
+ let btnRoundedClassName = $derived.by(() => {
25
+ if (!appearance || appearance == 'normal') {
26
+ return 'rounded-tr-lg rounded-br-lg';
27
+ }
28
+ return '';
29
+ });
30
+
31
+ let btnIconSizeClassName = $derived.by(() => {
32
+ let className = '';
33
+ if (size) {
34
+ switch (size) {
35
+ case 'lg':
36
+ className = '!h-7 !w-7';
37
+ break;
38
+ case 'md':
39
+ className = '!h-6 !w-6';
40
+ break;
41
+ case 'sm':
42
+ className = '!h-5 !w-5';
43
+ break;
44
+ case 'xs':
45
+ className = '!h-4 !w-4';
46
+ break;
47
+ }
48
+ }
49
+ return className;
50
+ });
24
51
  let fileNameDisplay = $state('');
25
52
 
26
53
  let inputFieldRef: any | null = $state(null);
@@ -51,38 +78,13 @@
51
78
  }
52
79
  }
53
80
  }
54
-
55
- $effect(() => {
56
- if (size) {
57
- switch (size) {
58
- case 'lg':
59
- btnIconSizeClassName = '!h-7 !w-7';
60
- break;
61
- case 'md':
62
- btnIconSizeClassName = '!h-6 !w-6';
63
- break;
64
- case 'sm':
65
- btnIconSizeClassName = '!h-5 !w-5';
66
- break;
67
- case 'xs':
68
- btnIconSizeClassName = '!h-4 !w-4';
69
- break;
70
- }
71
- }
72
- });
73
-
74
- $effect(() => {
75
- if (!appearance || appearance == 'normal') {
76
- btnRoundedClassName = 'rounded-tr-lg rounded-br-lg';
77
- }
78
- });
79
81
  </script>
80
82
 
81
83
  {#snippet fileButton()}
82
84
  <button
83
85
  id="btn-file-picker"
84
86
  type="button"
85
- class="px-3 h-full hover:bg-gray-100 focus:outline-primary {btnRoundedClassName} "
87
+ class="h-full px-3 hover:bg-gray-100 focus:outline-primary {btnRoundedClassName} "
86
88
  use:ripple
87
89
  onclick={handleFileAttachment}
88
90
  >
@@ -156,7 +156,7 @@
156
156
  if (size) {
157
157
  switch (size) {
158
158
  case 'lg':
159
- sizeClassName = 'p-4 text-base';
159
+ sizeClassName = 'p-4 text-neutral';
160
160
  break;
161
161
  case 'md':
162
162
  sizeClassName = 'p-2.5 text-sm';
@@ -202,7 +202,7 @@
202
202
  if (size) {
203
203
  switch (size) {
204
204
  case 'lg':
205
- className = 'text-base';
205
+ className = 'text-neutral';
206
206
  break;
207
207
  case 'md':
208
208
  className = 'text-sm';
@@ -1,7 +1,9 @@
1
1
  <script lang="ts">
2
- import { ripple } from '../../../../../actions';
3
- import { mdiEyeOffOutline, mdiEyeOutline } from '../../../icon';
2
+ import { ripple } from '../../../../../actions/ripple.js';
3
+
4
+
4
5
  import Icon from '../../../icon/components/icon/icon.svelte';
6
+ import { mdiEyeOffOutline, mdiEyeOutline } from '../../../icon/index.js';
5
7
  import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
6
8
 
7
9
  let {
@@ -19,8 +21,33 @@
19
21
  iconClassName?: string;
20
22
  } = $props();
21
23
 
22
- let btnRoundedClassName = $state('');
23
- let btnIconSizeClassName = $state('');
24
+ let btnRoundedClassName = $derived.by(() => {
25
+ if (!appearance || appearance == 'normal') {
26
+ return 'rounded-tr-lg rounded-br-lg';
27
+ }
28
+ return '';
29
+ });
30
+
31
+ let btnIconSizeClassName = $derived.by(() => {
32
+ let className = '';
33
+ if (size) {
34
+ switch (size) {
35
+ case 'lg':
36
+ className = '!h-7 !w-7';
37
+ break;
38
+ case 'md':
39
+ className = '!h-6 !w-6';
40
+ break;
41
+ case 'sm':
42
+ className = '!h-5 !w-5';
43
+ break;
44
+ case 'xs':
45
+ className = '!h-4 !w-4';
46
+ break;
47
+ }
48
+ }
49
+ return className;
50
+ });
24
51
 
25
52
  let inputFieldRef: any | null = $state(null);
26
53
 
@@ -44,37 +71,14 @@
44
71
  }
45
72
  }
46
73
 
47
- $effect(() => {
48
- if (size) {
49
- switch (size) {
50
- case 'lg':
51
- btnIconSizeClassName = '!h-7 !w-7';
52
- break;
53
- case 'md':
54
- btnIconSizeClassName = '!h-6 !w-6';
55
- break;
56
- case 'sm':
57
- btnIconSizeClassName = '!h-5 !w-5';
58
- break;
59
- case 'xs':
60
- btnIconSizeClassName = '!h-4 !w-4';
61
- break;
62
- }
63
- }
64
- });
65
-
66
- $effect(() => {
67
- if (!appearance || appearance == 'normal') {
68
- btnRoundedClassName = 'rounded-tr-lg rounded-br-lg';
69
- }
70
- });
74
+
71
75
  </script>
72
76
 
73
77
  {#snippet showPasswordButton()}
74
78
  <button
75
79
  id="btn-eye-{name || id}"
76
80
  type="button"
77
- class="px-3 h-full hover:bg-neutral-100 focus:outline-primary {btnRoundedClassName} {buttonClassName}"
81
+ class="h-full px-3 hover:bg-neutral-100 focus:outline-primary {btnRoundedClassName} {buttonClassName}"
78
82
  use:ripple
79
83
  onclick={handleTogglePassword}
80
84
  >
@@ -156,7 +156,7 @@
156
156
  </script>
157
157
 
158
158
  {#snippet dialCodePickerItemTile(item: any, index: number)}
159
- <div class="w-14 text-sm font-bold text-base">
159
+ <div class="w-14 text-sm font-bold text-neutral">
160
160
  {item.dialCode}
161
161
  </div>
162
162
  <div class="flex-grow">
@@ -32,23 +32,23 @@
32
32
  onfocus
33
33
  }: RangeFieldPropsType = $props();
34
34
 
35
- let rangeSizeClassName = $state('');
36
-
37
- $effect(() => {
35
+ let rangeSizeClassName = $derived.by(() => {
36
+ let className = '';
38
37
  switch (size) {
39
38
  case 'lg':
40
- rangeSizeClassName = 'h-3 ';
39
+ className = 'h-3 ';
41
40
  break;
42
41
  case 'md':
43
- rangeSizeClassName = 'h-2 ';
42
+ className = 'h-2 ';
44
43
  break;
45
44
  case 'sm':
46
- rangeSizeClassName = 'h-1 ';
45
+ className = 'h-1 ';
47
46
  break;
48
47
  case 'xs':
49
- rangeSizeClassName = 'h-2-px ';
48
+ className = 'h-2-px ';
50
49
  break;
51
50
  }
51
+ return className;
52
52
  });
53
53
 
54
54
  let inputRef: HTMLInputElement | null = $state(null);
@@ -72,7 +72,7 @@
72
72
  {id}
73
73
  {name}
74
74
  type="range"
75
- class="range-slider w-full bg-gray-200 appearance-none cursor-pointer dark:bg-gray-700 rounded-lg range-lg outline-none focus:outline-none {rangeSizeClassName} {className}"
75
+ class="range-slider range-lg w-full cursor-pointer appearance-none rounded-lg bg-gray-200 outline-none focus:outline-none dark:bg-gray-700 {rangeSizeClassName} {className}"
76
76
  {min}
77
77
  {max}
78
78
  {step}
@@ -29,11 +29,8 @@
29
29
  right: 'flex-row-reverse'
30
30
  };
31
31
 
32
- let iconPlacementClassName: string = $state('');
33
-
34
- $effect(() => {
35
- iconPlacementClassName = iconPlacementClassNameMap[iconPlacement];
36
- });
32
+ let iconPlacementClassName: string = $derived(iconPlacementClassNameMap[iconPlacement]);
33
+
37
34
  </script>
38
35
 
39
36
  <div
@@ -17,28 +17,23 @@
17
17
  children
18
18
  }: PropsType = $props();
19
19
 
20
- let progressValue: number = $state(0);
21
-
22
- $effect(() => {
23
- if (!className) {
24
- className = 'h-4';
25
- }
26
- });
27
-
28
- $effect(() => {
20
+ let progressValue: number = $derived.by(() => {
21
+ let v = value;
29
22
  if (value < 0) {
30
- progressValue = 0;
23
+ v = 0;
31
24
  } else if (value >= 100) {
32
- progressValue = 100;
25
+ v = 100;
33
26
  } else {
34
- progressValue = value;
27
+ v = value;
35
28
  }
29
+ return v;
36
30
  });
31
+
37
32
  </script>
38
33
 
39
- <div class="w-full bg-gray-200 rounded-full progressbar-container {backgroundClassName}" style="">
34
+ <div class="progressbar-container w-full rounded-full bg-gray-200 {backgroundClassName}" style="">
40
35
  <div
41
- class="bg-indigo-600 rounded-full transition-all ease-in-out text-center text-xs text-white progressbar {className}"
36
+ class="progressbar rounded-full bg-indigo-600 text-center text-xs text-white transition-all ease-in-out {className}"
42
37
  style="--progressWidth:{progressValue}%;"
43
38
  >
44
39
  {#if children}
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
- import { handleScreenSizeUpdate } from '../../../../services';
3
- import { BROWSER } from 'esm-env';
2
+ import { handleScreenSizeUpdate } from '../../../../services/index.js';
3
+
4
+ import { onMount } from 'svelte';
4
5
 
5
6
  let innerWidth: number = $state(0);
6
7
 
@@ -8,8 +9,8 @@
8
9
  handleScreenSizeUpdate(size);
9
10
  }
10
11
 
11
- $effect(() => {
12
- BROWSER && screenSizeChanged(innerWidth);
12
+ onMount(() => {
13
+ screenSizeChanged(innerWidth);
13
14
  });
14
15
  </script>
15
16
 
@@ -1,7 +1,10 @@
1
1
  <script lang="ts">
2
- import { dateFormat, dateToAgo, toDate } from '../../../../../services';
2
+ import { dateFormat, dateToAgo, toDate } from '../../../../../services/index.js';
3
+
4
+
3
5
 
4
6
  import { BROWSER } from 'esm-env';
7
+ import { onMount } from 'svelte';
5
8
 
6
9
  type PropsType = {
7
10
  input: Date | number | string | { seconds: number; nanoseconds: number };
@@ -27,8 +30,8 @@
27
30
  }
28
31
  }
29
32
 
30
- $effect(() => {
31
- BROWSER && prepareDate(input);
33
+ onMount(() => {
34
+ prepareDate(input);
32
35
  });
33
36
  </script>
34
37
 
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import EasyScriptLoader from '@cloudparker/easy-script-loader-svelte';
3
3
  import { BROWSER } from 'esm-env';
4
+ import { mount, onMount } from 'svelte';
4
5
 
5
6
  let { input }: { input: string } = $props();
6
7
 
@@ -31,8 +32,8 @@
31
32
  init();
32
33
  }
33
34
 
34
- $effect(() => {
35
- BROWSER && prepare(input, states);
35
+ onMount(() => {
36
+ prepare(input, states);
36
37
  });
37
38
  </script>
38
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudparker/moldex.js",
3
- "version": "4.1.3",
3
+ "version": "4.1.5",
4
4
  "keywords": [
5
5
  "svelte"
6
6
  ],