@bagelink/vue 0.0.771 → 0.0.773

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.
@@ -0,0 +1,180 @@
1
+ <script setup lang="ts">
2
+ import { Btn, MaterialIcon } from '@bagelink/vue'
3
+ import { useSlots } from 'vue'
4
+ import type { MaterialIcons, ThemeType } from '@bagelink/vue'
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ disabled?: boolean
9
+ icon?: MaterialIcons
10
+ iconEnd?: MaterialIcons
11
+ color?: ThemeType
12
+ theme?: ThemeType
13
+ flat?: boolean
14
+ border?: boolean
15
+ outline?: boolean
16
+ loading?: boolean
17
+ value?: string
18
+ round?: boolean
19
+ btnStart?: boolean
20
+ btnEnd?: boolean
21
+
22
+ }>(),
23
+ {
24
+ onClick: () => '',
25
+ loading: false,
26
+ round: false,
27
+ disabled: false,
28
+ border: false,
29
+ outline: false,
30
+ btnStart: true
31
+ },
32
+ )
33
+
34
+ const slots = useSlots()
35
+
36
+ const computedTheme = $computed(
37
+ () => {
38
+ if (props.disabled) return 'gray-light'
39
+ return (props.color || props.theme)
40
+ },
41
+ )
42
+
43
+ const computedDefaultColors = $computed(
44
+ () => ({
45
+ backgroundColor: 'var(--bgl-primary)',
46
+ color: props.flat ? 'var(--bgl-text-color)' : 'var(--bgl-light-text)',
47
+ }),
48
+ )
49
+
50
+ function getThemeColors(theme: Partial<typeof computedDefaultColors>): typeof computedDefaultColors {
51
+ return {
52
+ ...computedDefaultColors,
53
+ ...theme,
54
+ color: props.flat
55
+ ? theme.backgroundColor as string
56
+ : theme.color as string,
57
+ }
58
+ }
59
+
60
+ const themes: Partial<Record<ThemeType, typeof computedDefaultColors>> = {
61
+ 'red': getThemeColors({ backgroundColor: 'var(--bgl-red)' }),
62
+ 'white': getThemeColors({ backgroundColor: 'var(--bgl-white)', color: 'var(--bgl-black)' }),
63
+ 'black': getThemeColors({ backgroundColor: 'var(--bgl-black)', color: 'var(--bgl-white)' }),
64
+ 'green': getThemeColors({ backgroundColor: 'var(--bgl-green)', color: 'var(--bgl-white)' }),
65
+ 'primary': getThemeColors({ backgroundColor: 'var(--bgl-primary)', color: 'var(--bgl-white)' }),
66
+ 'gray': getThemeColors({ backgroundColor: 'var(--bgl-gray-light)', color: 'var(--bgl-black)' }),
67
+ 'light': getThemeColors({ backgroundColor: 'var(--bgl-primary-light)', color: 'var(--bgl-primary)' }),
68
+ 'gray-light': getThemeColors({ backgroundColor: 'var(--bgl-gray-light)', color: 'var(--bgl-gray)' }),
69
+ 'blue': getThemeColors({}),
70
+ }
71
+
72
+ const cumputedTextColor = $computed(
73
+ () => (themes[computedTheme as ThemeType]?.color ?? computedDefaultColors.color),
74
+ )
75
+
76
+ const computedBackgroundColor = $computed(
77
+ () => (themes[computedTheme as ThemeType]?.backgroundColor ?? computedDefaultColors.backgroundColor),
78
+ )
79
+ </script>
80
+
81
+ <template>
82
+ <div
83
+ :disabled="disabled" :class="{
84
+ 'bgl_pill': !icon || slots.default || value,
85
+ round,
86
+ 'bgl_flatPill': flat,
87
+ 'bgl_pill-border': border || outline,
88
+ }"
89
+ >
90
+ <div class="bgl_pill-flex">
91
+ <div v-if="loading" class="loading" />
92
+ <div v-else>
93
+ <div v-if="btnStart" class="flex h-100">
94
+ <Btn class="bgl_pill-btn " thin icon="close" />
95
+ </div>
96
+ </div>
97
+ <MaterialIcon v-if="icon" :icon="icon" />
98
+ <slot />
99
+ <template v-if="!slots.default && value">
100
+ {{ value }}
101
+ </template>
102
+ <MaterialIcon v-if="props.iconEnd" :icon="props.iconEnd" />
103
+ <div v-if="loading" class="loading" />
104
+ <div v-else>
105
+ <div v-if="props.btnEnd" class="flex h-100">
106
+ <Btn class="bgl_pill-btn" thin icon="close" />
107
+ </div>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ </template>
112
+
113
+ <style scoped>
114
+ .bgl_pill-btn{
115
+ color: var(--pill-btn-color);
116
+ background: var(--pill-btn-bg);
117
+ width: calc(var(--pill-height) / 1.25)!important;
118
+ height: calc(var(--pill-height) / 1.25)!important;
119
+ }
120
+ .loading {
121
+ border: 1px solid var(--bgl-light-text);
122
+ border-bottom: 2px solid var(--bgl-light-text);
123
+ animation: spin 1s linear infinite;
124
+ border-radius: 100px;
125
+ width: 1rem;
126
+ height: 1rem;
127
+ margin: auto;
128
+ }
129
+ .bgl_flatPill .loading {
130
+ border-bottom: 2px solid var(--bgl-text-color);
131
+ }
132
+
133
+ @keyframes spin {
134
+ 0% {
135
+ transform: rotate(0deg);
136
+ }
137
+ 100% {
138
+ transform: rotate(360deg);
139
+ }
140
+ }
141
+
142
+ .bgl_pill {
143
+ padding-inline: 0.25rem;
144
+ transition: var(--bgl-transition);
145
+ background-color: v-bind(computedBackgroundColor);
146
+ color: v-bind(cumputedTextColor);
147
+ display: inline-block;
148
+ margin-inline-end: 0.25rem;
149
+ border-radius: var(--pill-border-radius);
150
+ height: var(--pill-height);
151
+ vertical-align: middle;
152
+ margin-bottom: 0.25rem;
153
+ }
154
+
155
+ .bgl_pill[disabled="true"] {
156
+ opacity: 0.5;
157
+ cursor: not-allowed;
158
+ }
159
+
160
+ .bgl_pill-flex {
161
+ display: flex;
162
+ align-items: center;
163
+ gap: 0.25rem;
164
+ justify-content: center;
165
+ height: 100%;
166
+ }
167
+ .bgl_pill.bgl_flatPill {
168
+ background: transparent;
169
+ }
170
+
171
+ .bgl_pill.round {
172
+ border-radius: 1000px;
173
+ }
174
+
175
+ .bgl_pill-border {
176
+ outline: 1px solid v-bind(computedBackgroundColor);
177
+ color: v-bind(computedBackgroundColor);
178
+ background: transparent;
179
+ }
180
+ </style>
@@ -17,12 +17,14 @@ const {
17
17
  data,
18
18
  schema,
19
19
  showFields,
20
- useServerSort = false
20
+ useServerSort = false,
21
+ disableSelect = false
21
22
  } = defineProps<{
22
23
  data: T[]
23
24
  schema?: BglFormSchemaT<T> | (() => BglFormSchemaT<T>)
24
25
  showFields?: string[]
25
26
  useServerSort?: boolean
27
+ disableSelect?: boolean
26
28
  }>()
