@dvcol/neo-svelte 0.1.2 → 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 (152) hide show
  1. package/CHANGELOG.md +83 -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 +176 -73
  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 +335 -301
  72. package/dist/inputs/NeoTextarea.svelte.d.ts +5 -2
  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} +148 -68
  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 +10 -10
  122. package/dist/providers/neo-theme-provider-context.svelte.js +16 -15
  123. package/dist/providers/neo-theme-provider.model.d.ts +6 -6
  124. package/dist/providers/neo-theme-provider.model.js +17 -12
  125. package/dist/providers/neo-theme-selector.model.d.ts +2 -2
  126. package/dist/skeletons/NeoSkeletonMedia.svelte +4 -4
  127. package/dist/skeletons/NeoSkeletonText.svelte +12 -12
  128. package/dist/styles/common/colors.scss +85 -97
  129. package/dist/styles/common/filters.scss +17 -0
  130. package/dist/styles/common/shadows.scss +531 -293
  131. package/dist/styles/common/spacing.scss +7 -3
  132. package/dist/styles/common/typography.scss +1 -1
  133. package/dist/styles/common/utils.scss +1 -1
  134. package/dist/styles/common/z-index.scss +1 -1
  135. package/dist/styles/mixin.scss +80 -27
  136. package/dist/styles/reset.scss +8 -1
  137. package/dist/styles/theme.scss +39 -16
  138. package/dist/utils/html-element.utils.d.ts +3 -0
  139. package/dist/utils/regex.utils.d.ts +3 -0
  140. package/dist/utils/regex.utils.js +3 -0
  141. package/dist/utils/shadow.utils.d.ts +30 -3
  142. package/dist/utils/shadow.utils.js +41 -14
  143. package/dist/utils/transition.utils.d.ts +4 -0
  144. package/dist/utils/transition.utils.js +10 -1
  145. package/dist/utils/utils.svelte.d.ts +6 -0
  146. package/dist/utils/utils.svelte.js +13 -0
  147. package/package.json +13 -12
  148. package/dist/inputs/NeoInput.svelte +0 -750
  149. package/dist/inputs/NeoValidation.svelte.d.ts +0 -22
  150. package/dist/inputs/neo-validation.model.d.ts +0 -40
  151. /package/dist/inputs/{neo-validation.model.js → common/neo-affix.model.js} +0 -0
  152. /package/dist/inputs/{neo-input.model.js → common/neo-input.model.js} +0 -0
