@globalbrain/sefirot 0.70.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 -800
  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 +19 -35
  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 +23 -33
  24. package/lib/components/SInputRadios.vue +37 -47
  25. package/lib/components/SInputText.vue +59 -632
  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 +1 -3
  38. package/lib/components/SSheetMedium.vue +13 -25
  39. package/lib/components/SSnackbar.vue +18 -28
  40. package/lib/components/icons/SIconSend.vue +5 -0
  41. package/lib/composables/Dialog.ts +9 -17
  42. package/lib/composables/Dropdown.ts +1 -1
  43. package/lib/composables/{Menu.ts → Flyout.ts} +11 -4
  44. package/lib/composables/Form.ts +42 -44
  45. package/lib/composables/Modal.ts +9 -9
  46. package/lib/composables/Snackbar.ts +18 -0
  47. package/lib/composables/Validation.ts +28 -0
  48. package/lib/mixins/Sheet.ts +3 -3
  49. package/lib/store/Sefirot.ts +8 -13
  50. package/lib/store/dialog/index.ts +20 -10
  51. package/lib/store/modal/index.ts +11 -13
  52. package/lib/store/snackbars/index.ts +3 -4
  53. package/lib/support/{Util.ts → Utils.ts} +0 -2
  54. package/lib/types/Utils.ts +0 -7
  55. package/lib/types/vue-shims.d.ts +7 -0
  56. package/lib/validation/rules/checked.ts +6 -10
  57. package/lib/validation/rules/fileExtension.ts +9 -9
  58. package/lib/validation/rules/hms.ts +9 -9
  59. package/lib/validation/rules/index.ts +10 -74
  60. package/lib/validation/rules/maxLength.ts +10 -9
  61. package/lib/validation/rules/minLength.ts +12 -0
  62. package/lib/validation/rules/required.ts +2 -10
  63. package/lib/validation/rules/requiredHms.ts +11 -0
  64. package/lib/validation/rules/requiredIf.ts +3 -11
  65. package/lib/validation/rules/requiredYmd.ts +11 -0
  66. package/lib/validation/rules/ymd.ts +11 -0
  67. package/lib/validation/validators/checked.ts +1 -1
  68. package/lib/validation/validators/fileExtension.ts +1 -1
  69. package/lib/validation/validators/hms.ts +5 -5
  70. package/lib/validation/validators/requiredHms.ts +17 -0
  71. package/lib/validation/validators/requiredYmd.ts +7 -0
  72. package/lib/validation/validators/ymd.ts +41 -0
  73. package/package.json +45 -50
  74. package/lib/components/SAction.vue +0 -37
  75. package/lib/components/SActionAvatar.vue +0 -25
  76. package/lib/components/SActionButton.vue +0 -40
  77. package/lib/components/SActionPill.vue +0 -35
  78. package/lib/components/SActionSwitch.vue +0 -37
  79. package/lib/components/SAlert.vue +0 -145
  80. package/lib/components/SButtonGroup.vue +0 -160
  81. package/lib/components/SCard.vue +0 -111
  82. package/lib/components/SCardFooter.vue +0 -74
  83. package/lib/components/SCardHeader.vue +0 -213
  84. package/lib/components/SGrid.vue +0 -237
  85. package/lib/components/SGridActionLink.vue +0 -53
  86. package/lib/components/SGridActionMulti.vue +0 -139
  87. package/lib/components/SGridActionSingle.vue +0 -64
  88. package/lib/components/SHeader.vue +0 -180
  89. package/lib/components/SInputCheckboxes.vue +0 -83
  90. package/lib/components/SInputDate.vue +0 -192
  91. package/lib/components/SInputDay.vue +0 -87
  92. package/lib/components/SInputMonth.vue +0 -86
  93. package/lib/components/SInputSelect.vue +0 -282
  94. package/lib/components/SInputSwitch.vue +0 -212
  95. package/lib/components/SInputSwitches.vue +0 -108
  96. package/lib/components/SInputTime.vue +0 -255
  97. package/lib/components/SInputYear.vue +0 -60
  98. package/lib/components/SMarkdown.vue +0 -56
  99. package/lib/components/SPlaceholderBlank.vue +0 -113
  100. package/lib/components/SPlaceholderImage.vue +0 -83
  101. package/lib/components/SPortalScreens.vue +0 -62
  102. package/lib/components/SProgressBar.vue +0 -89
  103. package/lib/components/SResponsive.vue +0 -46
  104. package/lib/components/SScreen.vue +0 -81
  105. package/lib/components/SStep.vue +0 -107
  106. package/lib/components/SSteps.vue +0 -75
  107. package/lib/components/STag.vue +0 -67
  108. package/lib/components/STooltip.vue +0 -134
  109. package/lib/components/SWindow.vue +0 -158
  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
