@globalbrain/sefirot 2.28.0 → 2.30.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.
@@ -20,6 +20,7 @@ const props = defineProps<{
20
20
  checkText?: string
21
21
  checkColor?: Color
22
22
  block?: boolean
23
+ disabled?: boolean
23
24
  modelValue: Day | null
24
25
  validation?: Validatable
25
26
  hideError?: boolean
@@ -79,12 +80,13 @@ function emitBlur() {
79
80
  <input
80
81
  :id="name"
81
82
  class="input"
82
- :class="{ block }"
83
+ :class="{ block, disabled }"
83
84
  type="text"
84
85
  placeholder="YYYY-MM-DD"
85
- :value="inputValue"
86
86
  autocomplete="off"
87
- v-on="inputEvents"
87
+ :value="inputValue"
88
+ :disabled="disabled"
89
+ v-on="disabled || inputEvents"
88
90
  @blur="emitBlur"
89
91
  >
90
92
  </DatePicker>
@@ -97,31 +99,43 @@ function emitBlur() {
97
99
  .SInputDate.mini {
98
100
  .input {
99
101
  padding: 3px 8px;
100
- max-width: 120px;
102
+ max-width: 114px;
101
103
  height: 32px;
102
104
  line-height: 24px;
103
105
  font-size: var(--input-font-size, var(--input-mini-font-size));
104
106
  }
107
+
108
+ .input.block {
109
+ max-width: 100%;
110
+ }
105
111
  }
106
112
 
107
113
  .SInputDate.small {
108
114
  .input {
109
115
  padding: 5px 12px;
110
- max-width: 128px;
116
+ max-width: 136px;
111
117
  height: 40px;
112
118
  line-height: 24px;
113
119
  font-size: var(--input-font-size, var(--input-small-font-size));
114
120
  }
121
+
122
+ .input.block {
123
+ max-width: 100%;
124
+ }
115
125
  }
116
126
 
117
127
  .SInputDate.medium {
118
128
  .input {
119
129
  padding: 11px 12px;
120
- max-width: 160px;
130
+ max-width: 136px;
121
131
  height: 48px;
122
132
  line-height: 24px;
123
133
  font-size: var(--input-font-size, var(--input-medium-font-size));
124
134
  }
135
+
136
+ .input.block {
137
+ max-width: 100%;
138
+ }
125
139
  }
126
140
 
127
141
  .SInputDate.has-error {
@@ -139,8 +153,8 @@ function emitBlur() {
139
153
  border: 1px solid var(--input-border-color);
140
154
  border-radius: 6px;
141
155
  width: 100%;
142
- font-family: var(--font-family-number);
143
156
  font-weight: 400;
157
+ font-feature-settings: 'tnum';
144
158
  background-color: var(--input-bg-color);
145
159
  transition: border-color 0.25s, background-color 0.25s;
146
160
 
@@ -148,8 +162,10 @@ function emitBlur() {
148
162
  color: var(--input-placeholder-color);
149
163
  }
150
164
 
151
- &.block {
152
- max-width: none;
165
+ &.disabled {
166
+ border-color: var(--input-disabled-border-color);
167
+ background-color: var(--input-disabled-bg-color);
168
+ cursor: not-allowed;
153
169
  }
154
170
  }
155
171
  </style>
@@ -241,11 +241,12 @@ function handleArray(value: OptionValue) {
241
241
 
242
242
  .SInputDropdown.disabled {
243
243
  .box {
244
- background-color: var(--c-bg);
244
+ border-color: var(--input-disabled-border-color);
245
+ background-color: var(--input-disabled-bg-color);
245
246
  cursor: not-allowed;
246
247
 
247
- &:hover { border-color: var(--c-divider); }
248
- &:focus:not(:focus-visible) { border-color: var(--c-divider); }
248
+ &:hover { border-color: var(--input-disabled-border-color); }
249
+ &:focus:not(:focus-visible) { border-color: var(--input-disabled-border-color); }
249
250
  }
250
251
 
251
252
  .box-icon {
@@ -28,6 +28,7 @@ const props = defineProps<{
28
28
  noYear?: boolean
29
29
  noMonth?: boolean
30
30
  noDate?: boolean
31
+ block?: boolean
31
32
  disabled?: boolean
32
33
  value?: Value
33
34
  modelValue?: Value
@@ -139,7 +140,7 @@ function createRequiredTouched(): boolean[] {
139
140
  :hide-error="hideError"
140
141
  :validation="validation"
141
142
  >
142
- <div class="container" :class="{ focus: isFocused }">
143
+ <div class="container" :class="{ focus: isFocused, block }">
143
144
  <input
144
145
  v-if="!noYear"
145
146
  class="input year"
@@ -278,11 +279,15 @@ function createRequiredTouched(): boolean[] {
278
279
 
279
280
  &:hover { border-color: var(--input-hover-border-color); }
280
281
  &.focus { border-color: var(--input-focus-border-color); }
282
+
283
+ &.block {
284
+ width: 100%;
285
+ }
281
286
  }
282
287
 
283
288
  .input {
284
- font-family: var(--font-family-number);
285
289
  line-height: 24px;
290
+ font-feature-settings: "tnum";
286
291
  background-color: transparent;
287
292
 
288
293
  &::placeholder {
@@ -114,6 +114,16 @@ function lockBody(value: boolean) {
114
114
  function updateColWidth(key: string, value: string) {
115
115
  colWidths[key] = value
116
116
  }
117
+
118
+ function isSummary(index: number) {
119
+ return index === records?.value?.length
120
+ }
121
+
122
+ function getCell(key: string, index: number) {
123
+ return (isSummary(index) && columns.value[key]?.summaryCell)
124
+ ? columns.value[key]?.summaryCell
125
+ : columns.value[key]?.cell
126
+ }
117
127
  </script>
118
128
 
119
129
  <template>
@@ -171,7 +181,7 @@ function updateColWidth(key: string, value: string) {
171
181
  v-for="(record, rIndex) in recordsWithSummary"
172
182
  :key="rIndex"
173
183
  class="row"
174
- :class="rIndex === records?.length && 'summary'"
184
+ :class="isSummary(rIndex) && 'summary'"
175
185
  >
176
186
  <STableItem
177
187
  v-for="key in orders"
@@ -182,9 +192,9 @@ function updateColWidth(key: string, value: string) {
182
192
  >
183
193
  <STableCell
184
194
  :name="key"
185
- :class="rIndex === records?.length && 'summary'"
195
+ :class="isSummary(rIndex) && 'summary'"
186
196
  :class-name="columns[key].className"
187
- :cell="columns[key].cell"
197
+ :cell="getCell(key, rIndex)"
188
198
  :value="record[key]"
189
199
  :record="record"
190
200
  :records="records"
@@ -95,7 +95,7 @@ const computedCell = computed<TableCell | undefined>(() =>
95
95
  overflow: hidden;
96
96
 
97
97
  .row:hover & {
98
- background-color: var(--c-bg-elv-1);
98
+ background-color: var(--c-bg-elv-2);
99
99
  }
100
100
 
101
101
  .summary & {
@@ -6,14 +6,15 @@ import type { DropdownSection } from './Dropdown'
6
6
 
7
7
  export interface Table<
8
8
  O extends string = any,
9
- R extends Record<string, any> = any
9
+ R extends Record<string, any> = any,
10
+ SR extends Record<string, any> = any
10
11
  > {
11
12
  orders: O[]
12
- columns: TableColumns<O, R>
13
+ columns: TableColumns<O, R, SR>
13
14
  records?: R[] | null
14
15
  header?: boolean
15
16
  footer?: boolean
16
- summary?: TableSummary<R> | null
17
+ summary?: SR | null
17
18
  total?: number | null
18
19
  page?: number | null
19
20
  perPage?: number | null
@@ -27,21 +28,23 @@ export interface Table<
27
28
 
28
29
  export type TableColumns<
29
30
  O extends string,
30
- R extends Record<string, any>
31
+ R extends Record<string, any>,
32
+ SR extends Record<string, any>
31
33
  > = {
32
- [K in O]: K extends keyof R
33
- ? TableColumn<R[K], R>
34
- : TableColumn<undefined, R>
34
+ [K in O]: TableColumn<R[K], R, SR[K], SR>
35
35
  }
36
36
 
37
- export interface TableColumn<V, R> {
37
+ export interface TableColumn<V, R, SV, SR> {
38
38
  label?: string
39
39
  className?: string
40
40
  dropdown?: DropdownSection[]
41
41
  resizable?: boolean
42
- cell?: TableCell | ((value: V, record: R) => TableCell)
42
+ cell?: TableCell | TableColumnCellFn<V, R>
43
+ summaryCell?: TableCell | TableColumnCellFn<SV, SR>
43
44
  }
44
45
 
46
+ export type TableColumnCellFn<V, R> = (value: V, record: R) => TableCell
47
+
45
48
  export type TableCell =
46
49
  | TableCellText
47
50
  | TableCellDay
@@ -139,17 +142,17 @@ export interface TableCellComponent extends TableCellBase {
139
142
  props?: Record<string, any>
140
143
  }
141
144
 
142
- export type TableSummary<T> = {
143
- [P in keyof T]?: T[P] | null | undefined
144
- }
145
-
146
- export interface UseTableOptions<O extends string, R extends Record<string, any>> {
145
+ export interface UseTableOptions<
146
+ O extends string,
147
+ R extends Record<string, any>,
148
+ SR extends Record<string, any>
149
+ > {
147
150
  orders: MaybeRef<O[]>
148
- columns: MaybeRef<TableColumns<O, R>>
151
+ columns: MaybeRef<TableColumns<O, R, SR>>
149
152
  records?: MaybeRef<R[] | null | undefined>
150
153
  header?: MaybeRef<boolean | undefined>
151
154
  footer?: MaybeRef<boolean | undefined>
152
- summary?: MaybeRef<TableSummary<R> | null | undefined>
155
+ summary?: MaybeRef<SR | null | undefined>
153
156
  total?: MaybeRef<number | null | undefined>
154
157
  page?: MaybeRef<number | null | undefined>
155
158
  perPage?: MaybeRef<number | null | undefined>
@@ -161,8 +164,12 @@ export interface UseTableOptions<O extends string, R extends Record<string, any>
161
164
  onReset?(): void
162
165
  }
163
166
 
164
- export function useTable<O extends string, R extends Record<string, any>>(
165
- options: UseTableOptions<O, R>
166
- ): Table<O, R> {
167
- return reactive(options) as Table<O, R>
167
+ export function useTable<
168
+ O extends string,
169
+ R extends Record<string, any>,
170
+ SR extends Record<string, any>
171
+ >(
172
+ options: UseTableOptions<O, R, SR>
173
+ ): Table<O, R, SR> {
174
+ return reactive(options) as Table<O, R, SR>
168
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "2.28.0",
3
+ "version": "2.30.0",
4
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>",