@@ -1,13 +1,17 @@
1
- [neo-theme-root] {
1
+ @mixin spacing() {
2
2
  /* Borders */
3
3
  --neo-border-width: 1px;
4
+ --neo-border-width-md: 2px;
5
+ --neo-border-width-lg: 4px;
6
+ --neo-border-radius-xs: 0.25rem;
7
+ --neo-border-radius-sm: 0.375rem;
4
8
  --neo-border-radius: 0.5rem;
5
9
  --neo-border-radius-md: 1rem;
6
10
  --neo-border-radius-lg: 2rem;
7
11
 
8
12
  /* Gap */
9
13
  --neo-gap-xxs: 0.5rem;
10
- --neo-gap-xs: 0.615rem;
14
+ --neo-gap-xs: 0.625rem;
11
15
  --neo-gap-sm: 0.75rem;
12
16
  --neo-gap: 1rem;
13
17
  --neo-gap-md: 1.25rem;
@@ -22,6 +26,6 @@
22
26
  --neo-line-height: 1.5rem;
23
27
 
24
28
  /* Margin */
25
- --neo-shadow-margin: 0.6rem;
29
+ --neo-shadow-margin: 0.625rem;
26
30
  --neo-shadow-margin-lg: 1.125rem;
27
31
  }
@@ -1,4 +1,4 @@
1
- [neo-theme-root] {
1
+ @mixin typography {
2
2
  /* Default font stack */
3
3
  --neo-font-family: 'Nunito Sans', ui-rounded, sans-serif;
4
4
 
@@ -1,4 +1,4 @@
1
- [neo-theme-root] {
1
+ @mixin utils() {
2
2
  /* Transforms */
3
3
  --neo-transition-bezier: cubic-bezier(0.4, 0, 0.2, 1);
4
4
  --neo-transition-skeleton: cubic-bezier(0.4, 0, 0.6, 1);
@@ -1,4 +1,4 @@
1
- [neo-theme-root] {
1
+ @mixin z-index() {
2
2
  --neo-z-index-behind: -1;
3
3
  --neo-z-index-default: 0;
4
4
  --neo-z-index-in-front: 1;
@@ -106,25 +106,29 @@
106
106
  }
107
107
 
108
108
  @mixin border-rotate(
109
- $background-color: var(--neo-background-color),
110
- $border-color: var(--neo-border-color-primary),
111
- $border-width: 1px,
112
- $speed: 3s,
113
- $easing: linear,
114
- $transition: (
115
- 1s --neo-source-color,
116
- 1s --neo-target-color,
117
- )
109
+ $source-color: var(--neo-rotate-source-color, transparent),
110
+ $target-color: var(--neo-rotate-target-color, var(--neo-color-primary-50)),
111
+ $border-width: var(--neo-border-width, 1px),
112
+ $speed: var(--neo-rotate-speed, 4s),
113
+ $easing: var(--neo-rotate-easing, linear)
118
114
  ) {
119
- --neo-source-color: #{$background-color};
120
- --neo-target-color: #{$border-color};
121
-
122
- background:
123
- linear-gradient($background-color, $background-color) padding-box,
124
- conic-gradient(from var(--neo-angle), var(--neo-source-color), var(--neo-target-color)) border-box;
115
+ position: relative;
125
116
  border: $border-width solid transparent;
126
- transition: $transition;
127
- animation: $speed rotate $easing infinite;
117
+ border-radius: 2rem;
118
+
119
+ &::before {
120
+ position: absolute;
121
+ inset: 0;
122
+ padding: $border-width;
123
+ background: conic-gradient(from var(--neo-angle), #{$source-color} 20%, #{$target-color} 80%);
124
+ border-radius: inherit;
125
+ animation: $speed rotate $easing infinite;
126
+ content: '';
127
+ mask:
128
+ conic-gradient(black 0 0) content-box exclude,
129
+ conic-gradient(black 0 0);
130
+ pointer-events: none;
131
+ }
128
132
 
129
133
  &.filled {
130
134
  --neo-source-color: var(--neo-target-color);
@@ -138,18 +142,29 @@
138
142
  }
139
143
 
140
144
  @mixin border-progress(
141
- $background-color: var(--neo-background-color),
142
- $border-color: var(--neo-border-color-primary),
145
+ $border-color: var(--neo-progress-border-color, var(--neo-color-primary-50)),
143
146
  $border-width: 1px,
144
147
  $transition: --neo-progress,
145
- $speed: 2s,
146
- $easing: var(--neo-transition-bezier)
148
+ $speed: var(--neo-rotate-speed, 4s),
149
+ $easing: var(--neo-rotate-easing, linear)
147
150
  ) {
148
- background:
149
- linear-gradient($background-color, $background-color) padding-box,
150
- conic-gradient($border-color, $border-color var(--neo-progress), transparent var(--neo-progress)) border-box;
151
+ position: relative;
151
152
  border: $border-width solid transparent;
152
- transition: $transition $speed $easing;
153
+ border-radius: 2rem;
154
+
155
+ &::before {
156
+ position: absolute;
157
+ inset: 0;
158
+ padding: $border-width;
159
+ background: conic-gradient($border-color, $border-color var(--neo-progress), transparent var(--neo-progress));
160
+ border-radius: inherit;
161
+ transition: $transition $speed $easing;
162
+ content: '';
163
+ mask:
164
+ conic-gradient(black 0 0) content-box exclude,
165
+ conic-gradient(black 0 0);
166
+ pointer-events: none;
167
+ }
153
168
  }
154
169
 
155
170
  @mixin skeleton(
@@ -186,7 +201,7 @@
186
201
 
187
202
  @mixin scrollbar(
188
203
  $gutter: stable,
189
- $width: var(--neo-scrollbar-width, 0.45rem),
204
+ $width: var(--neo-scrollbar-width, 0.375rem),
190
205
  $thumb-color: var(--neo-scrollbar-color),
191
206
  $thumb-border-radius: var(--neo-border-radius),
192
207
  $button-height: var(--neo-scrollbar-button-height, 2px)
@@ -219,7 +234,45 @@
219
234
  }
220
235
 
221
236
  &::-webkit-resizer {
222
- background: url('~/assets/neo-icon-resizer-bottom-right.svg') no-repeat bottom;
237
+ background: url('../assets/neo-icon-resizer-bottom-right.svg') no-repeat bottom;
223
238
  background-clip: border-box;
224
239
  }
225
240
  }
241
+
242
+ @mixin fade-scroll($fade-height: 1rem) {
243
+ mask-image: linear-gradient(to top, transparent, transparent $fade-height, black $fade-height, black calc(100% - #{$fade-height}), transparent),
244
+ linear-gradient(to bottom, transparent, transparent $fade-height, black $fade-height, black calc(100% - #{$fade-height}), transparent);
245
+ }
246
+
247
+ @mixin glass() {
248
+ /** Box Shadows raised */
249
+ --neo-box-shadow-raised-5: var(--neo-glass-box-shadow-raised-5);
250
+ --neo-box-shadow-raised-4: var(--neo-glass-box-shadow-raised-4);
251
+ --neo-box-shadow-raised-3: var(--neo-glass-box-shadow-raised-3);
252
+ --neo-box-shadow-raised-2: var(--neo-glass-box-shadow-raised-2);
253
+ --neo-box-shadow-raised-1: var(--neo-glass-box-shadow-raised-1);
254
+
255
+ /** Box Shadows inset */
256
+ --neo-box-shadow-inset-1: var(--neo-glass-box-shadow-inset-1);
257
+ --neo-box-shadow-inset-2: var(--neo-glass-box-shadow-inset-2);
258
+ --neo-box-shadow-inset-3: var(--neo-glass-box-shadow-inset-3);
259
+ --neo-box-shadow-inset-4: var(--neo-glass-box-shadow-inset-4);
260
+ --neo-box-shadow-inset-5: var(--neo-glass-box-shadow-inset-5);
261
+
262
+ /** Box Shadows pressed */
263
+ --neo-box-shadow-pressed-1: var(--neo-glass-box-shadow-pressed-1);
264
+ --neo-box-shadow-pressed-2: var(--neo-glass-box-shadow-pressed-2);
265
+ --neo-box-shadow-pressed-3: var(--neo-glass-box-shadow-pressed-3);
266
+ --neo-box-shadow-pressed-4: var(--neo-glass-box-shadow-pressed-4);
267
+ --neo-box-shadow-pressed-5: var(--neo-glass-box-shadow-pressed-5);
268
+
269
+ /** Box Shadows convex */
270
+ --neo-box-shadow-convex-1: var(--neo-glass-box-shadow-convex-1);
271
+ --neo-box-shadow-convex-2: var(--neo-glass-box-shadow-convex-2);
272
+ --neo-box-shadow-convex-3: var(--neo-glass-box-shadow-convex-3);
273
+ --neo-box-shadow-convex-4: var(--neo-glass-box-shadow-convex-4);
274
+ --neo-box-shadow-convex-5: var(--neo-glass-box-shadow-convex-5);
275
+
276
+ /** Skeleton color */
277
+ --neo-skeleton-color: var(--neo-glass-skeleton-color);
278
+ }
@@ -1,4 +1,4 @@
1
- [neo-reset] {
1
+ @mixin reset() {
2
2
  /*
3
3
  Use a more-intuitive box-sizing model.
4
4
  */
@@ -17,6 +17,7 @@
17
17
 
18
18
  /* Global defaults */
19
19
  :host,
20
+ &:root,
20
21
  html {
21
22
  /* Default to dark mode */
22
23
  color-scheme: dark light;
@@ -81,3 +82,9 @@
81
82
  }
82
83
  }
83
84
  }
85
+
86
+ @mixin nested($root: neo-reset) {
87
+ [#{$root}] {
88
+ @include reset;
89
+ }
90
+ }
@@ -1,22 +1,45 @@
1
- @use 'src/lib/styles/common/z-index';
2
- @use 'src/lib/styles/common/colors';
3
- @use 'src/lib/styles/common/typography';
4
- @use 'src/lib/styles/common/shadows';
5
- @use 'src/lib/styles/common/spacing';
6
- @use 'src/lib/styles/common/utils';
1
+ @use 'src/lib/styles/common/z-index' as z-index;
2
+ @use 'src/lib/styles/common/colors' as colors;
3
+ @use 'src/lib/styles/common/typography' as typography;
4
+ @use 'src/lib/styles/common/shadows' as shadows;
5
+ @use 'src/lib/styles/common/filters' as filters;
6
+ @use 'src/lib/styles/common/spacing' as spacing;
7
+ @use 'src/lib/styles/common/utils' as utils;
7
8
  @use 'src/lib/styles/common/properties';
8
9
 
9
- [neo-theme-root] {
10
- color: var(--neo-text-color);
11
- font-family: var(--neo-font-family), sans-serif;
12
- line-height: var(--neo-line-height);
13
- background-color: var(--neo-background-color);
10
+ @mixin theme($root: neo-theme-root) {
11
+ [#{$root}] {
12
+ color: var(--neo-text-color);
13
+ font-family: var(--neo-font-family), sans-serif;
14
+ line-height: var(--neo-line-height);
15
+ background-color: var(--neo-background-color);
14
16
 
15
- /* touch highlight */
16
- -webkit-tap-highlight-color: transparent;
17
+ /* touch highlight */
18
+ -webkit-tap-highlight-color: transparent;
17
19
 
18
- /* cursor highlight */
19
- *::selection {
20
- background-color: var(--neo-text-highlight-color);
20
+ @include utils.utils;
21
+ @include z-index.z-index;
22
+ @include typography.typography;
23
+ @include spacing.spacing;
24
+ @include filters.filters;
25
+ @include colors.colors;
26
+ @include shadows.shadows;
27
+
28
+ /* cursor highlight */
29
+ *::selection {
30
+ background-color: var(--neo-text-highlight-color);
31
+ }
32
+
33
+ /* override semantic color if dark mode is enabled */
34
+ &[neo-theme='dark'] {
35
+ @include colors.dark-theme;
36
+ }
37
+
38
+ /* apply dark mode if not overridden */
39
+ @media (prefers-color-scheme: dark) {
40
+ &:not([neo-theme='light']) {
41
+ @include colors.dark-theme;
42
+ }
43
+ }
21
44
  }
22
45
  }
@@ -20,3 +20,6 @@ export type HTMLFlexProps = {
20
20
  */
21
21
  justify?: 'center' | 'start' | 'end' | 'between' | 'around' | 'evenly' | CSSStyleDeclaration['justifyContent'];
22
22
  };
23
+ export type SvelteEvent<E extends Event = Event, T extends EventTarget = any> = E & {
24
+ currentTarget?: EventTarget & T;
25
+ };
@@ -0,0 +1,3 @@
1
+ export declare const HexColorRegexString = "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$";
2
+ export declare const HexColorRegex: RegExp;
3
+ export declare const ArrowPrefix: RegExp;
@@ -0,0 +1,3 @@
1
+ export const HexColorRegexString = '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$';
2
+ export const HexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
3
+ export const ArrowPrefix = /^Arrow/;
@@ -1,8 +1,35 @@
1
1
  export declare const MaxShadowElevation = 5;
2
2
  export declare const MinShadowElevation = -5;
3
3
  export declare const DefaultShadowElevation = 3;
4
+ export declare const DefaultShadowPressedElevation = -2;
5
+ export declare const DefaultShadowHoverElevation = -1;
6
+ export declare const DefaultShadowHoverPressedElevation = 0;
7
+ export declare const DefaultSaturation = 3;
4
8
  export declare const ShadowElevations: readonly [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5];
5
9
  export type ShadowElevation = (typeof ShadowElevations)[number];
6
- export declare const computeShadowElevation: (elevation: number | ShadowElevation, glass?: boolean) => string;
7
- export declare const computeHoverShadowElevation: (elevation: number | ShadowElevation, hover?: number | ShadowElevation, glass?: boolean) => string | undefined;
8
- export declare const computeGlassFilter: (elevation: number | ShadowElevation, glass?: boolean) => string | undefined;
10
+ export type ShadowModifier = {
11
+ glass?: boolean;
12
+ convex?: boolean;
13
+ pressed?: boolean;
14
+ };
15
+ export declare const ShadowFlatRegex: RegExp;
16
+ export declare const getDefaultElevation: (pressed?: boolean) => 3 | -2;
17
+ export declare const getDefaultHoverElevation: (pressed?: boolean) => 0 | -1;
18
+ export declare const isShadowFlat: (shadow: string) => boolean;
19
+ export declare const computeElevation: (elevation: number | ShadowElevation, { min, max }?: {
20
+ min?: ShadowElevation;
21
+ max?: ShadowElevation;
22
+ }) => number;
23
+ export declare const computeShadowElevation: (elevation: number | ShadowElevation, { glass, convex, pressed }?: ShadowModifier, minMax?: {
24
+ min?: ShadowElevation;
25
+ max?: ShadowElevation;
26
+ }) => string;
27
+ export declare const computeHoverShadowElevation: (elevation: number | ShadowElevation, hover?: number | ShadowElevation, options?: ShadowModifier, minMax?: {
28
+ min?: ShadowElevation;
29
+ max?: ShadowElevation;
30
+ }) => string | undefined;
31
+ export declare const computeGlassFilter: (elevation: number | ShadowElevation, glass?: boolean, { max, saturation }?: {
32
+ max?: ShadowElevation;
33
+ saturation?: number;
34
+ }) => string | undefined;
35
+ export declare const computeButtonShadows: (elevation: number | ShadowElevation, text?: boolean) => string | undefined;
@@ -1,26 +1,53 @@
1
1
  export const MaxShadowElevation = 5;
2
2
  export const MinShadowElevation = -5;
3
3
  export const DefaultShadowElevation = 3;
4
+ export const DefaultShadowPressedElevation = -2;
5
+ export const DefaultShadowHoverElevation = -1;
6
+ export const DefaultShadowHoverPressedElevation = 0;
7
+ export const DefaultSaturation = 3;
4
8
  export const ShadowElevations = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5];
5
- export const computeShadowElevation = (elevation, glass) => {
9
+ export const ShadowFlatRegex = /^.*flat\)?;?$/;
10
+ export const getDefaultElevation = (pressed) => (pressed ? DefaultShadowPressedElevation : DefaultShadowElevation);
11
+ export const getDefaultHoverElevation = (pressed) => (pressed ? DefaultShadowHoverPressedElevation : DefaultShadowHoverElevation);
12
+ export const isShadowFlat = (shadow) => ShadowFlatRegex.test(shadow);
13
+ export const computeElevation = (elevation, { min = MinShadowElevation, max = MaxShadowElevation } = {}) => {
14
+ if (elevation < min)
15
+ return min;
16
+ if (elevation > max)
17
+ return max;
18
+ return elevation;
19
+ };
20
+ export const computeShadowElevation = (elevation, { glass, convex, pressed } = {}, minMax = {}) => {
21
+ const raided = convex ? 'convex' : 'raised';
22
+ const inset = pressed ? 'pressed' : 'inset';
6
23
  let shadow = `var(--neo-${glass ? 'glass-' : ''}box-shadow-`;
7
- if (!elevation)
8
- return `${shadow}flat`;
9
- shadow += elevation < 0 ? 'inset' : 'raised';
10
- return `${shadow}-${Math.trunc(Math.abs(elevation))})`;
24
+ const level = computeElevation(elevation, minMax);
25
+ if (!level)
26
+ return `${shadow}flat)`;
27
+ shadow += level < 0 ? inset : raided;
28
+ return `${shadow}-${Math.trunc(Math.abs(level))})`;
11
29
  };
12
- export const computeHoverShadowElevation = (elevation, hover, glass) => {
30
+ export const computeHoverShadowElevation = (elevation, hover, options, minMax = {}) => {
13
31
  if (!hover)
14
32
  return;
15
- let level = elevation + hover;
16
- if (level < -4)
17
- level = -4;
18
- if (level > 4)
19
- level = 4;
20
- return computeShadowElevation(level, glass);
33
+ return computeShadowElevation(elevation + hover, options, minMax);
21
34
  };
22
- export const computeGlassFilter = (elevation, glass) => {
35
+ export const computeGlassFilter = (elevation, glass, { max = MaxShadowElevation, saturation = DefaultSaturation } = {}) => {
23
36
  if (!glass)
24
37
  return;
25
- return `var(--neo-blur-${Math.min(Math.max(Math.abs(elevation + 2), 2), MaxShadowElevation)}) var(--neo-saturate-3)`;
38
+ const _elevation = Math.abs(elevation);
39
+ if (_elevation > max)
40
+ return `var(--neo-blur-${max}) var(--neo-saturate-${saturation})`;
41
+ return `var(--neo-blur-${Math.abs(_elevation)}) var(--neo-saturate-${saturation})`;
42
+ };
43
+ export const computeButtonShadows = (elevation, text) => {
44
+ if (text)
45
+ return;
46
+ return `
47
+ --neo-btn-box-shadow: var(--neo-box-shadow-raised-${Math.min(Math.abs(elevation), 3)});
48
+ --neo-btn-box-shadow-hover: var(--neo-box-shadow-raised-${Math.min(Math.max(Math.abs(elevation) - 1, 1), 2)});
49
+ --neo-btn-box-shadow-focus: var(--neo-box-shadow-raised-${Math.min(Math.max(Math.abs(elevation) - 1, 1), 2)});
50
+ --neo-btn-box-shadow-active: var(--neo-box-shadow-pressed-${Math.min(Math.max(Math.abs(elevation) - 1, 1), 2)});
51
+ --neo-btn-box-shadow-focus-active: var(--neo-box-shadow-pressed-${Math.min(Math.max(Math.abs(elevation) - 1, 1), 2)});
52
+ `;
26
53
  };
@@ -1,5 +1,9 @@
1
+ import { type FadeParams } from 'svelte/transition';
1
2
  import type { TransitionProps } from '@dvcol/svelte-utils/transition';
3
+ import type { TransitionWithProps } from './action.utils.js';
2
4
  export declare const defaultTransitionDuration = 300;
3
5
  export declare const enterFreezeTransition: TransitionProps;
4
6
  export declare const enterDefaultTransition: TransitionProps;
5
7
  export declare const leaveDefaultTransition: TransitionProps;
8
+ export declare const enterDefaultFadeTransition: TransitionWithProps<FadeParams>;
9
+ export declare const leaveDefaultFadeTransition: TransitionWithProps<FadeParams>;
@@ -1,3 +1,4 @@
1
+ import { fade } from 'svelte/transition';
1
2
  export const defaultTransitionDuration = 300;
2
3
  export const enterFreezeTransition = {
3
4
  duration: defaultTransitionDuration,
@@ -5,4 +6,12 @@ export const enterFreezeTransition = {
5
6
  css: `overflow: hidden; white-space: nowrap`,
6
7
  };
7
8
  export const enterDefaultTransition = { duration: 200 };
8
- export const leaveDefaultTransition = { delay: 200, duration: 200 };
9
+ export const leaveDefaultTransition = { delay: 200, duration: 100 };
10
+ export const enterDefaultFadeTransition = {
11
+ use: fade,
12
+ props: enterDefaultTransition,
13
+ };
14
+ export const leaveDefaultFadeTransition = {
15
+ use: fade,
16
+ props: leaveDefaultTransition,
17
+ };
@@ -0,0 +1,6 @@
1
+ export declare const doubleBind: <T = unknown, E = unknown>({ outer, inner, input, output, }: {
2
+ outer: () => T;
3
+ inner: () => T;
4
+ input: () => E;
5
+ output: () => E;
6
+ }) => void;
@@ -0,0 +1,13 @@
1
+ import { watch } from '@dvcol/svelte-utils/watch';
2
+ export const doubleBind = ({ outer, inner, input, output, }) => {
3
+ watch(outer, () => {
4
+ if (outer() === inner())
5
+ return;
6
+ input();
7
+ });
8
+ watch(inner, () => {
9
+ if (outer() === inner())
10
+ return;
11
+ output();
12
+ });
13
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dvcol/neo-svelte",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "Neomorphic ui library for svelte 5",
6
6
  "homepage": "https://github.com/dvcol/neo-svelte",
7
7
  "bugs": "https://github.com/dvcol/neo-svelte/issues",
@@ -82,9 +82,10 @@
82
82
  "svelte": ">=5"
83
83
  },
84
84
  "dependencies": {
85
- "@dvcol/common-utils": "^1.18.3",
86
- "@dvcol/svelte-utils": "^1.3.0",
87
- "svelte": "^5.1.9",
85
+ "@dvcol/common-utils": "^1.19.0",
86
+ "@dvcol/svelte-utils": "^1.4.0",
87
+ "@skeletonlabs/floating-ui-svelte": "^0.3.1",
88
+ "svelte": "^5.16.0",
88
89
  "vite": "^5.4.10"
89
90
  },
90
91
  "devDependencies": {
@@ -92,13 +93,13 @@
92
93
  "@commitlint/config-conventional": "^19.4.1",
93
94
  "@dvcol/eslint-plugin-presets": "^1.3.11",
94
95
  "@dvcol/stylelint-plugin-presets": "^2.1.2",
95
- "@dvcol/svelte-simple-router": "^1.7.3",
96
- "@sveltejs/adapter-auto": "^3.2.5",
97
- "@sveltejs/kit": "^2.7.4",
96
+ "@dvcol/svelte-simple-router": "^1.9.0",
97
+ "@sveltejs/adapter-auto": "^3.3.1",
98
+ "@sveltejs/kit": "^2.15.0",
98
99
  "@sveltejs/package": "^2.3.7",
99
- "@sveltejs/vite-plugin-svelte": "^4.0.0",
100
+ "@sveltejs/vite-plugin-svelte": "^4.0.4",
100
101
  "@testing-library/jest-dom": "^6.6.3",
101
- "@testing-library/svelte": "^5.2.4",
102
+ "@testing-library/svelte": "^5.2.6",
102
103
  "@testing-library/user-event": "^14.5.2",
103
104
  "@tsconfig/node22": "^22.0.0",
104
105
  "@tsconfig/svelte": "^5.0.4",
@@ -115,7 +116,7 @@
115
116
  "eslint-plugin-jsonc": "^2.16.0",
116
117
  "eslint-plugin-markdown": "^3.0.1",
117
118
  "eslint-plugin-prettier": "^5.2.1",
118
- "eslint-plugin-svelte": "^2.44.1",
119
+ "eslint-plugin-svelte": "^2.46.1",
119
120
  "eslint-plugin-vitest": "^0.4.1",
120
121
  "eslint-plugin-yml": "^1.14.0",
121
122
  "extract-changelog-release": "^1.0.2",
@@ -129,12 +130,12 @@
129
130
  "postcss": "^8.4.45",
130
131
  "postcss-syntax": "^0.36.2",
131
132
  "prettier": "^3.3.3",
132
- "prettier-plugin-svelte": "^3.2.6",
133
+ "prettier-plugin-svelte": "^3.3.2",
133
134
  "publint": "^0.2.0",
134
135
  "sass": "^1.77.8",
135
136
  "standard-version": "^9.5.0",
136
137
  "stylelint": "^16.9.0",
137
- "svelte-check": "^4.0.5",
138
+ "svelte-check": "^4.1.1",
138
139
  "svelte-preprocess": "^6.0.3",
139
140
  "typescript": "^5.5.4",
140
141
  "vite": "^5.4.10",