mgv-backoffice 1.40.0 → 1.42.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.
- package/README.md +34 -4
- package/dist/components/BaseCheckbox.vue.d.ts +28 -0
- package/dist/components/BaseSelect.vue.d.ts +4 -11
- package/dist/components/BaseSidebarUser.vue.d.ts +23 -0
- package/dist/index.d.ts +3 -0
- package/dist/ui-lib.css +1 -1
- package/dist/ui-lib.js +1105 -995
- package/dist/ui-lib.umd.cjs +1 -1
- package/dist/utils/humanize.d.ts +10 -0
- package/package.json +1 -1
- package/src/components/BaseAuthLayout.test.ts +48 -48
- package/src/components/BaseBadge.vue +3 -7
- package/src/components/BaseBooleanBadge.vue +32 -33
- package/src/components/BaseCheckbox.test.ts +30 -0
- package/src/components/BaseCheckbox.vue +51 -0
- package/src/components/BaseSelect.test.ts +20 -0
- package/src/components/BaseSelect.vue +16 -3
- package/src/components/BaseSidebarUser.test.ts +26 -0
- package/src/components/BaseSidebarUser.vue +75 -0
- package/src/components/BaseSpinner.vue +76 -76
- package/src/index.ts +3 -0
- package/src/style.css +71 -0
- package/src/utils/humanize.test.ts +35 -0
- package/src/utils/humanize.ts +35 -0
package/src/style.css
CHANGED
|
@@ -88,3 +88,74 @@ html .dp--theme-dark {
|
|
|
88
88
|
--dp-marker-color: #ef4444;
|
|
89
89
|
--dp-tooltip-color: #1e293b;
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
/* BaseSelect: rounded, themed dropdown panel. Opt-in customizable <select>
|
|
93
|
+
(appearance: base-select, Chromium 135+); other browsers keep the native
|
|
94
|
+
popup, which can't be styled. The button skin comes from BaseSelect's
|
|
95
|
+
utilities, and its own ChevronDownIcon replaces the built-in picker icon. */
|
|
96
|
+
@supports (appearance: base-select) {
|
|
97
|
+
.base-select,
|
|
98
|
+
.base-select::picker(select) {
|
|
99
|
+
appearance: base-select;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.base-select::picker-icon {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.base-select::picker(select) {
|
|
107
|
+
margin-top: 0.25rem;
|
|
108
|
+
padding: 0.25rem;
|
|
109
|
+
border: 1px solid var(--color-slate-200);
|
|
110
|
+
border-radius: 0.75rem;
|
|
111
|
+
background-color: #fff;
|
|
112
|
+
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.base-select option {
|
|
116
|
+
padding: 0.375rem 0.625rem;
|
|
117
|
+
border-radius: 0.5rem;
|
|
118
|
+
color: var(--color-slate-900);
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.base-select option::checkmark {
|
|
123
|
+
display: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.base-select option:hover,
|
|
127
|
+
.base-select option:focus-visible {
|
|
128
|
+
background-color: var(--color-slate-100);
|
|
129
|
+
outline: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.base-select option:checked {
|
|
133
|
+
background-color: var(--color-emerald-50);
|
|
134
|
+
color: var(--color-emerald-700);
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.base-select option:disabled {
|
|
139
|
+
color: var(--color-slate-400);
|
|
140
|
+
cursor: default;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.dark .base-select::picker(select) {
|
|
144
|
+
border-color: var(--color-slate-700);
|
|
145
|
+
background-color: var(--color-slate-900);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.dark .base-select option {
|
|
149
|
+
color: var(--color-slate-100);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.dark .base-select option:hover,
|
|
153
|
+
.dark .base-select option:focus-visible {
|
|
154
|
+
background-color: var(--color-slate-800);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.dark .base-select option:checked {
|
|
158
|
+
background-color: rgb(16 185 129 / 0.15);
|
|
159
|
+
color: var(--color-emerald-300);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { h, Fragment, createTextVNode } from 'vue'
|
|
3
|
+
import { humanizeEnum, humanizeTextVNodes } from './humanize'
|
|
4
|
+
|
|
5
|
+
describe('humanizeEnum', () => {
|
|
6
|
+
it('replaces every underscore with a space', () => {
|
|
7
|
+
expect(humanizeEnum('BLUE_SKY')).toBe('BLUE SKY')
|
|
8
|
+
expect(humanizeEnum('A_B_C')).toBe('A B C')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('returns an empty string for null / undefined', () => {
|
|
12
|
+
expect(humanizeEnum(null)).toBe('')
|
|
13
|
+
expect(humanizeEnum(undefined)).toBe('')
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('humanizeTextVNodes', () => {
|
|
18
|
+
it('rewrites text nodes and walks fragments', () => {
|
|
19
|
+
const [text, frag] = humanizeTextVNodes([
|
|
20
|
+
createTextVNode('PROFIT_TARGET'),
|
|
21
|
+
h(Fragment, [createTextVNode('RSI_REVERT')]),
|
|
22
|
+
])
|
|
23
|
+
expect(text.children).toBe('PROFIT TARGET')
|
|
24
|
+
expect((frag.children as any[])[0].children).toBe('RSI REVERT')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('leaves elements alone unless their tag is listed', () => {
|
|
28
|
+
const span = h('span', 'KEEP_ME')
|
|
29
|
+
expect(humanizeTextVNodes([span])[0]).toBe(span)
|
|
30
|
+
|
|
31
|
+
const [opt] = humanizeTextVNodes([h('option', { value: 'BLUE_SKY' }, 'BLUE_SKY')], ['option'])
|
|
32
|
+
expect(opt.children).toBe('BLUE SKY')
|
|
33
|
+
expect(opt.props?.value).toBe('BLUE_SKY')
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cloneVNode, createTextVNode, Fragment, Text, type VNode } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** Raw enum names (BLUE_SKY, PROFIT_TARGET) → display text (BLUE SKY). */
|
|
4
|
+
export function humanizeEnum(value: string | null | undefined): string {
|
|
5
|
+
return value == null ? '' : String(value).replace(/_/g, ' ')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Rewrites underscores to spaces in slot text so callers can pass raw enum
|
|
10
|
+
* names. Plain text nodes are rewritten and fragments (v-for / v-if) are
|
|
11
|
+
* walked; elements pass through untouched unless their tag is in `tags`, in
|
|
12
|
+
* which case their string children are rewritten too (e.g. `<option>`).
|
|
13
|
+
*/
|
|
14
|
+
export function humanizeTextVNodes(nodes: VNode[], tags: readonly string[] = []): VNode[] {
|
|
15
|
+
return nodes.map((node) => {
|
|
16
|
+
if (node.type === Text && typeof node.children === 'string') {
|
|
17
|
+
return createTextVNode(humanizeEnum(node.children))
|
|
18
|
+
}
|
|
19
|
+
if (node.type === Fragment && Array.isArray(node.children)) {
|
|
20
|
+
const clone = cloneVNode(node)
|
|
21
|
+
clone.children = humanizeTextVNodes(node.children as VNode[], tags)
|
|
22
|
+
return clone
|
|
23
|
+
}
|
|
24
|
+
if (typeof node.type === 'string' && tags.includes(node.type)) {
|
|
25
|
+
const clone = cloneVNode(node)
|
|
26
|
+
if (typeof node.children === 'string') {
|
|
27
|
+
clone.children = humanizeEnum(node.children)
|
|
28
|
+
} else if (Array.isArray(node.children)) {
|
|
29
|
+
clone.children = humanizeTextVNodes(node.children as VNode[], tags)
|
|
30
|
+
}
|
|
31
|
+
return clone
|
|
32
|
+
}
|
|
33
|
+
return node
|
|
34
|
+
})
|
|
35
|
+
}
|