@nanahoshi/mona-ui 0.1.1 → 0.2.1

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 (170) hide show
  1. package/auto-complete/package.json +4 -0
  2. package/avatar/package.json +4 -0
  3. package/breadcrumb/package.json +4 -0
  4. package/button/package.json +4 -0
  5. package/button-group/package.json +4 -0
  6. package/calendar/package.json +4 -0
  7. package/check-box/package.json +4 -0
  8. package/chip/package.json +4 -0
  9. package/circular-progress-bar/package.json +4 -0
  10. package/color-gradient/package.json +4 -0
  11. package/color-palette/package.json +4 -0
  12. package/color-picker/package.json +4 -0
  13. package/combo-box/package.json +4 -0
  14. package/common/package.json +4 -0
  15. package/contextmenu/package.json +4 -0
  16. package/date-input/package.json +4 -0
  17. package/date-picker/package.json +4 -0
  18. package/datetime-picker/package.json +4 -0
  19. package/dialog/package.json +4 -0
  20. package/dropdown-button/package.json +4 -0
  21. package/dropdown-list/package.json +4 -0
  22. package/dropdowns/package.json +4 -0
  23. package/editor/package.json +4 -0
  24. package/expansion-panel/package.json +4 -0
  25. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +40 -55
  26. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +19 -53
  27. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +15 -26
  28. package/fesm2022/nanahoshi-mona-ui-button.mjs +67 -68
  29. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +54 -150
  30. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +67 -99
  31. package/fesm2022/nanahoshi-mona-ui-chip.mjs +35 -45
  32. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +9 -23
  33. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +27 -78
  34. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +17 -39
  35. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +39 -48
  36. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +34 -54
  37. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +9 -12
  38. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +42 -29
  39. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +53 -53
  40. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +40 -153
  41. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +33 -54
  42. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +7 -12
  43. package/fesm2022/nanahoshi-mona-ui-editor.mjs +59 -219
  44. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +24 -75
  45. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +11 -44
  46. package/fesm2022/nanahoshi-mona-ui-filter.mjs +11 -41
  47. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-cell.component-B2ETh-uI.mjs → nanahoshi-mona-ui-grid-grid-footer-cell.component-B6FBLtrr.mjs} +2 -2
  48. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DZk18LJC.mjs → nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-OJe4UYuw.mjs} +4 -8
  49. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-C7WKhhig.mjs → nanahoshi-mona-ui-grid-grid-list.component-DCd8K6ng.mjs} +9 -16
  50. package/fesm2022/{nanahoshi-mona-ui-grid-grid-toggle.component-BRiY0CDX.mjs → nanahoshi-mona-ui-grid-grid-toggle.component-Dl8Hlkhj.mjs} +15 -44
  51. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BrYpFMyF.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-C5FRZlvv.mjs} +11 -20
  52. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-T9Bj98kl.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BRZUd8cE.mjs} +109 -393
  53. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  54. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +10 -28
  55. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +27 -57
  56. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +31 -122
  57. package/fesm2022/nanahoshi-mona-ui-internal.mjs +29 -1
  58. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +4 -26
  59. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +5 -18
  60. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +48 -154
  61. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +36 -63
  62. package/fesm2022/nanahoshi-mona-ui-notification.mjs +24 -108
  63. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +38 -64
  64. package/fesm2022/nanahoshi-mona-ui-pager.mjs +21 -73
  65. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +8 -30
  66. package/fesm2022/nanahoshi-mona-ui-popover.mjs +29 -50
  67. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +36 -108
  68. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +19 -60
  69. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +78 -98
  70. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +53 -144
  71. package/fesm2022/nanahoshi-mona-ui-slider.mjs +54 -110
  72. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +7 -20
  73. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +15 -50
  74. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +28 -91
  75. package/fesm2022/nanahoshi-mona-ui-switch.mjs +37 -59
  76. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +35 -107
  77. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +19 -31
  78. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +60 -65
  79. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1111 -269
  80. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +43 -29
  81. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +40 -102
  82. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +13 -41
  83. package/fesm2022/nanahoshi-mona-ui-window.mjs +29 -108
  84. package/fieldset/package.json +4 -0
  85. package/filter/package.json +4 -0
  86. package/grid/package.json +4 -0
  87. package/internal/filter-input/package.json +4 -0
  88. package/internal/indicator-icon/package.json +4 -0
  89. package/internal/list/package.json +4 -0
  90. package/internal/package.json +4 -0
  91. package/internal/tree/package.json +4 -0
  92. package/list/package.json +4 -0
  93. package/list-box/package.json +4 -0
  94. package/list-view/package.json +4 -0
  95. package/menubar/package.json +4 -0
  96. package/multi-select/package.json +4 -0
  97. package/notification/package.json +4 -0
  98. package/numeric-text-box/package.json +4 -0
  99. package/package.json +2 -1
  100. package/pager/package.json +4 -0
  101. package/placeholder/package.json +4 -0
  102. package/popover/package.json +4 -0
  103. package/popup/package.json +4 -0
  104. package/popup-menu/package.json +4 -0
  105. package/progress-bar/package.json +4 -0
  106. package/query/package.json +4 -0
  107. package/radio-button/package.json +4 -0
  108. package/scroll-view/package.json +4 -0
  109. package/slider/package.json +4 -0
  110. package/split-button/package.json +4 -0
  111. package/splitter/package.json +4 -0
  112. package/stepper/package.json +4 -0
  113. package/switch/package.json +4 -0
  114. package/tabs/package.json +4 -0
  115. package/text-area/package.json +4 -0
  116. package/text-box/package.json +4 -0
  117. package/theme/package.json +4 -0
  118. package/time-picker/package.json +4 -0
  119. package/time-selector/package.json +4 -0
  120. package/tooltip/package.json +4 -0
  121. package/tree-view/package.json +4 -0
  122. package/types/nanahoshi-mona-ui-auto-complete.d.ts +6 -7
  123. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +4 -6
  124. package/types/nanahoshi-mona-ui-button-group.d.ts +2 -3
  125. package/types/nanahoshi-mona-ui-button.d.ts +2 -3
  126. package/types/nanahoshi-mona-ui-calendar.d.ts +21 -22
  127. package/types/nanahoshi-mona-ui-check-box.d.ts +18 -10
  128. package/types/nanahoshi-mona-ui-chip.d.ts +2 -3
  129. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +2 -4
  130. package/types/nanahoshi-mona-ui-color-gradient.d.ts +10 -11
  131. package/types/nanahoshi-mona-ui-color-palette.d.ts +4 -5
  132. package/types/nanahoshi-mona-ui-color-picker.d.ts +6 -5
  133. package/types/nanahoshi-mona-ui-combo-box.d.ts +6 -7
  134. package/types/nanahoshi-mona-ui-date-input.d.ts +2 -3
  135. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -3
  136. package/types/nanahoshi-mona-ui-dialog.d.ts +6 -7
  137. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +6 -7
  138. package/types/nanahoshi-mona-ui-dropdowns.d.ts +2 -3
  139. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +8 -10
  140. package/types/nanahoshi-mona-ui-fieldset.d.ts +6 -8
  141. package/types/nanahoshi-mona-ui-filter.d.ts +2 -3
  142. package/types/nanahoshi-mona-ui-grid.d.ts +14 -15
  143. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +0 -1
  144. package/types/nanahoshi-mona-ui-internal.d.ts +8 -1
  145. package/types/nanahoshi-mona-ui-list-box.d.ts +4 -5
  146. package/types/nanahoshi-mona-ui-list-view.d.ts +2 -3
  147. package/types/nanahoshi-mona-ui-menubar.d.ts +6 -7
  148. package/types/nanahoshi-mona-ui-multi-select.d.ts +8 -9
  149. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +2 -3
  150. package/types/nanahoshi-mona-ui-pager.d.ts +6 -7
  151. package/types/nanahoshi-mona-ui-placeholder.d.ts +4 -6
  152. package/types/nanahoshi-mona-ui-popover.d.ts +8 -9
  153. package/types/nanahoshi-mona-ui-popup-menu.d.ts +12 -13
  154. package/types/nanahoshi-mona-ui-progress-bar.d.ts +8 -9
  155. package/types/nanahoshi-mona-ui-radio-button.d.ts +28 -13
  156. package/types/nanahoshi-mona-ui-scroll-view.d.ts +18 -20
  157. package/types/nanahoshi-mona-ui-slider.d.ts +18 -18
  158. package/types/nanahoshi-mona-ui-split-button.d.ts +2 -3
  159. package/types/nanahoshi-mona-ui-splitter.d.ts +6 -8
  160. package/types/nanahoshi-mona-ui-stepper.d.ts +12 -13
  161. package/types/nanahoshi-mona-ui-switch.d.ts +6 -7
  162. package/types/nanahoshi-mona-ui-tabs.d.ts +14 -16
  163. package/types/nanahoshi-mona-ui-text-area.d.ts +2 -4
  164. package/types/nanahoshi-mona-ui-text-box.d.ts +16 -7
  165. package/types/nanahoshi-mona-ui-theme.d.ts +111 -12
  166. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -3
  167. package/types/nanahoshi-mona-ui-time-selector.d.ts +11 -11
  168. package/types/nanahoshi-mona-ui-tooltip.d.ts +4 -5
  169. package/types/nanahoshi-mona-ui-window.d.ts +16 -17
  170. package/window/package.json +4 -0
