@dvcol/neo-svelte 0.1.3 → 0.1.4

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.
Files changed (150) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +25 -26
  3. package/dist/buttons/NeoButton.svelte +140 -128
  4. package/dist/buttons/NeoButtonGroup.svelte +99 -108
  5. package/dist/buttons/neo-button-group.model.d.ts +18 -19
  6. package/dist/buttons/neo-button.model.d.ts +6 -10
  7. package/dist/cards/NeoCard.svelte +175 -72
  8. package/dist/cards/NeoCard.svelte.d.ts +1 -1
  9. package/dist/cards/neo-card.model.d.ts +29 -1
  10. package/dist/containers/NeoTransitionContainer.svelte +13 -2
  11. package/dist/containers/neo-transition-container.model.d.ts +9 -1
  12. package/dist/divider/NeoDivider.svelte +11 -11
  13. package/dist/icons/IconAccount.svelte +10 -2
  14. package/dist/icons/IconAdd.svelte +10 -2
  15. package/dist/icons/IconAlert.svelte +2 -2
  16. package/dist/icons/IconCalendar.svelte +23 -0
  17. package/dist/icons/IconCalendar.svelte.d.ts +26 -0
  18. package/dist/icons/IconCheckbox.svelte +87 -0
  19. package/dist/icons/IconCheckbox.svelte.d.ts +55 -0
  20. package/dist/icons/IconCircleLoading.svelte +2 -2
  21. package/dist/icons/IconClear.svelte +10 -2
  22. package/dist/icons/IconClose.svelte +2 -2
  23. package/dist/icons/IconConfirm.svelte +2 -2
  24. package/dist/icons/IconDownload.svelte +17 -0
  25. package/dist/icons/IconDownload.svelte.d.ts +26 -0
  26. package/dist/icons/IconEmpty.svelte +2 -2
  27. package/dist/icons/IconFileUpload.svelte +2 -2
  28. package/dist/icons/IconGithub.svelte +2 -2
  29. package/dist/icons/IconImage.svelte +2 -2
  30. package/dist/icons/IconMinus.svelte +2 -2
  31. package/dist/icons/IconMoon.svelte +2 -2
  32. package/dist/icons/IconPaint.svelte +19 -0
  33. package/dist/icons/{IconSunrise.svelte.d.ts → IconPaint.svelte.d.ts} +3 -3
  34. package/dist/icons/IconPencil.svelte +13 -0
  35. package/dist/icons/IconPencil.svelte.d.ts +26 -0
  36. package/dist/icons/IconRadio.svelte +14 -0
  37. package/dist/icons/IconRadio.svelte.d.ts +22 -0
  38. package/dist/icons/IconSave.svelte +1 -1
  39. package/dist/icons/IconSave.svelte.d.ts +3 -3
  40. package/dist/icons/IconSaveOff.svelte +1 -1
  41. package/dist/icons/IconSaveOff.svelte.d.ts +3 -3
  42. package/dist/icons/IconSearch.svelte +2 -2
  43. package/dist/icons/IconSun.svelte +3 -3
  44. package/dist/icons/{IconSunrise.svelte → IconSunFull.svelte} +5 -4
  45. package/dist/icons/IconSunFull.svelte.d.ts +26 -0
  46. package/dist/icons/IconVideo.svelte +2 -2
  47. package/dist/icons/IconWatch.svelte +2 -2
  48. package/dist/icons/IconWatchOff.svelte +2 -2
  49. package/dist/inputs/NeoCheckbox.svelte +316 -0
  50. package/dist/inputs/NeoCheckbox.svelte.d.ts +19 -0
  51. package/dist/inputs/NeoColorPicker.svelte +140 -0
  52. package/dist/inputs/NeoColorPicker.svelte.d.ts +19 -0
  53. package/dist/inputs/NeoDateTime.svelte +96 -0
  54. package/dist/inputs/NeoDateTime.svelte.d.ts +19 -0
  55. package/dist/inputs/NeoFilePicker.svelte +528 -0
  56. package/dist/inputs/NeoFilePicker.svelte.d.ts +19 -0
  57. package/dist/inputs/NeoFilePickerCard.svelte +314 -0
  58. package/dist/inputs/NeoFilePickerCard.svelte.d.ts +19 -0
  59. package/dist/inputs/NeoNumberStep.svelte +174 -0
  60. package/dist/inputs/NeoNumberStep.svelte.d.ts +19 -0
  61. package/dist/inputs/NeoPassword.svelte +86 -17
  62. package/dist/inputs/NeoPassword.svelte.d.ts +19 -16
  63. package/dist/inputs/NeoPin.svelte +589 -0
  64. package/dist/inputs/NeoPin.svelte.d.ts +19 -0
  65. package/dist/inputs/NeoRadio.svelte +254 -0
  66. package/dist/inputs/NeoRadio.svelte.d.ts +19 -0
  67. package/dist/inputs/NeoRange.svelte +518 -0
  68. package/dist/inputs/NeoRange.svelte.d.ts +18 -0
  69. package/dist/inputs/NeoSwitch.svelte +373 -0
  70. package/dist/inputs/NeoSwitch.svelte.d.ts +19 -0
  71. package/dist/inputs/NeoTextarea.svelte +334 -300
  72. package/dist/inputs/NeoTextarea.svelte.d.ts +7 -4
  73. package/dist/inputs/common/NeoAffix.svelte +166 -0
  74. package/dist/inputs/common/NeoAffix.svelte.d.ts +19 -0
  75. package/dist/inputs/common/NeoBaseInput.svelte +338 -0
  76. package/dist/inputs/common/NeoBaseInput.svelte.d.ts +30 -0
  77. package/dist/inputs/common/NeoInput.svelte +684 -0
  78. package/dist/inputs/{NeoInput.svelte.d.ts → common/NeoInput.svelte.d.ts} +2 -10
  79. package/dist/inputs/common/NeoInputValidation.svelte +45 -0
  80. package/dist/inputs/common/NeoInputValidation.svelte.d.ts +22 -0
  81. package/dist/inputs/common/NeoLabel.svelte +93 -0
  82. package/dist/inputs/common/NeoLabel.svelte.d.ts +19 -0
  83. package/dist/inputs/{NeoValidation.svelte → common/NeoValidation.svelte} +9 -16
  84. package/dist/inputs/common/NeoValidation.svelte.d.ts +22 -0
  85. package/dist/inputs/common/neo-affix.model.d.ts +32 -0
  86. package/dist/inputs/common/neo-input-validation.model.d.ts +20 -0
  87. package/dist/inputs/common/neo-input-validation.model.js +1 -0
  88. package/dist/inputs/{neo-input.model.d.ts → common/neo-input.model.d.ts} +136 -57
  89. package/dist/inputs/common/neo-label.model.d.ts +36 -0
  90. package/dist/inputs/common/neo-label.model.js +1 -0
  91. package/dist/inputs/common/neo-validation.model.d.ts +70 -0
  92. package/dist/inputs/common/neo-validation.model.js +1 -0
  93. package/dist/inputs/index.d.ts +2 -2
  94. package/dist/inputs/index.js +1 -1
  95. package/dist/inputs/neo-checkbox.model.d.ts +9 -0
  96. package/dist/inputs/neo-checkbox.model.js +1 -0
  97. package/dist/inputs/neo-color-picker.model.d.ts +17 -0
  98. package/dist/inputs/neo-color-picker.model.js +1 -0
  99. package/dist/inputs/neo-date-time.model.d.ts +8 -0
  100. package/dist/inputs/neo-date-time.model.js +1 -0
  101. package/dist/inputs/neo-file-picker.model.d.ts +138 -0
  102. package/dist/inputs/neo-file-picker.model.js +1 -0
  103. package/dist/inputs/neo-number-step.model.d.ts +24 -0
  104. package/dist/inputs/neo-number-step.model.js +1 -0
  105. package/dist/inputs/neo-password.model.d.ts +13 -0
  106. package/dist/inputs/neo-password.model.js +1 -0
  107. package/dist/inputs/neo-pin.model.d.ts +47 -0
  108. package/dist/inputs/neo-pin.model.js +1 -0
  109. package/dist/inputs/neo-radio.model.d.ts +3 -0
  110. package/dist/inputs/neo-radio.model.js +1 -0
  111. package/dist/inputs/neo-switch.model.d.ts +9 -0
  112. package/dist/inputs/neo-switch.model.js +1 -0
  113. package/dist/nav/NeoTab.svelte +29 -25
  114. package/dist/nav/NeoTabPanel.svelte +1 -1
  115. package/dist/nav/NeoTabs.svelte +51 -44
  116. package/dist/nav/NeoTabsCard.svelte +8 -10
  117. package/dist/nav/neo-tabs-context.svelte.d.ts +2 -11
  118. package/dist/nav/neo-tabs-context.svelte.js +1 -41
  119. package/dist/nav/neo-tabs.model.d.ts +6 -0
  120. package/dist/providers/NeoThemeProvider.svelte +417 -305
  121. package/dist/providers/NeoThemeSelector.svelte +9 -9
  122. package/dist/providers/neo-theme-provider-context.svelte.js +1 -1
  123. package/dist/providers/neo-theme-selector.model.d.ts +1 -1
  124. package/dist/skeletons/NeoSkeletonMedia.svelte +4 -4
  125. package/dist/skeletons/NeoSkeletonText.svelte +12 -12
  126. package/dist/styles/common/colors.scss +85 -97
  127. package/dist/styles/common/filters.scss +17 -0
  128. package/dist/styles/common/shadows.scss +531 -293
  129. package/dist/styles/common/spacing.scss +7 -3
  130. package/dist/styles/common/typography.scss +1 -1
  131. package/dist/styles/common/utils.scss +1 -1
  132. package/dist/styles/common/z-index.scss +1 -1
  133. package/dist/styles/mixin.scss +79 -26
  134. package/dist/styles/reset.scss +8 -1
  135. package/dist/styles/theme.scss +39 -16
  136. package/dist/utils/html-element.utils.d.ts +3 -0
  137. package/dist/utils/regex.utils.d.ts +3 -0
  138. package/dist/utils/regex.utils.js +3 -0
  139. package/dist/utils/shadow.utils.d.ts +30 -3
  140. package/dist/utils/shadow.utils.js +41 -14
  141. package/dist/utils/transition.utils.d.ts +4 -0
  142. package/dist/utils/transition.utils.js +10 -1
  143. package/dist/utils/utils.svelte.d.ts +6 -0
  144. package/dist/utils/utils.svelte.js +13 -0
  145. package/package.json +13 -12
  146. package/dist/inputs/NeoInput.svelte +0 -750
  147. package/dist/inputs/NeoValidation.svelte.d.ts +0 -22
  148. package/dist/inputs/neo-validation.model.d.ts +0 -40
  149. /package/dist/inputs/{neo-validation.model.js → common/neo-affix.model.js} +0 -0
  150. /package/dist/inputs/{neo-input.model.js → common/neo-input.model.js} +0 -0
