@globalbrain/sefirot 2.16.0 → 2.18.0

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.
@@ -88,21 +88,19 @@ function getErrorMsg(validation: Validatable) {
88
88
 
89
89
  <style scoped lang="postcss">
90
90
  .SInputBase.mini {
91
- .label { padding-bottom: 6px; }
92
- .label-text-value { font-size: 12px; }
91
+ .label { padding-bottom: 6px; height: 22px; }
92
+ .label-text-value { font-size: var(--input-label-font-size, var(--input-mini-label-font-size)); }
93
93
  .label-text-info { width: 14px; height: 14px; }
94
94
  }
95
95
 
96
96
  .SInputBase.small {
97
- .label { padding-bottom: 8px; }
98
- .label-text-value { font-size: 14px; }
99
- .label-note, .check { transform: translateY(1px); }
97
+ .label { padding-bottom: 8px; height: 24px; }
98
+ .label-text-value { font-size: var(--input-label-font-size, var(--input-small-label-font-size)); }
100
99
  }
101
100
 
102
101
  .SInputBase.medium {
103
- .label { padding-bottom: 8px; }
104
- .label-text-value { font-size: 14px; }
105
- .label-note, .check { transform: translateY(1px); }
102
+ .label { padding-bottom: 8px; height: 24px; }
103
+ .label-text-value { font-size: var(--input-label-font-size, var(--input-medium-label-font-size)); }
106
104
  }
107
105
 
108
106
  .SInputBase.has-error {
@@ -113,7 +111,7 @@ function getErrorMsg(validation: Validatable) {
113
111
 
114
112
  .label {
115
113
  display: flex;
116
- align-items: center;
114
+ align-items: baseline;
117
115
  width: 100%;
118
116
  line-height: 16px;
119
117
  font-weight: 500;
@@ -17,6 +17,7 @@ const props = defineProps<{
17
17
  checkIcon?: IconifyIcon | DefineComponent
18
18
  checkText?: string
19
19
  checkColor?: Color
20
+ block?: boolean
20
21
  modelValue: Day | null
21
22
  validation?: Validatable
22
23
  hideError?: boolean
@@ -71,6 +72,7 @@ function emitBlur() {
71
72
  <input
72
73
  :id="name"
73
74
  class="input"
75
+ :class="{ block }"
74
76
  type="text"
75
77
  placeholder="YYYY-MM-DD"
76
78
  :value="inputValue"
@@ -113,5 +115,9 @@ function emitBlur() {
113
115
  font-weight: 500;
114
116
  color: var(--c-text-3);
115
117
  }
118
+
119
+ &.block {
120
+ max-width: none;
121
+ }
116
122
  }
117
123
  </style>
@@ -2,12 +2,13 @@
2
2
  import { IconifyIcon } from '@iconify/vue/dist/offline'
3
3
  import { DefineComponent, computed } from 'vue'
4
4
  import { Validatable } from '../composables/Validation'
5
- import { isNullish } from '../support/Utils'
5
+ import { isNullish, isString } from '../support/Utils'
6
6
  import SInputText from './SInputText.vue'
7
7
 
8
8
  export type Size = 'mini' | 'small' | 'medium'
9
9
  export type Align = 'left' | 'center' | 'right'
10
- export type Color = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
10
+ export type CheckColor = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
11
+ export type TextColor = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
11
12
 
12
13
  const props = defineProps<{
13
14
  size?: Size
@@ -17,11 +18,12 @@ const props = defineProps<{
17
18
  note?: string
18
19
  help?: string
19
20
  placeholder?: string
20
- unitBefore?: string
21
- unitAfter?: string
21
+ unitBefore?: any
22
+ unitAfter?: any
22
23
  checkIcon?: IconifyIcon | DefineComponent
23
24
  checkText?: string
24
- checkColor?: Color
25
+ checkColor?: CheckColor
26
+ textColor?: TextColor | ((value: number | null) => TextColor)
25
27
  align?: Align
26
28
  separator?: boolean
27
29
  disabled?: boolean
@@ -43,6 +45,18 @@ const _value = computed(() => {
43
45
  : props.value !== undefined ? props.value : null
44
46
  })
45
47
 
48
+ const _textColor = computed(() => {
49
+ if (!props.textColor) {
50
+ return 'neutral'
51
+ }
52
+
53
+ if (isString(props.textColor)) {
54
+ return props.textColor
55
+ }
56
+
57
+ return props.textColor(_value.value)
58
+ })
59
+
46
60
  const valueWithSeparator = computed(() => {
47
61
  if (isNullish(_value.value)) {
48
62
  return null
@@ -86,6 +100,7 @@ function emitUpdate(value: string | null) {
86
100
  :check-icon="checkIcon"
87
101
  :check-text="checkText"
88
102
  :check-color="checkColor"
103
+ :text-color="_textColor"
89
104
  :align="align"
90
105
  :disabled="disabled"
91
106
  :hide-error="hideError"
@@ -2,12 +2,14 @@
2
2
  import { IconifyIcon } from '@iconify/vue/dist/offline'
3
3
  import { DefineComponent, computed, ref } from 'vue'
4
4
  import { Validatable } from '../composables/Validation'
5
+ import { isString } from '../support/Utils'
5
6
  import SIcon from './SIcon.vue'
6
7
  import SInputBase from './SInputBase.vue'
7
8
 
8
9
  export type Size = 'mini' | 'small' | 'medium'
9
10
  export type Align = 'left' | 'center' | 'right'
10
- export type Color = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
11
+ export type CheckColor = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
12
+ export type TextColor = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
11
13
 
12
14
  const props = defineProps<{
13
15
  size?: Size
@@ -18,12 +20,12 @@ const props = defineProps<{
18
20
  help?: string
19
21
  type?: string
20
22
  placeholder?: string
21
- unitBefore?: string
22
- unitAfter?: string
23
+ unitBefore?: any
24
+ unitAfter?: any
23
25
  checkIcon?: IconifyIcon | DefineComponent
24
26
  checkText?: string
25
- checkColor?: Color
26
- icon?: any
27
+ checkColor?: CheckColor
28
+ textColor?: TextColor | ((value: string | null) => TextColor)
27
29
  align?: Align
28
30
  disabled?: boolean
29
31
  modelValue: string | null
@@ -48,6 +50,23 @@ const classes = computed(() => [
48
50
  { disabled: props.disabled }
49
51
  ])
50
52
 
53
+ const inputClasses = computed(() => [
54
+ textColor.value,
55
+ { hide: showDisplay.value }
56
+ ])
57
+
58
+ const textColor = computed(() => {
59
+ if (!props.textColor) {
60
+ return 'neutral'
61
+ }
62
+
63
+ if (isString(props.textColor)) {
64
+ return props.textColor
65
+ }
66
+
67
+ return props.textColor(props.modelValue)
68
+ })
69
+
51
70
  const showDisplay = computed(() => {
52
71
  return !isFocused.value && props.displayValue
53
72
  })
@@ -113,19 +132,16 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
113
132
  <slot name="addon-before" />
114
133
  </div>
115
134
 
116
- <div v-if="icon" class="icon">
117
- <SIcon :icon="icon" class="icon-svg" />
118
- </div>
119
-
120
135
  <div class="value">
121
- <div v-if="props.unitBefore" class="unit before">
122
- {{ props.unitBefore }}
136
+ <div v-if="unitBefore" class="unit before">
137
+ <span v-if="isString(unitBefore)" class="unit-text">{{ unitBefore }}</span>
138
+ <SIcon v-else class="unit-icon" :icon="unitBefore" />
123
139
  </div>
124
140
 
125
141
  <div class="area">
126
142
  <input
127
143
  class="input entity"
128
- :class="{ hide: showDisplay }"
144
+ :class="inputClasses"
129
145
  :id="name"
130
146
  :type="type ?? 'text'"
131
147
  :placeholder="placeholder"
@@ -137,13 +153,14 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
137
153
  @input="emitInput"
138
154
  @keypress.enter="emitEnter"
139
155
  >
140
- <div v-if="showDisplay" class="input display">
156
+ <div v-if="showDisplay" class="input display" :class="[textColor]">
141
157
  {{ displayValue }}
142
158
  </div>
143
159
  </div>
144
160
 
145
- <div v-if="props.unitAfter" class="unit after">
146
- {{ props.unitAfter }}
161
+ <div v-if="unitAfter" class="unit after">
162
+ <span v-if="isString(unitAfter)" class="unit-text">{{ unitAfter }}</span>
163
+ <SIcon v-else class="unit-icon" :icon="unitAfter" />
147
164
  </div>
148
165
  </div>
149
166
 
@@ -160,6 +177,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
160
177
  .box { min-height: 32px; }
161
178
  .value { min-height: 30px; }
162
179
  .area { min-height: 30px; }
180
+ .unit { min-height: 30px; }
163
181
 
164
182
  .input {
165
183
  padding: 3px 8px;
@@ -180,12 +198,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
180
198
  .unit.before { padding-right: 0; }
181
199
  .unit.after { padding-left: 0; }
182
200
 
183
- .icon {
184
- width: 22px;
185
- height: 30px;
186
- }
187
-
188
- .icon-svg {
201
+ .unit-icon {
189
202
  width: 16px;
190
203
  height: 16px;
191
204
  }
@@ -213,6 +226,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
213
226
  .box { min-height: 40px; }
214
227
  .value { min-height: 38px; }
215
228
  .area { min-height: 38px; }
229
+ .unit { min-height: 38px; }
216
230
 
217
231
  .input {
218
232
  padding: 7px 12px;
@@ -233,12 +247,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
233
247
  .unit.before { padding-right: 0; }
234
248
  .unit.after { padding-left: 0; }
235
249
 
236
- .icon {
237
- width: 26px;
238
- height: 38px;
239
- }
240
-
241
- .icon-svg {
250
+ .unit-icon {
242
251
  width: 16px;
243
252
  height: 16px;
244
253
  }
@@ -266,6 +275,7 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
266
275
  .box { min-height: 48px; }
267
276
  .value { min-height: 46px; }
268
277
  .area { min-height: 46px; }
278
+ .unit { min-height: 46px; }
269
279
 
270
280
  .input {
271
281
  padding: 11px 12px;
@@ -286,14 +296,9 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
286
296
  .unit.before { padding-right: 0; }
287
297
  .unit.after { padding-left: 0; }
288
298
 
289
- .icon {
290
- width: 28px;
291
- height: 46px;
292
- }
293
-
294
- .icon-svg {
295
- width: 18px;
296
- height: 18px;
299
+ .unit-icon {
300
+ width: 16px;
301
+ height: 16px;
297
302
  }
298
303
 
299
304
  :slotted(.SInputAddon) .action {
@@ -385,10 +390,15 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
385
390
  bottom: 0;
386
391
  left: 0;
387
392
  width: 100%;
388
- color: var(--input-value-color);
389
393
  background-color: transparent;
390
394
  cursor: text;
391
395
 
396
+ &.neutral:not(.hide) { color: var(--input-value-color); }
397
+ &.info:not(.hide) { color: var(--c-info-text); }
398
+ &.success:not(.hide) { color: var(--c-success-text); }
399
+ &.warning:not(.hide) { color: var(--c-warning-text); }
400
+ &.danger:not(.hide) { color: var(--c-danger-text); }
401
+
392
402
  &.hide,
393
403
  &.hide::placeholder {
394
404
  color: transparent;
@@ -409,19 +419,14 @@ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
409
419
  }
410
420
 
411
421
  .unit {
412
- font-weight: 500;
413
- color: var(--c-text-2);
414
- }
415
-
416
- .icon {
417
422
  display: flex;
418
423
  align-items: center;
419
- cursor: text;
424
+ justify-content: center;
420
425
  color: var(--c-text-2);
421
426
  }
422
427
 
423
- .icon-svg {
424
- fill: currentColor;
428
+ .unit-text {
429
+ font-weight: 500;
425
430
  }
426
431
 
427
432
  .addon {
@@ -19,7 +19,7 @@ const props = defineProps<{
19
19
  checkColor?: Color
20
20
  placeholder?: string
21
21
  disabled?: boolean
22
- rows?: number
22
+ rows?: number | 'fill'
23
23
  modelValue: string | null
24
24
  hideError?: boolean
25
25
  validation?: Validatable
@@ -31,7 +31,8 @@ const emit = defineEmits<{
31
31
 
32
32
  const classes = computed(() => [
33
33
  props.size ?? 'small',
34
- { disabled: props.disabled }
34
+ { disabled: props.disabled },
35
+ { fill: props.rows === 'fill' }
35
36
  ])
36
37
 
37
38
  function emitInput(e: Event): void {
@@ -62,6 +63,7 @@ function emitBlur(e: FocusEvent): void {
62
63
  <textarea
63
64
  :id="name"
64
65
  class="input"
66
+ :class="{ fill: rows === 'fill' }"
65
67
  :placeholder="placeholder"
66
68
  :rows="rows ?? 3"
67
69
  :disabled="disabled"
@@ -73,7 +75,7 @@ function emitBlur(e: FocusEvent): void {
73
75
  </SInputBase>
74
76
  </template>
75
77
 
76
- <style lang="postcss" scoped>
78
+ <style scoped lang="postcss">
77
79
  .SInputTextarea.mini {
78
80
  .input {
79
81
  padding: 6px 12px;
@@ -155,5 +157,9 @@ function emitBlur(e: FocusEvent): void {
155
157
  .dark &:hover:focus {
156
158
  border-color: var(--c-info);
157
159
  }
160
+
161
+ &.fill {
162
+ height: 100%;
163
+ }
158
164
  }
159
165
  </style>
@@ -658,4 +658,8 @@
658
658
  --input-mini-font-size: 14px;
659
659
  --input-small-font-size: 16px;
660
660
  --input-medium-font-size: 16px;
661
+
662
+ --input-mini-label-font-size: 12px;
663
+ --input-small-label-font-size: 14px;
664
+ --input-medium-label-font-size: 14px;
661
665
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "2.16.0",
4
- "packageManager": "pnpm@7.26.0",
3
+ "version": "2.18.0",
4
+ "packageManager": "pnpm@7.26.2",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",
7
7
  "license": "MIT",