27
29
 
28
30
  const emit = defineEmits<{
@@ -40,18 +42,18 @@ const computedItemHiehgt = $computed(() => `${itemHeight.value}px`)
40
42
  let sortField = $ref('')
41
43
  let sortDirection = $ref<SortDirectionsT>('ASC')
42
44
 
43
- const selectedItems = defineModel<T[]>(
45
+ const selectedItems = defineModel<string[]>(
44
46
  'selectedItems',
45
47
  {
46
- default: () => [] as T[],
47
- set: (value: T[]) => {
48
+ default: [] as string[],
49
+ set: (value: string[]) => {
48
50
  setTimeout(updateAllSelectorState, 0)
49
51
  return value
50
52
  },
51
53
  }
52
54
  )
53
55
 
54
- const isSelectable = $computed(() => Array.isArray(selectedItems.value))
56
+ const isSelectable = $computed(() => disableSelect === false && Array.isArray(selectedItems.value))
55
57
 
56
58
  const computedSortField = $computed(() => `_transformed_${sortField}`)
57
59
 
@@ -153,7 +155,7 @@ function updateAllSelectorState() {
153
155
  if (!allSelector) return
154
156
  const allSelected
155
157
  = computedData.value.length === computedSelectedItems.length
156
- && computedData.value.every((s: any) => computedSelectedItems.includes(s.id))
158
+ && computedData.value.every(s => computedSelectedItems.includes(s.id))
157
159
  allSelector.checked = allSelected
158
160
  allSelector.indeterminate = !allSelected && computedSelectedItems.length > 0
159
161
  }
@@ -25,8 +25,9 @@ export { default as ModalConfirm } from './ModalConfirm.vue'
25
25
  export { default as ModalForm } from './ModalForm.vue'
26
26
  export { default as NavBar } from './NavBar.vue'
27
27
  export { default as PageTitle } from './PageTitle.vue'
28
- export { default as RouterWrapper } from './RouterWrapper.vue'
28
+ export { default as Pill } from './Pill.vue'
29
29
 
30
+ export { default as RouterWrapper } from './RouterWrapper.vue'
30
31
  export { default as TableSchema } from './TableSchema.vue'
31
32
  export { default as Title } from './Title.vue'
32
33
  export { default as TopBar } from './TopBar.vue'
@@ -22,6 +22,10 @@
22
22
  border-radius: var(--btn-border-radius) !important;
23
23
  }
24
24
 
25
+ .rounded-thin {
26
+ border-radius: calc(var(--btn-border-radius) / 1.5) !important;
27
+ }
28
+
25
29
  .radius-05 {
26
30
  border-radius: calc(var(--btn-border-radius) / 2) !important;
27
31
  }
@@ -1841,6 +1845,10 @@
1841
1845
  height: 30vh;
1842
1846
  }
1843
1847
 
1848
+ .h-28px {
1849
+ height: 28px;
1850
+ }
1851
+
1844
1852
  .h-30px {
1845
1853
  height: 30px;
1846
1854
  }
@@ -44,6 +44,10 @@
44
44
  border-radius: var(--btn-border-radius) !important;
45
45
  }
