@globalbrain/sefirot 0.72.0 → 2.0.0-draft.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 (174) hide show
  1. package/CHANGELOG.md +2 -820
  2. package/README.md +1 -1
  3. package/lib/assets/styles/bootstrap.css +1 -2
  4. package/lib/assets/styles/variables.css +14 -47
  5. package/lib/components/SAvatar.vue +9 -18
  6. package/lib/components/SButton.vue +35 -48
  7. package/lib/components/SDialog.vue +16 -34
  8. package/lib/components/SDropdown.vue +36 -55
  9. package/lib/components/SDropdownItem.vue +27 -39
  10. package/lib/components/SDropdownItemText.vue +4 -9
  11. package/lib/components/SDropdownItemUser.vue +4 -12
  12. package/lib/components/SInputBase.vue +33 -45
  13. package/lib/components/SInputCheckbox.vue +17 -37
  14. package/lib/components/SInputDropdown.vue +109 -171
  15. package/lib/components/SInputDropdownItem.vue +26 -32
  16. package/lib/components/SInputDropdownItemText.vue +6 -11
  17. package/lib/components/SInputDropdownItemTextTag.vue +10 -17
  18. package/lib/components/SInputDropdownItemUser.vue +5 -13
  19. package/lib/components/SInputDropdownItemUserTag.vue +9 -16
  20. package/lib/components/SInputFile.vue +38 -53
  21. package/lib/components/SInputHMS.vue +91 -114
  22. package/lib/components/SInputNumber.vue +27 -106
  23. package/lib/components/SInputRadio.vue +21 -34
  24. package/lib/components/SInputRadios.vue +36 -46
  25. package/lib/components/SInputText.vue +59 -633
  26. package/lib/components/SInputTextarea.vue +54 -113
  27. package/lib/components/SInputYMD.vue +94 -105
  28. package/lib/components/SLink.vue +16 -52
  29. package/lib/components/SModal.vue +53 -90
  30. package/lib/components/SPortalModals.vue +37 -53
  31. package/lib/components/SPortalSnackbars.vue +9 -24
  32. package/lib/components/SSheet.vue +10 -23
  33. package/lib/components/SSheetFooter.vue +0 -2
  34. package/lib/components/SSheetFooterAction.vue +9 -14
  35. package/lib/components/SSheetFooterActions.vue +1 -3
  36. package/lib/components/SSheetHeader.vue +9 -24
  37. package/lib/components/SSheetHeaderTitle.vue +0 -2
  38. package/lib/components/SSheetMedium.vue +12 -14
  39. package/lib/components/SSnackbar.vue +18 -28
  40. package/lib/composables/Dialog.ts +9 -17
  41. package/lib/composables/Dropdown.ts +1 -1
  42. package/lib/composables/{Menu.ts → Flyout.ts} +11 -4
  43. package/lib/composables/Form.ts +42 -44
  44. package/lib/composables/Modal.ts +9 -9
  45. package/lib/composables/Snackbar.ts +18 -0
  46. package/lib/composables/Validation.ts +28 -0
  47. package/lib/mixins/Sheet.ts +3 -3
  48. package/lib/store/Sefirot.ts +8 -13
  49. package/lib/store/dialog/index.ts +20 -10
  50. package/lib/store/modal/index.ts +11 -13
  51. package/lib/store/snackbars/index.ts +3 -4
  52. package/lib/support/{Util.ts → Utils.ts} +0 -2
  53. package/lib/types/Utils.ts +0 -7
  54. package/lib/types/vue-shims.d.ts +7 -0
  55. package/lib/validation/rules/checked.ts +6 -10
  56. package/lib/validation/rules/fileExtension.ts +9 -9
  57. package/lib/validation/rules/hms.ts +9 -9
  58. package/lib/validation/rules/index.ts +10 -74
  59. package/lib/validation/rules/maxLength.ts +10 -9
  60. package/lib/validation/rules/minLength.ts +12 -0
  61. package/lib/validation/rules/required.ts +2 -10
  62. package/lib/validation/rules/requiredHms.ts +11 -0
  63. package/lib/validation/rules/requiredIf.ts +3 -11
  64. package/lib/validation/rules/requiredYmd.ts +11 -0
  65. package/lib/validation/rules/ymd.ts +11 -0
  66. package/lib/validation/validators/checked.ts +1 -1
  67. package/lib/validation/validators/fileExtension.ts +1 -1
  68. package/lib/validation/validators/hms.ts +5 -5
  69. package/lib/validation/validators/requiredHms.ts +17 -0
  70. package/lib/validation/validators/requiredYmd.ts +7 -0
  71. package/lib/validation/validators/ymd.ts +41 -0
  72. package/package.json +45 -50
  73. package/lib/components/SAction.vue +0 -37
  74. package/lib/components/SActionAvatar.vue +0 -25
  75. package/lib/components/SActionButton.vue +0 -40
  76. package/lib/components/SActionPill.vue +0 -35
  77. package/lib/components/SActionSwitch.vue +0 -37
  78. package/lib/components/SAlert.vue +0 -145
  79. package/lib/components/SButtonGroup.vue +0 -160
  80. package/lib/components/SCard.vue +0 -111
  81. package/lib/components/SCardFooter.vue +0 -74
  82. package/lib/components/SCardHeader.vue +0 -213
  83. package/lib/components/SGrid.vue +0 -237
  84. package/lib/components/SGridActionLink.vue +0 -53
  85. package/lib/components/SGridActionMulti.vue +0 -139
  86. package/lib/components/SGridActionSingle.vue +0 -64
  87. package/lib/components/SHeader.vue +0 -180
  88. package/lib/components/SInputCheckboxes.vue +0 -87
  89. package/lib/components/SInputDate.vue +0 -192
  90. package/lib/components/SInputDay.vue +0 -87
  91. package/lib/components/SInputMonth.vue +0 -86
  92. package/lib/components/SInputSelect.vue +0 -298
  93. package/lib/components/SInputSwitch.vue +0 -212
  94. package/lib/components/SInputSwitches.vue +0 -108
  95. package/lib/components/SInputTime.vue +0 -255
  96. package/lib/components/SInputYear.vue +0 -60
  97. package/lib/components/SMarkdown.vue +0 -56
  98. package/lib/components/SPlaceholderBlank.vue +0 -113
  99. package/lib/components/SPlaceholderImage.vue +0 -83
  100. package/lib/components/SPortalScreens.vue +0 -62
  101. package/lib/components/SProgressBar.vue +0 -89
  102. package/lib/components/SResponsive.vue +0 -46
  103. package/lib/components/SScreen.vue +0 -81
  104. package/lib/components/SStep.vue +0 -107
  105. package/lib/components/SSteps.vue +0 -75
  106. package/lib/components/STag.vue +0 -67
  107. package/lib/components/STooltip.vue +0 -134
  108. package/lib/components/SWindow.vue +0 -158
  109. package/lib/components/icons/SIconCopy.vue +0 -6
  110. package/lib/composables/Action.ts +0 -141
  111. package/lib/composables/Alert.ts +0 -50
  112. package/lib/composables/Card.ts +0 -46
  113. package/lib/composables/FormValidation.ts +0 -150
  114. package/lib/composables/Header.ts +0 -72
  115. package/lib/composables/InputDropdown.ts +0 -6
  116. package/lib/composables/Markdown.ts +0 -138
  117. package/lib/composables/Router.ts +0 -20
  118. package/lib/composables/Step.ts +0 -7
  119. package/lib/composables/Store.ts +0 -9
  120. package/lib/composables/Tag.ts +0 -32
  121. package/lib/composables/Tooltip.ts +0 -91
  122. package/lib/composables/Utils.ts +0 -115
  123. package/lib/composables/markdown/LinkPlugin.ts +0 -45
  124. package/lib/compositions/useForm.ts +0 -17
  125. package/lib/compositions/useResizeObserver.ts +0 -25
  126. package/lib/compositions/useTime.ts +0 -26
  127. package/lib/store/alert/index.ts +0 -32
  128. package/lib/store/screen/index.ts +0 -46
  129. package/lib/types/v-calendar.d.ts +0 -5
  130. package/lib/validation/Validation.ts +0 -151
  131. package/lib/validation/rules/day.ts +0 -11
  132. package/lib/validation/rules/email.ts +0 -11
  133. package/lib/validation/rules/every.ts +0 -38
  134. package/lib/validation/rules/include.ts +0 -11
  135. package/lib/validation/rules/includeSome.ts +0 -11
  136. package/lib/validation/rules/integer.ts +0 -11
  137. package/lib/validation/rules/maxValue.ts +0 -11
  138. package/lib/validation/rules/minValue.ts +0 -11
  139. package/lib/validation/rules/month.ts +0 -11
  140. package/lib/validation/rules/not.ts +0 -10
  141. package/lib/validation/rules/regex.ts +0 -11
  142. package/lib/validation/rules/requiredHMS.ts +0 -11
  143. package/lib/validation/rules/requiredMonthDate.ts +0 -11
  144. package/lib/validation/rules/requiredYearMonth.ts +0 -11
  145. package/lib/validation/rules/requiredYearMonthDate.ts +0 -11
  146. package/lib/validation/rules/rule.ts +0 -5
  147. package/lib/validation/rules/sameAs.ts +0 -11
  148. package/lib/validation/rules/url.ts +0 -11
  149. package/lib/validation/rules/validateIf.ts +0 -27
  150. package/lib/validation/rules/year.ts +0 -11
  151. package/lib/validation/rules/yearMonth.ts +0 -11
  152. package/lib/validation/rules/yearMonthDate.ts +0 -11
  153. package/lib/validation/validators/day.ts +0 -29
  154. package/lib/validation/validators/email.ts +0 -5
  155. package/lib/validation/validators/include.ts +0 -5
  156. package/lib/validation/validators/includeSome.ts +0 -5
  157. package/lib/validation/validators/index.ts +0 -51
  158. package/lib/validation/validators/integer.ts +0 -6
  159. package/lib/validation/validators/maxLength.ts +0 -3
  160. package/lib/validation/validators/maxValue.ts +0 -3
  161. package/lib/validation/validators/minValue.ts +0 -3
  162. package/lib/validation/validators/month.ts +0 -3
  163. package/lib/validation/validators/monthDate.ts +0 -20
  164. package/lib/validation/validators/regex.ts +0 -3
  165. package/lib/validation/validators/required.ts +0 -27
  166. package/lib/validation/validators/requiredHMS.ts +0 -17
  167. package/lib/validation/validators/requiredMonthDate.ts +0 -8
  168. package/lib/validation/validators/requiredYearMonth.ts +0 -8
  169. package/lib/validation/validators/requiredYearMonthDate.ts +0 -9
  170. package/lib/validation/validators/sameAs.ts +0 -5
  171. package/lib/validation/validators/url.ts +0 -5
  172. package/lib/validation/validators/year.ts +0 -3
  173. package/lib/validation/validators/yearMonth.ts +0 -20
  174. package/lib/validation/validators/yearMonthDate.ts +0 -21