@@ -0,0 +1,45 @@
1
+ <script lang="ts" generics="T extends HTMLElement, V extends any">
2
+ import type { NeoInputValidationProps } from './neo-input-validation.model.js';
3
+
4
+ import NeoValidation from './NeoValidation.svelte';
5
+
6
+ /* eslint-disable prefer-const -- necessary for binding checked */
7
+ let {
8
+ // Snippets
9
+ children,
10
+ error,
11
+
12
+ // States
13
+ visible = $bindable(false),
14
+ validation,
15
+ validationMessage,
16
+
17
+ message,
18
+ valid,
19
+
20
+ // Other props
21
+ messageProps,
22
+ messageId = $bindable(messageProps?.id ?? `neo-validation-message-${crypto.randomUUID()}`),
23
+ ...rest
24
+ }: NeoInputValidationProps<T, V> = $props();
25
+ /* eslint-enable prefer-const */
26
+
27
+ const errorMessage = $derived.by(() => {
28
+ if (valid !== false) return;
29
+ if (error) return error;
30
+ if (!validation) return;
31
+ return validationMessage;
32
+ });
33
+
34
+ const showMessage = $derived(message || errorMessage || error || validation);
35
+
36
+ $effect(() => {
37
+ visible = !!showMessage;
38
+ });
39
+ </script>
40
+
41
+ {#if showMessage}
42
+ <NeoValidation bind:messageId error={errorMessage} {message} {messageProps} {children} {...rest} />
43
+ {:else}
44
+ {@render children?.({ messageId, message, error })}
45
+ {/if}
@@ -0,0 +1,22 @@
1
+ import type { NeoInputValidationProps } from './neo-input-validation.model.js';
2
+ declare class __sveltets_Render<T extends HTMLElement, V extends any> {
3
+ props(): NeoInputValidationProps<T, V>;
4
+ events(): {} & {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots(): {};
8
+ bindings(): "messageId" | "visible";
9
+ exports(): {};
10
+ }
11
+ interface $$IsomorphicComponent {
12
+ new <T extends HTMLElement, V extends any>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, V>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, V>['props']>, ReturnType<__sveltets_Render<T, V>['events']>, ReturnType<__sveltets_Render<T, V>['slots']>> & {
13
+ $$bindings?: ReturnType<__sveltets_Render<T, V>['bindings']>;
14
+ } & ReturnType<__sveltets_Render<T, V>['exports']>;
15
+ <T extends HTMLElement, V extends any>(internal: unknown, props: ReturnType<__sveltets_Render<T, V>['props']> & {
16
+ $$events?: ReturnType<__sveltets_Render<T, V>['events']>;
17
+ }): ReturnType<__sveltets_Render<T, V>['exports']>;
18
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
19
+ }
20
+ declare const NeoInputValidation: $$IsomorphicComponent;
21
+ type NeoInputValidation<T extends HTMLElement, V extends any> = InstanceType<typeof NeoInputValidation<T, V>>;
22
+ export default NeoInputValidation;
@@ -0,0 +1,93 @@
1
+ <script lang="ts">
2
+ /* eslint-disable prefer-const -- necessary for binding checked */
3
+ import type { NeoLabelProps } from './neo-label.model.js';
4
+
5
+ import { toAction, toActionProps } from '../../utils/action.utils.js';
6
+
7
+ let {
8
+ // Snippets
9
+ children,
10
+ label,
11
+
12
+ // States
13
+ ref = $bindable(),
14
+ valid,
15
+ required,
16
+ disabled,
17
+
18
+ // Actions
19
+ use,
20
+
21
+ // Other props
22
+ containerTag = 'div',
23
+ containerProps,
24
+ ...rest
25
+ }: NeoLabelProps = $props();
26
+ /* eslint-enable prefer-const */
27
+
28
+ const useFn = $derived(toAction(use));
29
+ const useProps = $derived(toActionProps(use));
30
+ </script>
31
+
32
+ <svelte:element this={containerTag} class:neo-label-container={true} {...containerProps}>
33
+ <label
34
+ bind:this={ref}
35
+ class:neo-label={true}
36
+ class:neo-disabled={disabled}
37
+ class:neo-valid={valid === true}
38
+ class:neo-invalid={valid === false}
39
+ class:neo-required={required}
40
+ use:useFn={useProps}
41
+ {...rest}
42
+ >
43
+ {#if typeof label === 'string'}
44
+ {label}
45
+ {:else}
46
+ {@render label?.()}
47
+ {/if}
48
+ </label>
49
+ {@render children?.()}
50
+ </svelte:element>
51
+
52
+ <style>.neo-label-container {
53
+ display: inline-flex;
54
+ flex: 1 1 auto;
55
+ flex-direction: column;
56
+ }
57
+ .neo-label-container .neo-label {
58
+ display: inline-flex;
59
+ align-items: center;
60
+ box-sizing: border-box;
61
+ max-width: var(--neo-label-max-width);
62
+ margin: var(--neo-label-margin, var(--neo-shadow-margin, 0.625rem) var(--neo-shadow-margin, 0.625rem) 0);
63
+ padding: var(--neo-label-padding, 0 0.75rem);
64
+ overflow: hidden;
65
+ color: var(--neo-label-color, inherit);
66
+ text-wrap: stable;
67
+ text-overflow: ellipsis;
68
+ cursor: inherit;
69
+ }
70
+ .neo-label-container .neo-label.neo-required::after {
71
+ margin-left: 0.1rem;
72
+ color: var(--neo-label-required-color, var(--neo-color-error-75));
73
+ font-size: var(--neo-label-font-size, var(--neo-font-size, inherit));
74
+ content: "*";
75
+ }
76
+ .neo-label-container .neo-label.neo-invalid {
77
+ color: var(--neo-label-color-error, var(--neo-color-error));
78
+ }
79
+ .neo-label-container .neo-label.neo-valid {
80
+ color: var(--neo-label-color-success, var(--neo-color-success));
81
+ }
82
+ .neo-label-container .neo-label.neo-disabled {
83
+ color: var(--neo-label-disabled-color, var(--neo-color-disabled));
84
+ }
85
+ .neo-label-container .neo-label.neo-disabled.neo-invalid {
86
+ color: var(--neo-input-color-error-disabled, var(--neo-color-error-50));
87
+ }
88
+ .neo-label-container .neo-label.neo-disabled.neo-valid {
89
+ color: var(--neo-label-color-success-disabled, var(--neo-color-success-50));
90
+ }
91
+ .neo-label-container .neo-label.neo-disabled::after {
92
+ color: var(--neo-label-disabled-color, var(--neo-color-error-50));
93
+ }</style>
@@ -0,0 +1,19 @@
1
+ import type { NeoLabelProps } from './neo-label.model.js';
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const NeoLabel: $$__sveltets_2_IsomorphicComponent<NeoLabelProps, {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}, {}, "ref">;
18
+ type NeoLabel = InstanceType<typeof NeoLabel>;
19
+ export default NeoLabel;
@@ -1,10 +1,10 @@
1
- <script lang="ts" generics="T extends HTMLElement">
1
+ <script lang="ts" generics="T extends HTMLElement, V extends any">
2
2
  import { fade } from 'svelte/transition';
3
3
 
4
4
  import type { NeoValidationContext, NeoValidationProps } from './neo-validation.model.js';
5
5
 
6
- import { toTransition, toTransitionProps } from '../utils/action.utils.js';
7
- import { enterDefaultTransition, leaveDefaultTransition } from '../utils/transition.utils.js';
6
+ import { toTransition, toTransitionProps } from '../../utils/action.utils.js';
7
+ import { enterDefaultTransition, leaveDefaultTransition } from '../../utils/transition.utils.js';
8
8
 
9
9
  /* eslint-disable prefer-const -- necessary for binding checked */
10
10
  let {
@@ -25,12 +25,12 @@
25
25
  // Other props
26
26
  messageProps,
27
27
  messageTag = 'div',
28
- messageId = messageProps?.id ?? `neo-validation-message-${crypto.randomUUID()}`,
28
+ messageId = $bindable(messageProps?.id ?? `neo-validation-message-${crypto.randomUUID()}`),
29
29
  ...rest
30
- }: NeoValidationProps<T> = $props();
30
+ }: NeoValidationProps<T, V> = $props();
31
31
  /* eslint-enable prefer-const */
32
32
 
33
- const innerContext = $derived<NeoValidationContext<T>>({
33
+ const innerContext = $derived<NeoValidationContext<T, V>>({
34
34
  messageId,
35
35
  message,
36
36
  error,
@@ -44,7 +44,7 @@
44
44
 
45
45
  <svelte:element this={tag} class:neo-validation-group-wrapper={true} out:outFn={outProps} in:inFn={inProps} {...rest}>
46
46
  {@render children?.(innerContext)}
47
- <div class="neo-validation-message" class:rounded={context?.rounded}>
47
+ <div class="neo-validation-message">
48
48
  {#if error}
49
49
  <svelte:element
50
50
  this={messageTag}
@@ -85,7 +85,7 @@
85
85
  }
86
86
  .neo-validation-group-wrapper .neo-validation-message {
87
87
  min-height: var(--neo-line-height-sm, 1.25rem);
88
- margin: 0.25rem var(--neo-shadow-margin, 0.6rem) var(--neo-shadow-margin, 0.6rem);
88
+ margin: var(--neo-validation-margin, 0.25rem var(--neo-shadow-margin, 0.625rem) var(--neo-shadow-margin, 0.625rem));
89
89
  font-size: var(--neo-font-size-sm, 0.875rem);
90
90
  line-height: var(--neo-line-height-xs, 1rem);
91
91
  transition: color 0.3s ease, padding 0.3s ease, margin 0.3s ease;
@@ -95,12 +95,5 @@
95
95
  }
96
96
  .neo-validation-group-wrapper .neo-validation-message .neo-validation-error,
97
97
  .neo-validation-group-wrapper .neo-validation-message .neo-validation-description {
98
- padding: 0 0.75rem;
99
- }
100
- .neo-validation-group-wrapper .neo-validation-message.rounded {
101
- margin: 0.25rem var(--neo-shadow-margin-lg, 1.125rem) var(--neo-shadow-margin-lg, 1.125rem);
102
- }
103
- .neo-validation-group-wrapper .neo-validation-message.rounded .neo-validation-error,
104
- .neo-validation-group-wrapper .neo-validation-message.rounded .neo-validation-description {
105
- padding: 0 1rem;
98
+ padding: var(--neo-validation-padding, 0 0.75rem);
106
99
  }</style>
@@ -0,0 +1,22 @@
1
+ import type { NeoValidationProps } from './neo-validation.model.js';
2
+ declare class __sveltets_Render<T extends HTMLElement, V extends any> {
3
+ props(): NeoValidationProps<T, V>;
4
+ events(): {} & {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots(): {};
8
+ bindings(): "messageId";
9
+ exports(): {};
10
+ }
11
+ interface $$IsomorphicComponent {
12
+ new <T extends HTMLElement, V extends any>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, V>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, V>['props']>, ReturnType<__sveltets_Render<T, V>['events']>, ReturnType<__sveltets_Render<T, V>['slots']>> & {
13
+ $$bindings?: ReturnType<__sveltets_Render<T, V>['bindings']>;
14
+ } & ReturnType<__sveltets_Render<T, V>['exports']>;
15
+ <T extends HTMLElement, V extends any>(internal: unknown, props: ReturnType<__sveltets_Render<T, V>['props']> & {
16
+ $$events?: ReturnType<__sveltets_Render<T, V>['events']>;
17
+ }): ReturnType<__sveltets_Render<T, V>['exports']>;
18
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
19
+ }
20
+ declare const NeoValidation: $$IsomorphicComponent;
21
+ type NeoValidation<T extends HTMLElement, V extends any> = InstanceType<typeof NeoValidation<T, V>>;
22
+ export default NeoValidation;
@@ -0,0 +1,32 @@
1
+ import type { HTMLButtonAttributes } from 'svelte/elements';
2
+ import type { HTMLNeoBaseElement, HTMLRefProps } from '../../utils/html-element.utils.js';
3
+ export type NeoAffixProps = {
4
+ /**
5
+ * Display loading indicator
6
+ */
7
+ loading?: boolean;
8
+ /**
9
+ * Display a close button if not loading
10
+ */
11
+ close?: boolean;
12
+ /**
13
+ * Display validation state if not loading or closable
14
+ */
15
+ valid?: boolean;
16
+ /**
17
+ * Display a skeleton state
18
+ */
19
+ skeleton?: boolean;
20
+ /**
21
+ * Display a disabled state
22
+ */
23
+ disabled?: boolean;
24
+ /**
25
+ * The size of the inner svg
26
+ */
27
+ size?: string;
28
+ /**
29
+ * Props for the close button
30
+ */
31
+ closeProps?: HTMLButtonAttributes;
32
+ } & HTMLNeoBaseElement<HTMLSpanElement> & HTMLRefProps<HTMLSpanElement>;
@@ -0,0 +1,20 @@
1
+ import type { NeoValidationFieldContext, NeoValidationProps, NeoValidationValue } from './neo-validation.model.js';
2
+ export type NeoInputValidationProps<T extends HTMLElement = HTMLElement, V extends NeoValidationValue = NeoValidationValue, C extends NeoValidationFieldContext<T, V> = NeoValidationFieldContext<T, V>> = NeoValidationProps<T, V, C> & {
3
+ /**
4
+ * `true` if the input passes validation.
5
+ */
6
+ valid?: boolean;
7
+ /**
8
+ * `true` if the any message is displayed
9
+ */
10
+ visible?: boolean;
11
+ /**
12
+ * `true` to display the validation message.
13
+ */
14
+ validation?: boolean;
15
+ /**
16
+ * Optional validation message.
17
+ * Note: This will be overridden by the error message if it is set.
18
+ */
19
+ validationMessage?: string;
20
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,29 +1,16 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLInputAttributes, HTMLTextareaAttributes } from 'svelte/elements';
3
- import type { HTMLActionProps } from '../utils/action.utils.js';
4
- import type { HTMLNeoBaseElement, HTMLRefProps } from '../utils/html-element.utils.js';
5
- import type { ShadowElevation } from '../utils/shadow.utils.js';
6
- export type NeoInputState = {
7
- /**
8
- * `true` if the input has been focused.
9
- */
10
- touched?: boolean;
11
- /**
12
- * `true` if the input content has been modified and defers from the initial state.
13
- * If `dirtyOnChange` is `true`, the input will always be considered dirty once it has been modified.
14
- *
15
- * @see dirtyOnChange
16
- */
17
- dirty?: boolean;
18
- /**
19
- * `true` if the input passes validation.
20
- */
21
- valid?: boolean;
22
- /**
23
- * The input/textarea value.
24
- */
25
- value?: string;
3
+ import type { NeoLabelProps } from './neo-label.model.js';
4
+ import type { NeoValidationFieldContext, NeoValidationState } from './neo-validation.model.js';
5
+ import type { HTMLTransitionProps, HTMLUseProps } from '../../utils/action.utils.js';
6
+ import type { HTMLNeoBaseElement, HTMLRefProps, SvelteEvent } from '../../utils/html-element.utils.js';
7
+ import type { ShadowElevation } from '../../utils/shadow.utils.js';
8
+ export type NeoInputValue<T extends HTMLInputElement | HTMLTextAreaElement> = T extends HTMLTextAreaElement ? HTMLTextareaAttributes['value'] : HTMLInputAttributes['value'] | HTMLInputAttributes['checked'] | HTMLInputAttributes['bind:files'];
9
+ type NeoInputHTMLAttributes<T extends HTMLInputElement | HTMLTextAreaElement> = T extends HTMLTextAreaElement ? HTMLTextareaAttributes : HTMLInputAttributes & {
10
+ files?: HTMLInputAttributes['bind:files'];
11
+ group?: HTMLInputAttributes['bind:group'];
26
12
  };
13
+ export type NeoInputState<T extends HTMLInputElement | HTMLTextAreaElement> = NeoValidationState<NeoInputValue<T>>;
27
14
  export type NeoInputStyles = {
28
15
  /**
29
16
  * Input elevation.
@@ -35,6 +22,10 @@ export type NeoInputStyles = {
35
22
  * @default 0
36
23
  */
37
24
  hover?: number;
25
+ /**
26
+ * If true, negative elevation (< 0) will be displayed as pressed instead of inset.
27
+ */
28
+ pressed?: boolean;
38
29
  /**
39
30
  * By default, inputs with no elevation will display a border.
40
31
  * If this is `true`, the input will never display a border.
@@ -66,21 +57,38 @@ export type NeoInputStyles = {
66
57
  */
67
58
  readonly?: boolean;
68
59
  };
69
- export type NeoInputMethods = {
60
+ export type NeoInputMethods<T extends HTMLInputElement | HTMLTextAreaElement> = {
70
61
  /**
71
62
  * Change the input state. If no value is provided, the state attributes will be unchanged.
72
63
  * @param state
73
64
  */
74
- mark: (state: NeoInputState) => unknown;
65
+ mark: (state: NeoInputState<T>) => unknown;
75
66
  /**
76
67
  * Clear the input. If a state is provided, the input state will be updated accordingly.
77
68
  * If a partial state is provided, the input state will be reinitialized and the provided state will be merged.
69
+ *
70
+ * Note: Clearing the input will trigger `onclear` and `oninput` events, but not `onchange`.
78
71
  * @param state
72
+ * @param event
73
+ */
74
+ clear: (state?: NeoInputState<T>, event?: InputEvent | SvelteEvent<InputEvent>) => Promise<unknown>;
75
+ /**
76
+ * Change the input value.
77
+ * @param value
78
+ * @param event
79
+ */
80
+ change: (value: NeoInputValue<T>, event?: InputEvent | SvelteEvent<InputEvent>) => NeoInputState<T>;
81
+ /**
82
+ * Check the input validity.
83
+ * @param update whether to check the input dirty and/or valid state.
79
84
  */
80
- clear: (state?: NeoInputState) => unknown;
85
+ validate: (update?: {
86
+ dirty?: boolean;
87
+ valid?: boolean;
88
+ }) => NeoInputState<T>;
81
89
  };
82
90
  export type NeoInputElevation = ShadowElevation;
83
- export type NeoInputContext<T extends HTMLElement = HTMLElement> = HTMLRefProps<T> & NeoInputState & NeoInputStyles & NeoInputMethods;
91
+ export type NeoInputContext<T extends HTMLInputElement | HTMLTextAreaElement> = NeoValidationFieldContext<T, NeoInputValue<T>> & Partial<NeoInputStyles & NeoInputMethods<T>>;
84
92
  export declare const NeoInputLabelPosition: {
85
93
  readonly Inside: "inside";
86
94
  readonly Top: "top";
@@ -88,41 +96,104 @@ export declare const NeoInputLabelPosition: {
88
96
  readonly Right: "right";
89
97
  };
90
98
  export type NeoInputLabelPositions = (typeof NeoInputLabelPosition)[keyof typeof NeoInputLabelPosition];
91
- export type NeoCommonInputProps<T extends HTMLElement> = {
99
+ export type NeoBaseInputProps<T extends HTMLInputElement | HTMLTextAreaElement = NeoInputHTMLElement> = {
92
100
  /**
93
- * A snippet or a string to display as the input label.
101
+ * If `true`, the input will have no left padding/border radius.
94
102
  */
95
- label?: Snippet<[NeoInputContext<T>]> | string;
103
+ after?: boolean;
96
104
  /**
97
- * A snippet or a string to display as the input info message.
105
+ * If `true`, the input will have no right padding/border radius.
98
106
  */
99
- message?: Snippet<[NeoInputContext<T>]> | string;
107
+ before?: boolean;
100
108
  /**
101
- * A snippet or a string to display as the input error message.
109
+ * If the input is currently focused.
102
110
  */
103
- error?: Snippet<[NeoInputContext<T>]> | string;
111
+ focused?: boolean;
104
112
  /**
105
- * A snippet to display as the input suffix.
113
+ * If false, and a default value is provided, the input will be set to the default value when cleared.
114
+ *
115
+ * Note: This does not apply to checkboxes, radios, and file inputs.
116
+ *
117
+ * @default true
118
+ */
119
+ nullable?: boolean;
120
+ /**
121
+ * Fall back value when the input value is cleared.
122
+ */
123
+ defaultValue?: HTMLInputAttributes['value'];
124
+ /**
125
+ * Fall back checked state when the input value is cleared.
106
126
  */
107
- suffix?: Snippet<[NeoInputContext<T>]>;
127
+ defaultChecked?: HTMLInputAttributes['checked'];
108
128
  /**
109
129
  * If `true`, the input dirty state will update on input events.
110
130
  * If `false`, the input dirty state will only update on change events.
111
131
  * @default false
112
132
  */
113
133
  dirtyOnInput?: boolean;
134
+ /**
135
+ * If `true`, the input dirty state will update on blur events.
136
+ * @default false
137
+ */
138
+ dirtyOnBlur?: boolean;
114
139
  /**
115
140
  * If `true`, the input will check for validity on input events.
116
141
  * If `false`, the input will only check for validity on change events.
117
142
  * @default false
118
143
  */
119
144
  validateOnInput?: boolean;
145
+ /**
146
+ * If `true`, the input will check for validity on blur events.
147
+ * @default false
148
+ */
149
+ validateOnBlur?: boolean;
150
+ /**
151
+ * Reflect the input validation message.
152
+ */
153
+ validationMessage?: T['validationMessage'];
154
+ /**
155
+ * Callback when the input state is manually changed.
156
+ * @param state
157
+ */
158
+ onmark?: (state: NeoInputState<T>) => unknown;
159
+ /**
160
+ * Callback when the input is cleared.
161
+ * @param state
162
+ * @param event
163
+ */
164
+ onclear?: (state: NeoInputState<T>, event?: InputEvent) => unknown;
165
+ } & HTMLUseProps & HTMLRefProps<T> & NeoInputState<T> & NeoInputHTMLAttributes<T>;
166
+ export type NeoInputGroupProps<T extends HTMLInputElement | HTMLTextAreaElement> = {
167
+ /**
168
+ * A snippet or a string to display as the input label.
169
+ */
170
+ label?: Snippet<[NeoInputContext<T>]> | string;
171
+ /**
172
+ * A snippet or a string to display as the input info message.
173
+ */
174
+ message?: Snippet<[NeoInputContext<T>]> | string;
175
+ /**
176
+ * A snippet or a string to display as the input error message.
177
+ */
178
+ error?: Snippet<[NeoInputContext<T>]> | string;
179
+ /**
180
+ * A snippet to display as the input suffix.
181
+ */
182
+ after?: Snippet<[NeoInputContext<T>]>;
183
+ /**
184
+ * Element(s) to render inside the input-group (after the input).
185
+ */
186
+ children?: Snippet<[NeoInputContext<T>]>;
120
187
  /**
121
188
  * Display a loading spinner inside the input.
122
189
  * If defined, some space will be reserved for the spinner.
123
190
  * Set to `undefined` when not loading to regain the space.
124
191
  */
125
192
  loading?: boolean;
193
+ /**
194
+ * If the input is currently hovered.
195
+ */
196
+ hovered?: boolean;
126
197
  /**
127
198
  * Display a clear button to reset the input value.
128
199
  * If used in combination with `loading`, the clear button will be hidden while loading.
@@ -147,16 +218,6 @@ export type NeoCommonInputProps<T extends HTMLElement> = {
147
218
  * @default 'inside'
148
219
  */
149
220
  position?: NeoInputLabelPositions;
150
- /**
151
- * Callback when the input state is manually changed.
152
- * @param state
153
- */
154
- onmark?: (state: NeoInputState) => unknown;
155
- /**
156
- * Callback when the input is cleared.
157
- * @param state
158
- */
159
- onclear?: (state: NeoInputState) => unknown;
160
221
  /**
161
222
  * The HTML tag to use for the wrapper component (when message or error are shown).
162
223
  */
@@ -182,35 +243,46 @@ export type NeoCommonInputProps<T extends HTMLElement> = {
182
243
  * The props to pass to the message and error components.
183
244
  */
184
245
  messageProps?: HTMLNeoBaseElement;
185
- suffixTag?: keyof HTMLElementTagNameMap;
246
+ afterTag?: keyof HTMLElementTagNameMap;
186
247
  /**
187
248
  * The props to pass to the suffix.
188
249
  */
189
- suffixProps?: HTMLNeoBaseElement;
250
+ afterProps?: HTMLNeoBaseElement;
251
+ /**
252
+ * The ref to bind to the suffix.
253
+ */
254
+ afterRef?: HTMLElement;
190
255
  /**
191
256
  * The props to pass to the label.
192
257
  */
193
- labelProps?: HTMLNeoBaseElement<HTMLLabelElement>;
258
+ labelProps?: NeoLabelProps;
194
259
  /**
195
260
  * The ref to bind to the label.
196
261
  */
197
262
  labelRef?: HTMLLabelElement;
198
- } & HTMLRefProps<T> & NeoInputState & NeoInputStyles & HTMLActionProps;
199
- export type NeoInputProps<T extends HTMLInputElement = HTMLInputElement> = {
263
+ } & Omit<NeoBaseInputProps<T>, 'after' | 'before'> & NeoInputStyles & HTMLTransitionProps;
264
+ export type NeoInputProps<T extends HTMLInputElement = NeoInputHTMLElement> = {
200
265
  /**
201
266
  * A snippet to display as the input prefix.
202
267
  */
203
- prefix?: Snippet<[NeoInputContext<T>]>;
268
+ before?: Snippet<[NeoInputContext<T>]>;
204
269
  /**
205
270
  * The HTML tag to use for the prefix.
206
271
  * @default div
207
272
  */
208
- prefixTag?: keyof HTMLElementTagNameMap;
273
+ beforeTag?: keyof HTMLElementTagNameMap;
209
274
  /**
210
275
  * The props to pass to the prefix.
211
276
  */
212
- prefixProps?: HTMLNeoBaseElement;
213
- } & NeoCommonInputProps<T> & HTMLInputAttributes;
277
+ beforeProps?: HTMLNeoBaseElement;
278
+ /**
279
+ * The ref to bind to the prefix.
280
+ */
281
+ beforeRef?: HTMLElement;
282
+ } & NeoInputGroupProps<T> & HTMLInputAttributes & {
283
+ files?: HTMLInputAttributes['bind:files'];
284
+ group?: HTMLInputAttributes['bind:group'];
285
+ };
214
286
  export type NeoTextAreaResize = {
215
287
  /**
216
288
  * The minimum number of rows the textarea can have.
@@ -222,7 +294,11 @@ export type NeoTextAreaResize = {
222
294
  */
223
295
  max?: number;
224
296
  };
225
- export type NeoTextareaProps<T extends HTMLTextAreaElement = HTMLTextAreaElement> = {
297
+ export type NeoTextareaProps<T extends HTMLTextAreaElement = NeoTextareaHTMLElement> = {
298
+ /**
299
+ * Fall back value when the textarea value is cleared.
300
+ */
301
+ defaultValue: HTMLTextareaAttributes['value'];
226
302
  /**
227
303
  * Automatically increments/decrements the textarea rows to fit the content.
228
304
  *
@@ -232,4 +308,7 @@ export type NeoTextareaProps<T extends HTMLTextAreaElement = HTMLTextAreaElement
232
308
  * @default true
233
309
  */
234
310
  autoResize?: boolean | NeoTextAreaResize;
235
- } & NeoCommonInputProps<T> & HTMLTextareaAttributes;
311
+ } & NeoInputGroupProps<T> & HTMLTextareaAttributes;
312
+ export type NeoInputHTMLElement<T extends HTMLInputElement = HTMLInputElement> = T & Partial<NeoInputMethods<T>>;
313
+ export type NeoTextareaHTMLElement<T extends HTMLTextAreaElement = HTMLTextAreaElement> = T & Partial<NeoInputMethods<T>>;
314
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLLabelAttributes } from 'svelte/elements';
3
+ import type { HTMLUseProps } from '../../utils/action.utils.js';
4
+ import type { HTMLNeoBaseElement, HTMLRefProps } from '../../utils/html-element.utils.js';
5
+ export type NeoLabelProps = {
6
+ /**
7
+ * The element(s) to wrap with the label.
8
+ */
9
+ children?: Snippet;
10
+ /**
11
+ * A snippet or a string to display as the label.
12
+ */
13
+ label?: Snippet | string;
14
+ /**
15
+ * If `true` or `false`, the label will be displayed as valid or invalid.
16
+ * If any other value (undefined, null, etc.), the label will be displayed as normal.
17
+ */
18
+ valid?: boolean;
19
+ /**
20
+ * If `true`, the label will be displayed a required asterisk.
21
+ */
22
+ required?: boolean | null;
23
+ /**
24
+ * If `true`, the label will be displayed as disabled.
25
+ */
26
+ disabled?: boolean | null;
27
+ /**
28
+ * The HTML tag to use for the container.
29
+ * @default div
30
+ */
31
+ containerTag?: keyof HTMLElementTagNameMap;
32
+ /**
33
+ * The props to pass to the label container.
34
+ */
35
+ containerProps?: HTMLNeoBaseElement;
36
+ } & HTMLRefProps<HTMLLabelElement> & HTMLLabelAttributes & HTMLUseProps;
@@ -0,0 +1 @@
1
+ export {};