@@ -3,7 +3,6 @@ import { Directive, inject, ElementRef, computed, input, afterRenderEffect, Dest
3
3
  import { NgTemplateOutlet } from '@angular/common';
4
4
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
5
  import { select } from '@mirei/ts-collections';
6
- import { ThemeService } from '@nanahoshi/mona-ui/theme';
7
6
  import { fromEvent } from 'rxjs';
8
7
  import { cva } from 'class-variance-authority';
9
8
 
@@ -53,12 +52,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
53
52
  }]
54
53
  }] });
55
54
 
56
- const stepperBaseVariants = cva(`
55
+ const stepperBaseThemeVariants = cva(`
57
56
  relative grid outline-none
58
57
  `, {
59
58
  variants: {
60
59
  orientation: {
61
- horizontal: "w-full h-auto",
60
+ horizontal: "h-auto w-full",
62
61
  vertical: "h-full w-auto"
63
62
  }
64
63
  },
@@ -66,18 +65,18 @@ const stepperBaseVariants = cva(`
66
65
  orientation: "horizontal"
67
66
  }
68
67
  });
69
- const stepperStepListVariants = cva(`
70
- absolute flex list-none col-span-full
71
- font-medium z-1
68
+ const stepperStepListThemeVariants = cva(`
69
+ absolute z-1 col-span-full flex list-none
70
+ font-medium
72
71
  `, {
73
72
  variants: {
74
73
  orientation: {
75
74
  horizontal: `
76
- flex-row w-full
75
+ w-full flex-row
77
76
  -translate-y-3
78
77
  `,
79
78
  vertical: `
80
- flex-col h-full w-max
79
+ h-full w-max flex-col
81
80
  -translate-x-3
82
81
  `
83
82
  }
@@ -86,35 +85,31 @@ const stepperStepListVariants = cva(`
86
85
  orientation: "horizontal"
87
86
  }