package/README.md CHANGED
@@ -20,7 +20,7 @@ We're really excited that you are interested in contributing to Sefirot. Before
20
20
 
21
21
  ### Code style guide
22
22
 
23
- Sefirot follows the official [Vue Style Guide](https://vuejs.org/v2/style-guide/). But always remember to follow the "Golden Rule"…
23
+ Sefirot follows the official [Vue Style Guide](https://v3.vuejs.org/style-guide/). But always remember to follow the "Golden Rule"…
24
24
 
25
25
  > Every line of code should appear to be written by a single person, no matter the number of contributors.
26
26
  > &mdash; <cite>@mdo</cite>
@@ -1,4 +1,3 @@
1
- @import 'simplebar/dist/simplebar.min';
2
-
1
+ @import "normalize.css";
3
2
  @import "./variables";
4
3
  @import "./base";
@@ -105,7 +105,7 @@
105
105
  --c-text-inverse-4: var(--c-text-dark-4);
106
106
  }
107
107
 
108
- .dark-mode {
108
+ .dark {
109
109
  --c-bg: var(--c-black-deep);
110
110
  --c-bg-soft: var(--c-black-soft);
111
111
  --c-bg-mute: var(--c-black-mute);
@@ -129,9 +129,7 @@
129
129
  * -------------------------------------------------------------------------- */
130
130
 
131
131
  :root {
132
- --font-family-base: "Roboto", "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Helvetica Neue", "Arial", "sans-serif";
133
- --font-family-primary: "interstate", "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica Neue", "Arial", "sans-serif";
134
- --font-family-number: "Roboto", "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Helvetica Neue", "Arial", "sans-serif";
132
+ --font-family-base: "Roboto", "Noto Sans JP", "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Helvetica Neue", "Arial", "sans-serif";
135
133
  --font-family-mono: "source-code-pro", "Menlo", "Monaco", "Consolas", "Courier New", monospace;
136
134
  }
137
135
 
@@ -152,12 +150,8 @@
152
150
  * -------------------------------------------------------------------------- */
153
151
 
154
152
  :root {
155
- --z-index-tooltip: 1000;
156
- --z-index-dropdown: 2000;
157
- --z-index-screen: 3000;
158
- --z-index-backdrop: 4000;
159
- --z-index-modal: 4100;
160
- --z-index-snackbar: 5000;
153
+ --z-index-dropdown: 1000;
154
+ --z-index-backdrop: 2000;
161
155
  }
162
156
 
163
157
  /**
@@ -185,7 +179,7 @@
185
179
  --preloader-color: var(--c-black);
186
180
  }
187
181
 
188
- .dark-mode {
182
+ .dark {
189
183
  --preloader-color: var(--c-white);
190
184
  }
191
185
 
@@ -239,7 +233,7 @@
239
233
  --button-mute-inverse-bg-focus: var(--c-gray-dark-2);
240
234
  }
241
235
 
242
- .dark-mode {
236
+ .dark {
243
237
  --button-primary-text: var(--c-text-inverse-1);
244
238
  --button-primary-bg: var(--c-white);
245
239
  --button-primary-bg-hover: var(--c-gray-light-3);
@@ -293,51 +287,24 @@
293
287
  --input-note: var(--c-text-2);
294
288
  --input-text: var(--c-text-1);
295
289
  --input-placeholder: var(--c-text-3);
290
+ --input-help: var(--c-text-2);
296
291
 
297
- --input-filled-bg: var(--c-bg-mute);
298
- --input-filled-bg-focus: var(--c-bg);
299
- --input-filled-bg-disabled: var(--c-gray-light-4);
300
-
301
- --input-outlined-bg-disabled: var(--c-white-mute);
302
- --input-outlined-border: var(--c-divider);
303
- --input-outlined-border-focus: var(--c-black);
292
+ --input-border: var(--c-divider);
304
293
 
305
- --input-clear-bg-disabled: var(--c-white);
294
+ --input-hover-border: var(--c-black);
306
295
 
307
296
  --input-focus-border: var(--c-black);
308
297
  --input-focus-bg: var(--c-white);
309
298
 
310
- --input-help: var(--c-text-2);
311
-
312
- --input-action-filled-bg: var(--c-white-mute);
313
- --input-action-filled-bg-hover: var(--c-gray-light-4);
314
- --input-action-filled-bg-focus: var(--c-gray-light-3);
315
-
316
- --input-action-outlined-bg: var(--c-white-mute);
317
- --input-action-outlined-border: var(--c-divider);
318
- --input-action-outlined-bg-hover: var(--c-gray-light-4);
319
- --input-action-outlined-bg-focus: var(--c-gray-light-3);
299
+ --input-disabled-bg: var(--c-white-mute);
320
300
  }
321
301
 
322
- .dark-mode {
323
- --input-outlined-bg-disabled: var(--c-black-mute);
324
- --input-outlined-border-focus: var(--c-gray);
302
+ .dark {
303
+ --input-hover-border: var(--c-gray);
325
304
 
326
305
  --input-focus-border: var(--c-gray);
327
- }
328
306
 
329
- /**
330
- * Component: Card
331
- * -------------------------------------------------------------------------- */
332
-
333
- :root {
334
- --card-bg: var(--c-white);
335
- --card-bg-mute: var(--c-white-soft);
336
- --card-shadow-depth-1: var(--shadow-depth-1);
337
- --card-shadow-depth-2: var(--shadow-depth-2);
338
- --card-shadow-depth-3: var(--shadow-depth-3);
339
- --card-shadow-depth-4: var(--shadow-depth-4);
340
- --card-shadow-depth-5: var(--shadow-depth-5);
307
+ --input-disabled-bg: var(--c-black-mute);
341
308
  }
342
309
 
343
310
  /**
@@ -348,6 +315,6 @@
348
315
  --dropdown-item-hover-bg: var(--c-white-soft);
349
316
  }
350
317
 
351
- .dark-mode {
318
+ .dark {
352
319
  --dropdown-item-hover-bg: var(--c-black);
353
320
  }
@@ -5,29 +5,20 @@
5
5
  </div>
6
6
  </template>
7
7
 
8
- <script lang="ts">
9
- import { PropType, defineComponent, computed } from '@vue/composition-api'
8
+ <script setup lang="ts">
9
+ import { PropType, computed } from 'vue'
10
10
 
11
11
  type Size = 'nano' | 'mini' | 'small' | 'medium' | 'large'
12
12
 
13
- export default defineComponent({
14
- props: {
15
- size: { type: String as PropType<Size>, default: 'medium' },
16
- avatar: { type: String, required: true },
17
- name: { type: String, default: '' }
18
- },
19
-
20
- setup(props) {
21
- const classes = computed(() => [props.size])
13
+ const props = defineProps({
14
+ size: { type: String as PropType<Size>, default: 'medium' },
15
+ avatar: { type: String, required: true },
16
+ name: { type: String, default: '' }
17
+ })
22
18
 
23
- const initial = computed(() => props.name.charAt(0).toUpperCase())
19
+ const classes = computed(() => [props.size])
24
20
 
25
- return {
26
- classes,
27
- initial
28
- }
29
- }
30
- })
21
+ const initial = computed(() => props.name.charAt(0).toUpperCase())
31
22
  </script>
32
23
 
33
24
  <style lang="postcss" scoped>
@@ -20,61 +20,48 @@
20
20
  </component>
21
21
  </template>
22
22
 
23
- <script lang="ts">
24
- import { PropType, defineComponent, computed } from '@vue/composition-api'
23
+ <script setup lang="ts">
24
+ import { PropType, computed } from 'vue'
25
25
  import SIconPreloader from './icons/SIconPreloader.vue'
26
26
 
27
27
  type Size = 'mini' | 'small' | 'medium' | 'large' | 'jumbo'
28
28
 
29
- export default defineComponent({
30
- components: {
31
- SIconPreloader
32
- },
33
-
34
- props: {
35
- label: { type: String, default: null },
36
- tag: { type: String, default: 'button' },
37
- to: { type: String, default: '/' },
38
- type: { type: String, default: 'primary' },
39
- mode: { type: String, default: 'neutral' },
40
- size: { type: String as PropType<Size>, default: 'medium' },
41
- rounded: { type: Boolean, default: false },
42
- icon: { type: Object, default: null },
43
- block: { type: Boolean, default: false },
44
- inverse: { type: Boolean, default: false },
45
- loading: { type: Boolean, default: false },
46
- disabled: { type: Boolean, default: false }
47
- },
48
-
49
- setup(props, { emit }) {
50
- const classes = computed(() => [
51
- props.type,
52
- props.mode,
53
- props.size,
54
- { rounded: props.rounded },
55
- { block: props.block },
56
- { inverse: props.inverse },
57
- { 'has-label': props.label },
58
- { 'has-icon': props.icon },
59
- { loading: props.loading },
60
- { disabled: props.disabled }
61
- ])
62
-
63
- function handleClick(): void {
64
- !props.disabled && emit('click')
65
- }
66
-
67
- return {
68
- classes,
69
- handleClick
70
- }
71
- }
29
+ const props = defineProps({
30
+ label: { type: String, default: null },
31
+ tag: { type: String, default: 'button' },
32
+ to: { type: String, default: '/' },
33
+ type: { type: String, default: 'primary' },
34
+ mode: { type: String, default: 'neutral' },
35
+ size: { type: String as PropType<Size>, default: 'medium' },
36
+ rounded: { type: Boolean, default: false },
37
+ icon: { type: Object, default: null },
38
+ block: { type: Boolean, default: false },
39
+ inverse: { type: Boolean, default: false },
40
+ loading: { type: Boolean, default: false },
41
+ disabled: { type: Boolean, default: false }
72
42
  })
43
+
44
+ const emit = defineEmits(['click'])
45
+
46
+ const classes = computed(() => [
47
+ props.type,
48
+ props.mode,
49
+ props.size,
50
+ { rounded: props.rounded },
51
+ { block: props.block },
52
+ { inverse: props.inverse },
53
+ { 'has-label': props.label },
54
+ { 'has-icon': props.icon },
55
+ { loading: props.loading },
56
+ { disabled: props.disabled }
57
+ ])
58
+
59
+ function handleClick(): void {
60
+ !props.disabled && emit('click')
61
+ }
73
62
  </script>
74
63
 
75
64
  <style lang="postcss" scoped>
76
- @import "@/assets/styles/variables";
77
-
78
65
  .SButton {
79
66
  position: relative;
80
67
  display: inline-block;
@@ -196,7 +183,7 @@ export default defineComponent({
196
183
  }
197
184
  }
198
185
 
199
- & .loader-icon >>> .bar {
186
+ & .loader-icon :deep(.bar) {
200
187
  fill: var(--c-text-inverse-1);
201
188
  }
202
189
  }
@@ -22,53 +22,35 @@
22
22
  </div>
23
23
  </template>
24
24
 
25
- <script lang="ts">
26
- import { PropType, defineComponent, computed } from '@vue/composition-api'
27
- import { DialogType } from '../composables/Dialog'
25
+ <script setup lang="ts">
26
+ import { PropType, computed } from 'vue'
27
+ import { Action } from '../store/dialog'
28
28
  import SIconPreloader from './icons/SIconPreloader.vue'
29
29
  import SButton from './SButton.vue'
30
30
 
31
- export default defineComponent({
32
- components: {
33
- SIconPreloader,
34
- SButton
35
- },
36
-
37
- props: {
38
- type: { type: String as PropType<DialogType>, default: 'confirm' },
39
- title: { type: String, default: null },
40
- text: { type: String, default: null },
41
- progress: { type: Object, default: () => ({}) },
42
- actions: { type: Array, default: () => [] }
43
- },
44
-
45
- setup(props) {
46
- const isTypeLoading = computed(() => props.type === 'loading')
47
- const isLoadOnly = computed(() => isTypeLoading.value && !props.title && !props.text)
48
-
49
- function getActionType(value?: 'text' | 'mute'): 'text' | 'mute' {
50
- return value !== 'mute' ? 'text' : 'mute'
51
- }
52
-
53
- return {
54
- isTypeLoading,
55
- isLoadOnly,
56
- getActionType
57
- }
58
- }
31
+ const props = defineProps({
32
+ type: { type: String as PropType<'confirm' | 'loading'>, default: 'confirm' },
33
+ title: { type: String, default: null },
34
+ text: { type: String, default: null },
35
+ actions: { type: Array as PropType<Action[]>, default: () => [] }
59
36
  })
37
+
38
+ const isTypeLoading = computed(() => props.type === 'loading')
39
+ const isLoadOnly = computed(() => isTypeLoading.value && !props.title && !props.text)
40
+
41
+ function getActionType(value?: 'text' | 'mute'): 'text' | 'mute' {
42
+ return value !== 'mute' ? 'text' : 'mute'
43
+ }
60
44
  </script>
61
45
 
62
46
  <style lang="postcss" scoped>
63
- @import "@/assets/styles/variables";
64
-
65
47
  .SDialog {
66
48
  margin: 96px 16px;
67
49
  border: 1px solid var(--c-divider-light);
68
50
  border-radius: 8px;
69
51
  padding: 16px 16px 8px;
70
52
  max-width: 392px;
71
- background-color: var(--modal-content-bg);
53
+ background-color: var(--c-bg);
72
54
  box-shadow: var(--shadow-depth-3);
73
55
 
74
56
  @media (min-width: 424px) {
@@ -12,10 +12,8 @@
12
12
  size="mini"
13
13
  mode="outlined"
14
14
  :placeholder="options.search.placeholder"
15
- :value="options.search.value.value"
16
- @input="v => options.search.onInput(v)"
17
- @down="focusFirstItem"
18
- @escape="$emit('close')"
15
+ :model-value="options.search.value.value"
16
+ @update:model-value="v => options.search?.onInput(v)"
19
17
  />
20
18
  </div>
21
19
 
@@ -38,69 +36,52 @@
38
36
  </li>
39
37
  </ul>
40
38
 
41
- <p v-else class="item-missing">{{ options.search.missing }}</p>
39
+ <p v-else class="item-missing">{{ options.search?.missing }}</p>
42
40
  </div>
43
41
  </div>
44
42
  </template>
45
43
 
46
- <script lang="ts">
47
- import { PropType, defineComponent } from '@vue/composition-api'
44
+ <script setup lang="ts">
45
+ import { PropType } from 'vue'
48
46
  import { Dropdown, Item } from '../composables/Dropdown'
49
47
  import SIconX from './icons/SIconX.vue'
50
48
  import SInputText from './SInputText.vue'
51
49
  import SDropdownItem from './SDropdownItem.vue'
52
50
 
53
- export default defineComponent({
54
- components: {
55
- SIconX,
56
- SInputText,
57
- SDropdownItem
58
- },
59
-
60
- props: {
61
- round: { type: Number, default: 8 },
62
- options: { type: Object as PropType<Dropdown>, required: true }
63
- },
64
-
65
- setup(props, { emit }) {
66
- function focusFirstItem(): void {
67
- const el = document.querySelector('.SDropdown .item:first-child') as HTMLElement | null
68
- el?.focus?.()
69
- }
70
-
71
- function focusPrev(event: any): void {
72
- event.target.previousSibling?.focus()
73
- }
74
-
75
- function focusNext(event: any): void {
76
- event.target.nextSibling?.focus()
77
- }
78
-
79
- function onClick(item: Item): void {
80
- if (item.callback) {
81
- item.callback()
82
- } else if (props.options.callback) {
83
- props.options.callback(item)
84
- }
85
-
86
- if (props.options.closeOnClick) {
87
- emit('close')
88
- }
89
- }
90
-
91
- return {
92
- focusFirstItem,
93
- focusPrev,
94
- focusNext,
95
- onClick
96
- }
97
- }
51
+ const props = defineProps({
52
+ round: { type: Number, default: 8 },
53
+ options: { type: Object as PropType<Dropdown>, required: true }
98
54
  })
55
+
56
+ const emit = defineEmits(['close'])
57
+
58
+ function focusFirstItem(): void {
59
+ const el = document.querySelector('.SDropdown .item:first-child') as HTMLElement | null
60
+ el?.focus?.()
61
+ }
62
+
63
+ function focusPrev(event: any): void {
64
+ event.target.previousSibling?.focus()
65
+ }
66
+
67
+ function focusNext(event: any): void {
68
+ event.target.nextSibling?.focus()
69
+ }
70
+
71
+ function onClick(item: Item): void {
72
+ if (item.callback) {
73
+ item.callback()
74
+ } else if (props.options.callback) {
75
+ props.options.callback(item)
76
+ }
77
+
78
+ if (props.options.closeOnClick) {
79
+ emit('close')
80
+ }
81
+ }
99
82
  </script>
100
83
 
101
84
  <style lang="postcss" scoped>
102
- @import "@/assets/styles/variables";
103
-
104
85
  .SDropdown {
105
86
  display: inline-block;
106
87
  overflow: hidden;
@@ -112,7 +93,7 @@ export default defineComponent({
112
93
  transition: background-color .25s;
113
94
  }
114
95
 
115
- .dark-mode .SDropdown {
96
+ .dark .SDropdown {
116
97
  background-color: var(--c-black-soft);
117
98
  }
118
99
 
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <li class="SDropdownItem" role="button" @click="$emit('click')">
3
- <div class="content">
3
+ <div v-if="item" class="content">
4
4
  <component :is="component" :item="item" />
5
5
  </div>
6
6
 
@@ -10,55 +10,43 @@
10
10
  </li>
11
11
  </template>
12
12
 
13
- <script lang="ts">
14
- import { ComputedRef, PropType, defineComponent, computed } from '@vue/composition-api'
15
- import { isArray, isEqual } from '../support/Util'
16
- import { Item } from '../composables/Dropdown'
13
+ <script setup lang="ts">
14
+ import { ComputedRef, PropType, computed } from 'vue'
15
+ import { isArray, isEqual } from '../support/Utils'
17
16
  import SIconCheck from './icons/SIconCheck.vue'
18
17
  import SDropdownItemText from './SDropdownItemText.vue'
19
18
  import SDropdownItemUser from './SDropdownItemUser.vue'
20
19
 
21
- export default defineComponent({
22
- components: {
23
- SIconCheck
24
- },
25
-
26
- props: {
27
- selected: { type: Object as PropType<ComputedRef<any>>, default: null },
28
- item: { type: Object as PropType<Item>, required: true }
29
- },
20
+ const props = defineProps({
21
+ selected: { type: Object as PropType<ComputedRef<any>>, default: null },
22
+ item: { type: Object as PropType<any>, default: null }
23
+ })
30
24
 
31
- setup(props) {
32
- const component = computed(() => {
33
- if (props.item.type === 'text') {
34
- return SDropdownItemText
35
- }
25
+ defineEmits(['click'])
36
26
 
37
- if (props.item.type === 'user') {
38
- return SDropdownItemUser
39
- }
27
+ const component = computed(() => {
28
+ if (props.item.type === 'text') {
29
+ return SDropdownItemText
30
+ }
40
31
 
41
- throw new Error('Invalid item type.')
42
- })
32
+ if (props.item.type === 'user') {
33
+ return SDropdownItemUser
34
+ }
43
35
 
44
- const isActive = computed(() => {
45
- if (!props.selected) {
46
- return false
47
- }
36
+ throw new Error('Invalid item type.')
37
+ })
48
38
 
49
- const selected = props.selected.value
50
- const value = props.item.value
39
+ const isActive = computed(() => {
40
+ if (!props.selected) {
41
+ return false
42
+ }
51
43
 
52
- return isArray(selected)
53
- ? !!selected.find(s => isEqual(s, value))
54
- : isEqual(selected, value)
55
- })
44
+ const selected = props.selected.value
45
+ const value = props.item.value
56
46
 
57
- return {
58
- component,
59
- isActive
60
- }
61
- }
47
+ return isArray(selected)
48
+ ? !!selected.find(s => isEqual(s, value))
49
+ : isEqual(selected, value)
62
50
  })
63
51
  </script>
64
52
 
@@ -4,20 +4,15 @@
4
4
  </div>
5
5
  </template>
6
6
 
7
- <script lang="ts">
8
- import { PropType, defineComponent } from '@vue/composition-api'
9
- import { Item } from '../composables/Dropdown'
7
+ <script setup lang="ts">
8
+ import { PropType } from 'vue'
10
9
 
11
- export default defineComponent({
12
- props: {
13
- item: { type: Object as PropType<Item>, required: true }
14
- }
10
+ defineProps({
11
+ item: { type: Object as PropType<any>, required: true }
15
12
  })
16
13
  </script>
17
14
 
18
15
  <style lang="postcss" scoped>
19
- @import "@/assets/styles/variables";
20
-
21
16
  .text {
22
17
  margin: 0;
23
18
  line-height: 16px;
@@ -8,25 +8,17 @@
8
8
  </div>
9
9
  </template>
10
10
 
11
- <script lang="ts">
12
- import { PropType, defineComponent } from '@vue/composition-api'
11
+ <script setup lang="ts">
12
+ import { PropType } from 'vue'
13
13
  import { UserItem } from '../composables/Dropdown'
14
14
  import SAvatar from './SAvatar.vue'
15
15
 
16
- export default defineComponent({
17
- components: {
18
- SAvatar
19
- },
20
-
21
- props: {
22
- item: { type: Object as PropType<UserItem>, required: true }
23
- }
16
+ defineProps({
17
+ item: { type: Object as PropType<UserItem>, required: true }
24
18
  })
25
19
  </script>
26
20
 
27
21
  <style lang="postcss" scoped>
28
- @import "@/assets/styles/variables";
29
-
30
22
  .SDropdownItemUser {
31
23
  position: relative;
32
24
  }