@@ -1,282 +0,0 @@
1
- <template>
2
- <SInputBase
3
- class="SInputSelect"
4
- :class="classes"
5
- :name="name"
6
- :label="label"
7
- :note="note"
8
- :help="help"
9
- :validation="validation"
10
- :error-message="errorMessage"
11
- >
12
- <div class="box" :class="{ focus: isFocused }">
13
- <select
14
- :id="name"
15
- class="select"
16
- :class="{ 'is-not-selected': isNotSelected }"
17
- :disabled="disabled"
18
- @focus="focus"
19
- @blur="blur"
20
- @change="emitChange"
21
- >
22
- <option
23
- v-if="placeholder"
24
- value=""
25
- :selected="isNotSelected"
26
- disabled
27
- >
28
- {{ placeholder }}
29
- </option>
30
-
31
- <option
32
- v-for="option in options"
33
- :key="option.value"
34
- :style="{ display: option.disabled ? 'none' : null }"
35
- :value="JSON.stringify(option)"
36
- :selected="isSelectedOption(option)"
37
- >
38
- {{ option.label }}
39
- </option>
40
- </select>
41
-
42
- <div class="icon" role="button">
43
- <SIconChevronUp class="icon-svg up" />
44
- <SIconChevronDown class="icon-svg down" />
45
- </div>
46
- </div>
47
- </SInputBase>
48
- </template>
49
-
50
- <script lang="ts">
51
- import { PropType, defineComponent, ref, computed } from '@vue/composition-api'
52
- import { SyntheticInputEvent } from '../types/Utils'
53
- import SIconChevronUp from './icons/SIconChevronUp.vue'
54
- import SIconChevronDown from './icons/SIconChevronDown.vue'
55
- import SInputBase from './SInputBase.vue'
56
-
57
- type Size = 'medium' | 'mini'
58
- type Mode = 'filled' | 'outlined'
59
-
60
- interface Option {
61
- label: string
62
- value: boolean | number | string
63
- disabled?: boolean
64
- }
65
-
66
- export default defineComponent({
67
- components: {
68
- SIconChevronUp,
69
- SIconChevronDown,
70
- SInputBase
71
- },
72
-
73
- model: {
74
- prop: 'value',
75
- event: 'change'
76
- },
77
-
78
- props: {
79
- size: { type: String as PropType<Size>, default: 'medium' },
80
- mode: { type: String as PropType<Mode>, default: 'filled' },
81
- name: { type: String, default: null },
82
- label: { type: String, default: null },
83
- note: { type: String, default: null },
84
- help: { type: String, default: null },
85
- placeholder: { type: String, default: null },
86
- disabled: { type: Boolean, default: false },
87
- errorMessage: { type: Boolean, default: true },
88
- options: { type: Array as PropType<Option[]>, required: true },
89
- validation: { type: Object, default: null },
90
- value: { type: [String, Number, Boolean], default: null }
91
- },
92
-
93
- setup(props, { emit }) {
94
- const isFocused = ref(false)
95
-
96
- const classes = computed(() => ({
97
- medium: props.size === 'medium',
98
- mini: props.size === 'mini',
99
- filled: props.mode === 'filled',
100
- outlined: props.mode === 'outlined',
101
- disabled: props.disabled
102
- }))
103
-
104
- const isNotSelected = computed(() => {
105
- return props.value === undefined || props.value === null || props.value === ''
106
- })
107
-
108
- function isSelectedOption(option: Option): boolean {
109
- return option.value === props.value
110
- }
111
-
112
- function focus() {
113
- isFocused.value = true
114
- }
115
-
116
- function blur() {
117
- isFocused.value = false
118
- }
119
-
120
- function emitChange(e: SyntheticInputEvent): void {
121
- props.validation && props.validation.$touch()
122
-
123
- const option = JSON.parse(e.target.value)
124
-
125
- emit('change', option.value)
126
- }
127
-
128
- return {
129
- isFocused,
130
- classes,
131
- isNotSelected,
132
- isSelectedOption,
133
- focus,
134
- blur,
135
- emitChange
136
- }
137
- }
138
- })
139
- </script>
140
-
141
- <style lang="postcss" scoped>
142
- @import "@/assets/styles/variables";
143
-
144
- .SInputSelect.mini {
145
- .box {
146
- height: 32px;
147
- }
148
-
149
- .select {
150
- padding: 3px 30px 3px 12px;
151
- line-height: 24px;
152
- font-size: 14px;
153
- }
154
-
155
- .icon {
156
- top: 3px;
157
- right: 8px;
158
- }
159
- }
160
-
161
- .SInputSelect.medium {
162
- .box {
163
- height: 48px;
164
- }
165
-
166
- .select {
167
- padding: 11px 44px 11px 16px;
168
- line-height: 24px;
169
- font-size: 16px;
170
- }
171
-
172
- .icon {
173
- top: 11px;
174
- right: 12px;
175
- }
176
- }
177
-
178
- .SInputSelect.filled {
179
- .box {
180
- background-color: var(--input-filled-bg);
181
-
182
- &:hover,
183
- &.focus {
184
- border-color: var(--input-focus-border);
185
- }
186
- }
187
-
188
- &.disabled .box:hover {
189
- border-color: transparent;
190
- }
191
-
192
- &.disabled .select {
193
- background-color: var(--input-filled-bg-disabled);
194
- opacity: 1;
195
- }
196
- }
197
-
198
- .SInputSelect.outlined {
199
- &.has-error {
200
- .box {
201
- border-color: var(--c-danger);
202
- }
203
- }
204
-
205
- .box {
206
- border-color: var(--input-outlined-border);
207
-
208
- &:hover,
209
- &.focus {
210
- border-color: var(--input-focus-border);
211
- }
212
-
213
- &:focus:not(:focus-visible) {
214
- border-color: var(--input-focus-border);
215
- outline: 0;
216
- }
217
- }
218
-
219
- &.disabled .box:hover {
220
- border-color: var(--input-outlined-border);
221
- }
222
-
223
- &.disabled .select {
224
- background-color: var(--input-outlined-bg-disabled);
225
- opacity: 1;
226
- }
227
- }
228
-
229
- .SInputSelect.disabled {
230
- .box:hover .select {
231
- cursor: not-allowed;
232
- }
233
- }
234
-
235
- .SInputSelect.has-error {
236
- .select {
237
- border-color: var(--c-danger);
238
- }
239
- }
240
-
241
- .box {
242
- position: relative;
243
- border: 1px solid transparent;
244
- border-radius: 4px;
245
- width: 100%;
246
- color: var(--input-text);
247
- cursor: pointer;
248
- transition: border-color .25s, background-color .25s;
249
- }
250
-
251
- .select {
252
- position: relative;
253
- z-index: 20;
254
- display: block;
255
- border: 0;
256
- border-radius: 4px;
257
- width: 100%;
258
- background-color: transparent;
259
- cursor: pointer;
260
-
261
- &.select.is-not-selected {
262
- color: var(--input-placeholder);
263
- }
264
- }
265
-
266
- .icon {
267
- position: absolute;
268
- z-index: 10;
269
- cursor: pointer;
270
- }
271
-
272
- .icon-svg {
273
- display: block;
274
- width: 14px;
275
- height: 14px;
276
- fill: var(--input-placeholder);
277
- }
278
-
279
- .icon-svg.up {
280
- margin-bottom: -4px;
281
- }
282
- </style>
@@ -1,212 +0,0 @@
1
- <template>
2
- <SInputBase
3
- class="SInputSwitch"
4
- :class="classes"
5
- :name="name"
6
- :label="label"
7
- :note="note"
8
- :help="help"
9
- >
10
- <div class="SInputSwitch-container">
11
- <div class="SInputSwitch-input" :class="{ on: value }" role="button" @click="emitChange">
12
- <p v-if="text" class="SInputSwitch-text" :class="[textMode]">{{ text }}</p>
13
-
14
- <div class="SInputSwitch-box">
15
- <div class="SInputSwitch-check" />
16
- </div>
17
-
18
- <p v-if="textAfter" class="SInputSwitch-text after" :class="[textMode]">{{ textAfter }}</p>
19
- </div>
20
- </div>
21
- </SInputBase>
22
- </template>
23
-
24
- <script lang="ts">
25
- import { PropType, defineComponent, computed } from '@vue/composition-api'
26
- import SInputBase from './SInputBase.vue'
27
-
28
- type Size = 'mini' | 'small'
29
- type Mode = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
30
- type TextMode = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
31
-
32
- export default defineComponent({
33
- components: {
34
- SInputBase
35
- },
36
-
37
- model: {
38
- prop: 'value',
39
- event: 'change'
40
- },
41
-
42
- props: {
43
- size: { type: String as PropType<Size>, default: 'small' },
44
- mode: { type: String as PropType<Mode>, default: 'neutral' },
45
- name: { type: String, default: null },
46
- label: { type: String, default: null },
47
- note: { type: String, default: null },
48
- text: { type: String, default: null },
49
- textAfter: { type: String, default: null },
50
- textMode: { type: String as PropType<TextMode>, default: 'neutral' },
51
- disabled: { type: Boolean, default: false },
52
- help: { type: String, default: null },
53
- value: { type: Boolean, required: true }
54
- },
55
-
56
- setup(props, { emit }) {
57
- const classes = computed(() => ({
58
- mini: props.size === 'mini',
59
- small: props.size === 'small',
60
- neutral: props.mode === 'neutral',
61
- info: props.mode === 'info',
62
- success: props.mode === 'success',
63
- warning: props.mode === 'warning',
64
- danger: props.mode === 'danger',
65
- disabled: props.disabled
66
- }))
67
-
68
- function emitChange(): void {
69
- !props.disabled && emit('change', !props.value)
70
- }
71
-
72
- return {
73
- classes,
74
- emitChange
75
- }
76
- }
77
- })
78
- </script>
79
-
80
- <style lang="postcss" scoped>
81
- @import "@/assets/styles/variables";
82
-
83
- .SInputSwitch.mini {
84
- .SInputSwitch-box {
85
- margin: 1px 0 0;
86
- border-radius: 9px;
87
- width: 36px;
88
- height: 18px;
89
- }
90
-
91
- .SInputSwitch-check {
92
- top: 2px;
93
- left: 2px;
94
- width: 12px;
95
- height: 12px;
96
- transition: background-color .25s, transform .25s;
97
- }
98
- }
99
-
100
- .SInputSwitch.small {
101
- .SInputSwitch-box {
102
- margin: -1px 0 -1px;
103
- border-radius: 11px;
104
- width: 40px;
105
- height: 22px;
106
- }
107
-
108
- .SInputSwitch-check {
109
- top: 2px;
110
- left: 2px;
111
- width: 16px;
112
- height: 16px;
113
- transition: background-color .25s, transform .25s;
114
- }
115
- }
116
-
117
- .SInputSwitch.neutral .SInputSwitch-input.on .SInputSwitch-box {
118
- border-color: var(--c-black);
119
- background-color: var(--c-black);
120
- }
121
-
122
- .SInputSwitch.info .SInputSwitch-input.on .SInputSwitch-box {
123
- border-color: var(--c-info);
124
- background-color: var(--c-info);
125
- }
126
-
127
- .SInputSwitch.success .SInputSwitch-input.on .SInputSwitch-box {
128
- border-color: var(--c-success);
129
- background-color: var(--c-success);
130
- }
131
-
132
- .SInputSwitch.warning .SInputSwitch-input.on .SInputSwitch-box {
133
- border-color: var(--c-warning);
134
- background-color: var(--c-warning);
135
- }
136
-
137
- .SInputSwitch.danger .SInputSwitch-input.on .SInputSwitch-box {
138
- border-color: var(--c-danger);
139
- background-color: var(--c-danger);
140
- }
141
-
142
- .SInputSwitch.disabled .SInputSwitch-input {
143
- .SInputSwitch-box {
144
- cursor: not-allowed;
145
- opacity: .6;
146
- }
147
-
148
- &:hover .SInputSwitch-box { border-color: var(--c-gray); }
149
- }
150
-
151
- .SInputSwitch.disabled .SInputSwitch-input.on {
152
- &:hover .SInputSwitch-box { border-color: transparent; }
153
- }
154
-
155
- .SInputSwitch-container {
156
- display: flex;
157
- }
158
-
159
- .SInputSwitch-input {
160
- position: relative;
161
- display: flex;
162
- justify-content: space-between;
163
- width: 100%;
164
-
165
- &:hover {
166
- .SInputSwitch-box { border-color: var(--c-black); }
167
- .SInputSwitch-check { background-color: var(--c-black); }
168
- }
169
- }
170
-
171
- .SInputSwitch-input.on .SInputSwitch-check {
172
- background-color: var(--c-white);
173
- transform: translateX(18px);
174
- }
175
-
176
- .SInputSwitch-text {
177
- flex-grow: 1;
178
- margin: 0;
179
- padding-right: 16px;
180
- line-height: 20px;
181
- font-size: 14px;
182
- }
183
-
184
- .SInputSwitch-text.mute {
185
- color: var(--c-text-light-2);
186
- font-weight: 500;
187
- }
188
-
189
- .SInputSwitch-text.info { color: var(--c-info); }
190
- .SInputSwitch-text.success { color: var(--c-success); }
191
- .SInputSwitch-text.warning { color: var(--c-warning); }
192
- .SInputSwitch-text.danger { color: var(--c-danger); }
193
-
194
- .SInputSwitch-text.after {
195
- padding-left: 12px;
196
- }
197
-
198
- .SInputSwitch-box {
199
- position: relative;
200
- flex-shrink: 0;
201
- border: 1px solid var(--c-gray);
202
- background-color: var(--c-white-mute);
203
- transition: border-color .25s, background-color .25s, box-shadow .25s;
204
- }
205
-
206
- .SInputSwitch-check {
207
- position: absolute;
208
- border-radius: 50%;
209
- background-color: var(--c-black);
210
- transition: background-color .25s, transform .25s;
211
- }
212
- </style>
@@ -1,108 +0,0 @@
1
- <template>
2
- <SInputBase
3
- class="SInputSwitches"
4
- :class="classes"
5
- :name="name"
6
- :label="label"
7
- :note="note"
8
- :help="help"
9
- >
10
- <div class="SInputSwitches-container">
11
- <div class="SInputSwitches-row">
12
- <div v-for="option in options" :key="option.value" class="SInputSwitches-col">
13
- <SInputSwitch
14
- :size="size"
15
- :mode="mode"
16
- :text="option.label"
17
- :value="isChecked(option.value)"
18
- @change="handleChange(option.value)"
19
- />
20
- </div>
21
- </div>
22
- </div>
23
- </SInputBase>
24
- </template>
25
-
26
- <script lang="ts">
27
- import { PropType, defineComponent, computed } from '@vue/composition-api'
28
- import SInputBase from './SInputBase.vue'
29
- import SInputSwitch from './SInputSwitch.vue'
30
-
31
- type Size = 'mini' | 'small'
32
- type Mode = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
33
-
34
- interface Option {
35
- label: string
36
- value: unknown
37
- }
38
-
39
- export default defineComponent({
40
- components: {
41
- SInputBase,
42
- SInputSwitch
43
- },
44
-
45
- model: {
46
- prop: 'value',
47
- event: 'change'
48
- },
49
-
50
- props: {
51
- size: { type: String as PropType<Size>, default: 'small' },
52
- mode: { type: String as PropType<Mode>, default: 'neutral' },
53
- name: { type: String, default: null },
54
- label: { type: String, default: null },
55
- note: { type: String, default: null },
56
- help: { type: String, default: null },
57
- options: { type: Array as PropType<Option[]>, required: true },
58
- value: { type: Array as PropType<unknown[]>, required: true }
59
- },
60
-
61
- setup(props, { emit }) {
62
- const classes = computed(() => [
63
- props.size,
64
- props.mode
65
- ])
66
-
67
- function isChecked(value: unknown): boolean {
68
- return props.value.includes(value)
69
- }
70
-
71
- function handleChange(value: unknown): void {
72
- const difference = props.value
73
- .filter(v => v !== value)
74
- .concat(props.value.includes(value) ? [] : [value])
75
-
76
- emit('change', difference)
77
- }
78
-
79
- return {
80
- classes,
81
- isChecked,
82
- handleChange
83
- }
84
- }
85
- })
86
- </script>
87
-
88
- <style lang="postcss" scoped>
89
- @import "@/assets/styles/variables";
90
-
91
- .SInputSwitches.mini {
92
- .SInputSwitches-row { margin: -2px -8px; }
93
- .SInputSwitches-col { padding: 2px 8px; }
94
- }
95
-
96
- .SInputSwitches.small {
97
- .SInputSwitches-row { margin: -4px -8px; }
98
- .SInputSwitches-col { padding: 4px 8px; }
99
- }
100
-
101
- .SInputSwitches-container {
102
- display: flex;
103
- }
104
-
105
- .SInputSwitches-row {
106
- width: 100%;
107
- }
108
- </style>