88
87
  });
89
- const stepperStepListItemVariants = cva(`
90
- flex items-center
91
- grow-1 shrink-0 basis-auto
92
- z-1
88
+ const stepperStepListItemThemeVariants = cva(`
89
+ z-1 flex grow-1 shrink-0 basis-auto items-center
93
90
  `, {
94
91
  variants: {
95
92
  orientation: {
96
93
  horizontal: "flex-col gap-2",
97
- vertical: "flex-row gap-2 justify-start"
94
+ vertical: "flex-row justify-start gap-2"
98
95
  }
99
96
  },
100
97
  defaultVariants: {
101
98
  orientation: "horizontal"
102
99
  }
103
100
  });
104
- const stepperStepIndicatorVariants = cva(`
105
- w-8 h-8
106
- flex items-center justify-center
107
- bg-background border border-border
108
- text-foreground outline-none
101
+ const stepperStepIndicatorThemeVariants = cva(`
102
+ flex h-8 w-8 items-center justify-center
103
+ border border-border outline-none
109
104
  transition-colors duration-400 ease-in-out
110
105
  `, {
111
106
  variants: {
112
107
  active: {
113
108
  true: "bg-primary text-primary-foreground",
114
- false: ""
109
+ false: "bg-surface-raised text-foreground"
115
110
  },
116
111
  focused: {
117
- true: "ring-2 ring-primary/40",
112
+ true: "border-focus-indicator ring-2 ring-focus-indicator/35",
118
113
  false: ""
119
114
  },
120
115
  rounded: {
@@ -126,13 +121,14 @@ const stepperStepIndicatorVariants = cva(`
126
121
  }
127
122
  }
128
123
  });
129
- const stepperTrackVariants = cva(`
124
+ const stepperTrackThemeVariants = cva(`
130
125
  relative grid
131
- bg-background text-foreground border border-border
126
+ bg-surface-muted text-foreground
127
+ border border-border-subtle
132
128
  `, {
133
129
  variants: {
134
130
  orientation: {
135
- horizontal: "w-full h-2",
131
+ horizontal: "h-2 w-full",
136
132
  vertical: "h-full w-2"
137
133
  }
138
134
  },
@@ -140,13 +136,13 @@ const stepperTrackVariants = cva(`
140
136
  orientation: "horizontal"
141
137
  }
142
138
  });
143
- const stepperTrackLineVariants = cva(`
139
+ const stepperTrackLineThemeVariants = cva(`
144
140
  absolute bg-primary
145
141
  `, {
146
142
  variants: {
147
143
  orientation: {
148
- horizontal: "h-full transition-width duration-300 ease-out",
149
- vertical: "w-full transition-height duration-300 ease-out"
144
+ horizontal: "h-full transition-width duration-(--mona-motion-standard) ease-out",
145
+ vertical: "w-full transition-height duration-(--mona-motion-standard) ease-out"
150
146
  }
151
147
  },
152
148
  defaultVariants: {
@@ -154,69 +150,17 @@ const stepperTrackLineVariants = cva(`
154
150
  }
155
151
  });
156
152
 
157
- const stepperBaseThemeVariants = (theme) => {
158
- switch (theme) {
159
- case "mona":
160
- return stepperBaseVariants;
161
- default:
162
- return stepperBaseVariants;
163
- }
164
- };
165
- const stepperStepListThemeVariants = (theme) => {
166
- switch (theme) {
167
- case "mona":
168
- return stepperStepListVariants;
169
- default:
170
- return stepperStepListVariants;
171
- }
172
- };
173
- const stepperStepListItemThemeVariants = (theme) => {
174
- switch (theme) {
175
- case "mona":
176
- return stepperStepListItemVariants;
177
- default:
178
- return stepperStepListItemVariants;
179
- }
180
- };
181
- const stepperStepIndicatorThemeVariants = (theme) => {
182
- switch (theme) {
183
- case "mona":
184
- return stepperStepIndicatorVariants;
185
- default:
186
- return stepperStepIndicatorVariants;
187
- }
188
- };
189
- const stepperTrackThemeVariants = (theme) => {
190
- switch (theme) {
191
- case "mona":
192
- return stepperTrackVariants;
193
- default:
194
- return stepperTrackVariants;
195
- }
196
- };
197
- const stepperTrackLineThemeVariants = (theme) => {
198
- switch (theme) {
199
- case "mona":
200
- return stepperTrackLineVariants;
201
- default:
202
- return stepperTrackLineVariants;
203
- }
204
- };
205
-
206
153
  class StepperIndicatorDirective {
207
154
  #wasFocused;
208
155
  #host;
209
- #themeService;
210
156
  constructor() {
211
157
  this.#wasFocused = false;
212
158
  this.#host = inject(ElementRef);
213
- this.#themeService = inject(ThemeService);
214
159
  this.stepIndicatorClass = computed(() => {
215
- const theme = this.#themeService.theme();
216
160
  const active = this.active();
217
161
  const focused = this.focused();
218
162
  const rounded = this.rounded();
219
- return stepperStepIndicatorThemeVariants(theme)({ active, focused, rounded });
163
+ return stepperStepIndicatorThemeVariants({ active, focused, rounded });
220
164
  }, /* @ts-ignore */
221
165
  ...(ngDevMode ? [{ debugName: "stepIndicatorClass" }] : /* istanbul ignore next */ []));
222
166
  this.active = input.required(/* @ts-ignore */
@@ -251,13 +195,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
251
195
  class StepperComponent {
252
196
  #destroyRef;
253
197
  #hostElementRef;
254
- #themeService;
255
198
  #trackItemSize;
256
199
  #trackLength;
257
200
  constructor() {
258
201
  this.#destroyRef = inject(DestroyRef);
259
202
  this.#hostElementRef = inject(ElementRef);
260
- this.#themeService = inject(ThemeService);
261
203
  this.#trackItemSize = computed(() => {
262
204
  const stepCount = this.viewSteps().length;
263
205
  return stepCount !== 0 ? 100 / stepCount : 0;
@@ -280,9 +222,8 @@ class StepperComponent {
280
222
  }, /* @ts-ignore */
281
223
  ...(ngDevMode ? [{ debugName: "activeStep" }] : /* istanbul ignore next */ []));
282
224
  this.baseClass = computed(() => {
283
- const theme = this.#themeService.theme();
284
225
  const orientation = this.orientation();
285
- return stepperBaseThemeVariants(theme)({ orientation });
226
+ return stepperBaseThemeVariants({ orientation });
286
227
  }, /* @ts-ignore */
287
228
  ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
288
229
  this.highlightedStep = signal(0, /* @ts-ignore */
@@ -301,15 +242,13 @@ class StepperComponent {
301
242
  });
302
243
  this.labelTemplate = contentChild(StepperLabelTemplateDirective, { read: TemplateRef });
303
244
  this.listClass = computed(() => {
304
- const theme = this.#themeService.theme();
305
245
  const orientation = this.orientation();
306
- return stepperStepListThemeVariants(theme)({ orientation });
246
+ return stepperStepListThemeVariants({ orientation });
307
247
  }, /* @ts-ignore */
308
248
  ...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
309
249
  this.listItemClass = computed(() => {
310
- const theme = this.#themeService.theme();
311
250
  const orientation = this.orientation();
312
- return stepperStepListItemThemeVariants(theme)({ orientation });
251
+ return stepperStepListItemThemeVariants({ orientation });
313
252
  }, /* @ts-ignore */
314
253
  ...(ngDevMode ? [{ debugName: "listItemClass" }] : /* istanbul ignore next */ []));
315
254
  this.progressMax = computed(() => Math.max(this.viewSteps().length - 1, 0), /* @ts-ignore */
@@ -318,9 +257,8 @@ class StepperComponent {
318
257
  read: TemplateRef
319
258
  });
320
259
  this.trackClass = computed(() => {
321
- const theme = this.#themeService.theme();
322
260
  const orientation = this.orientation();
323
- return stepperTrackThemeVariants(theme)({ orientation });
261
+ return stepperTrackThemeVariants({ orientation });
324
262
  }, /* @ts-ignore */
325
263
  ...(ngDevMode ? [{ debugName: "trackClass" }] : /* istanbul ignore next */ []));
326
264
  this.trackInnerStyles = computed(() => {
@@ -340,9 +278,8 @@ class StepperComponent {
340
278
  }, /* @ts-ignore */
341
279
  ...(ngDevMode ? [{ debugName: "trackItemStyles" }] : /* istanbul ignore next */ []));
342
280
  this.trackLineClass = computed(() => {
343
- const theme = this.#themeService.theme();
344
281
  const orientation = this.orientation();
345
- return stepperTrackLineThemeVariants(theme)({ orientation });
282
+ return stepperTrackLineThemeVariants({ orientation });
346
283
  }, /* @ts-ignore */
347
284
  ...(ngDevMode ? [{ debugName: "trackLineClass" }] : /* istanbul ignore next */ []));
348
285
  this.trackStyles = computed(() => {
@@ -2,10 +2,10 @@ import { NgTemplateOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
3
  import { Directive, inject, DestroyRef, ElementRef, computed, contentChild, TemplateRef, input, model, output, afterNextRender, Component } from '@angular/core';
4
4
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
- import { ThemeService } from '@nanahoshi/mona-ui/theme';
6
5
  import { fromEvent, filter, tap, merge } from 'rxjs';
7
6
  import { twMerge } from 'tailwind-merge';
8
7
  import { cva } from 'class-variance-authority';
8
+ import { themeControlSurfaceClasses, themeRaisedSurfaceClasses } from '@nanahoshi/mona-ui/internal';
9
9
 
10
10
  class SwitchHandleContentTemplateDirective {
11
11
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SwitchHandleContentTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
@@ -40,26 +40,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
40
40
  }]
41
41
  }] });
42
42
 
43
- const switchVariants = cva(`
44
- relative flex items-center cursor-pointer select-none
45
- transition-[background]
46
-
47
- bg-input-background
43
+ const switchThemeVariants = cva(`
44
+ group relative flex items-center
45
+ cursor-pointer select-none
46
+ ${themeControlSurfaceClasses}
48
47
  border border-input-border
49
48
  outline-none
50
-
51
- focus-within:ring-2 focus-within:ring-primary/40
49
+ transition-[background,border-color]
52
50
 
53
51
  data-[disabled='true']:pointer-events-none
54
- data-[disabled='true']:opacity-50
52
+ data-[disabled='true']:cursor-not-allowed
53
+ data-[disabled='true']:border-disabled-border
54
+ data-[disabled='true']:bg-disabled-background
55
+ data-[disabled='true']:text-disabled-foreground
55
56
 
56
57
  data-[active='true']:bg-primary
57
58
  data-[active='true']:text-primary-foreground
59
+ data-[disabled='true']:data-[active='true']:bg-disabled-background
58
60
 
59
- [&.ng-touched.ng-invalid]:border-error
61
+ focus-visible:border-focus-indicator
62
+ focus-visible:ring-2 focus-visible:ring-focus-indicator/35
60
63
 
61
64
  data-[invalid='true']:border-error
62
- data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/40
65
+ data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
66
+ data-[invalid='true']:focus-visible:border-error
67
+ data-[invalid='true']:focus-visible:ring-error/35
63
68
  `, {
64
69
  variants: {
65
70
  rounded: {
@@ -70,18 +75,21 @@ const switchVariants = cva(`
70
75
  small: "rounded-sm"
71
76
  },
72
77
  size: {
73
- large: "w-14 h-7.5 text-md",
74
- medium: "w-12 h-6.5 text-sm",
75
- small: "w-10 h-5.5 text-xs"
78
+ large: "h-7.5 w-14 text-md",
79
+ medium: "h-6.5 w-12 text-sm",
80
+ small: "h-5.5 w-10 text-xs"
76
81
  }
77
82
  }
78
83
  });
79
- const switchHandleVariants = cva(`
80
- absolute inline-flex
81
- items-center justify-center
82
- outline-none transition-[left,background] ease-in-out duration-300
83
- border border-border bg-secondary
84
- data-[active='true']:bg-background text-foreground
84
+ const switchHandleThemeVariants = cva(`
85
+ absolute inline-flex items-center justify-center
86
+ ${themeRaisedSurfaceClasses} text-foreground
87
+ border border-border-subtle shadow-(--shadow-control)
88
+ outline-none
89
+ transition-[left,background] duration-(--mona-motion-standard) ease-in-out
90
+ data-[active='true']:bg-primary-foreground
91
+ group-data-[disabled='true']:border-disabled-border
92
+ group-data-[disabled='true']:bg-disabled-background
85
93
  `, {
86
94
  variants: {
87
95
  rounded: {
@@ -93,82 +101,52 @@ const switchHandleVariants = cva(`
93
101
  },
94
102
  size: {
95
103
  large: `
96
- w-6 h-6
104
+ h-6 w-6
97
105
  data-[active='true']:left-[calc(100%-26px)]
98
106
  data-[active='false']:left-0.5
99
107
  `,
100
108
  medium: `
101
- w-5 h-5
109
+ h-5 w-5
102
110
  data-[active='true']:left-[calc(100%-22px)]
103
111
  data-[active='false']:left-0.5
104
112
  `,
105
113
  small: `
106
- w-4 h-4
114
+ h-4 w-4
107
115
  data-[active='true']:left-[calc(100%-18px)]
108
116
  data-[active='false']:left-0.5
109
117
  `
110
118
  }
111
119
  }
112
120
  });
113
- const switchLabelVariants = cva(`
114
- h-full flex flex-1 items-center justify-center text-xs
121
+ const switchLabelThemeVariants = cva(`
122
+ flex h-full flex-1 items-center justify-center text-xs
115
123
  `);
116
124
 
117
- const switchThemeVariants = (theme) => {
118
- switch (theme) {
119
- case "mona":
120
- return switchVariants;
121
- default:
122
- return switchVariants; // Default to Mona styles
123
- }
124
- };
125
- const switchHandleThemeVariants = (theme) => {
126
- switch (theme) {
127
- case "mona":
128
- return switchHandleVariants;
129
- default:
130
- return switchHandleVariants; // Default to Mona styles
131
- }
132
- };
133
- const switchLabelThemeVariants = (theme) => {
134
- switch (theme) {
135
- case "mona":
136
- return switchLabelVariants;
137
- default:
138
- return switchLabelVariants; // Default to Mona styles
139
- }
140
- };
141
-
142
125
  class SwitchComponent {
143
126
  #destroyRef;
144
127
  #hostElementRef;
145
- #themeService;
146
128
  constructor() {
147
129
  this.#destroyRef = inject(DestroyRef);
148
130
  this.#hostElementRef = inject((ElementRef));
149
- this.#themeService = inject(ThemeService);
150
131
  this.classes = computed(() => {
151
- const theme = this.#themeService.theme();
152
132
  const rounded = this.rounded();
153
133
  const size = this.size();
154
- const classes = switchThemeVariants(theme)({ rounded, size });
134
+ const classes = switchThemeVariants({ rounded, size });
155
135
  return twMerge(classes, this.userClass());
156
136
  }, /* @ts-ignore */
157
137
  ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
158
- this.invalidState = computed(() => this.invalid() || (this.required() && this.touched() && !this.checked()), /* @ts-ignore */
138
+ this.invalidState = computed(() => this.touched() && (this.invalid() || (this.required() && !this.checked())), /* @ts-ignore */
159
139
  ...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
160
140
  this.handleClasses = computed(() => {
161
- const theme = this.#themeService.theme();
162
141
  const rounded = this.rounded();
163
142
  const size = this.size();
164
- const classes = switchHandleThemeVariants(theme)({ rounded, size });
143
+ const classes = switchHandleThemeVariants({ rounded, size });
165
144
  return twMerge(classes);
166
145
  }, /* @ts-ignore */
167
146
  ...(ngDevMode ? [{ debugName: "handleClasses" }] : /* istanbul ignore next */ []));
168
147
  this.handleContentTemplate = contentChild(SwitchHandleContentTemplateDirective, { ...(ngDevMode ? { debugName: "handleContentTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
169
148
  this.labelClasses = computed(() => {
170
- const theme = this.#themeService.theme();
171
- const classes = switchLabelThemeVariants(theme)();
149
+ const classes = switchLabelThemeVariants();
172
150
  return twMerge(classes);
173
151
  }, /* @ts-ignore */
174
152
  ...(ngDevMode ? [{ debugName: "labelClasses" }] : /* istanbul ignore next */ []));