46
46
 
47
+ .m_rounded-thin {
48
+ border-radius: calc(var(--btn-border-radius) / 1.5) !important;
49
+ }
50
+
47
51
  .m_radius-05 {
48
52
  border-radius: calc(var(--btn-border-radius) / 2) !important;
49
53
  }
@@ -1466,6 +1470,10 @@
1466
1470
  height: 30vh;
1467
1471
  }
1468
1472
 
1473
+ .m_h-28px {
1474
+ height: 28px;
1475
+ }
1476
+
1469
1477
  .m_h-30px {
1470
1478
  height: 30px;
1471
1479
  }
@@ -34,6 +34,8 @@
34
34
  --bgl-selection-bg: var(--bgl-blue-dark);
35
35
  --bgl-selection-color: var(--bgl-white);
36
36
  --bgl-scrollbar-thumb: var(--bgl-gray);
37
+ --pill-btn-color: var(--bgl-white);
38
+ --pill-btn-bg: var(--placeholder-color)
37
39
  }
38
40
 
39
41
  /* TYPE */
@@ -52,6 +54,8 @@
52
54
  --btn-border-radius: 10px;
53
55
  --btn-padding: 30px;
54
56
  --btn-height: 40px;
57
+ --pill-border-radius: 8px;
58
+ --pill-height: 30px;
55
59
  }
56
60
 
57
61
  /* MISC */