@veracity/vui 2.21.4 → 2.22.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/dist/cjs/button/theme.d.ts +1 -217
- package/dist/cjs/button/theme.d.ts.map +1 -1
- package/dist/cjs/button/theme.js +19 -15
- package/dist/cjs/button/theme.js.map +1 -1
- package/dist/cjs/buttonGroup/buttonGroup.js +6 -6
- package/dist/cjs/buttonGroup/buttonGroup.js.map +1 -1
- package/dist/cjs/select/select.d.ts.map +1 -1
- package/dist/cjs/select/select.js +3 -2
- package/dist/cjs/select/select.js.map +1 -1
- package/dist/cjs/select/select.types.d.ts +2 -0
- package/dist/cjs/select/select.types.d.ts.map +1 -1
- package/dist/cjs/select/useSelect.d.ts +2 -1
- package/dist/cjs/select/useSelect.d.ts.map +1 -1
- package/dist/cjs/select/useSelect.js +8 -4
- package/dist/cjs/select/useSelect.js.map +1 -1
- package/dist/cjs/select/useSelect.types.d.ts +2 -0
- package/dist/cjs/select/useSelect.types.d.ts.map +1 -1
- package/dist/cjs/theme/components.d.ts +1 -217
- package/dist/cjs/theme/components.d.ts.map +1 -1
- package/dist/cjs/theme/defaultTheme.d.ts +1 -217
- package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
- package/dist/esm/button/theme.d.ts +1 -217
- package/dist/esm/button/theme.d.ts.map +1 -1
- package/dist/esm/button/theme.js +22 -15
- package/dist/esm/button/theme.js.map +1 -1
- package/dist/esm/buttonGroup/buttonGroup.js +6 -6
- package/dist/esm/buttonGroup/buttonGroup.js.map +1 -1
- package/dist/esm/select/select.d.ts.map +1 -1
- package/dist/esm/select/select.js +3 -2
- package/dist/esm/select/select.js.map +1 -1
- package/dist/esm/select/select.types.d.ts +2 -0
- package/dist/esm/select/select.types.d.ts.map +1 -1
- package/dist/esm/select/useSelect.d.ts +2 -1
- package/dist/esm/select/useSelect.d.ts.map +1 -1
- package/dist/esm/select/useSelect.js +6 -4
- package/dist/esm/select/useSelect.js.map +1 -1
- package/dist/esm/select/useSelect.types.d.ts +2 -0
- package/dist/esm/select/useSelect.types.d.ts.map +1 -1
- package/dist/esm/theme/components.d.ts +1 -217
- package/dist/esm/theme/components.d.ts.map +1 -1
- package/dist/esm/theme/defaultTheme.d.ts +1 -217
- package/dist/esm/theme/defaultTheme.d.ts.map +1 -1
- package/dist/tsconfig.legacy.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/button/theme.ts +25 -16
- package/src/buttonGroup/buttonGroup.tsx +7 -7
- package/src/select/select.tsx +4 -2
- package/src/select/select.types.ts +2 -0
- package/src/select/useSelect.tsx +16 -6
- package/src/select/useSelect.types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veracity/vui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
package/src/button/theme.ts
CHANGED
|
@@ -59,7 +59,7 @@ const sizes = {
|
|
|
59
59
|
},
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const variants = {
|
|
62
|
+
const variants: Record<string, Record<string, Record<string, string>>> = {
|
|
63
63
|
primaryDark: {
|
|
64
64
|
container: {
|
|
65
65
|
bg: 'buttonTypePrimaryDefaultBackgroundColorDark',
|
|
@@ -274,21 +274,30 @@ const variants = {
|
|
|
274
274
|
color: 'landGreen.30',
|
|
275
275
|
},
|
|
276
276
|
},
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// buttonGroupDefault is an internal variant, used in ButtonGroup; based on secondaryDark
|
|
280
|
+
variants.buttonGroupDefault = {
|
|
281
|
+
container: {
|
|
282
|
+
...variants.secondaryDark.container,
|
|
283
|
+
borderColor: 'sandstone.60',
|
|
284
|
+
},
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// buttonGroupRounded is an internal variant
|
|
288
|
+
variants.buttonGroupRounded = {
|
|
289
|
+
container: {
|
|
290
|
+
bg: 'white',
|
|
291
|
+
borderColor: 'sandstone.79',
|
|
292
|
+
color: 'sandstone.10',
|
|
293
|
+
hoverBg: 'seaBlue.20',
|
|
294
|
+
hoverBorderColor: 'buttonTypePrimaryHoverBorderColorDark',
|
|
295
|
+
hoverColor: 'white',
|
|
296
|
+
activeBg: 'seaBlue.35',
|
|
297
|
+
activeBorderColor: 'buttonTypePrimaryActiveBorderColorDark',
|
|
298
|
+
activeColor: 'white',
|
|
299
|
+
borderRadius: 'round',
|
|
300
|
+
marginRight: '22px',
|
|
292
301
|
},
|
|
293
302
|
}
|
|
294
303
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
2
|
|
|
3
3
|
import { styled, th, vui } from '../core'
|
|
4
4
|
import { activeClassName, cs, filterUndefined } from '../utils'
|
|
@@ -39,12 +39,12 @@ export const ButtonGroupBase = styled.divBox<{ innerBorderColor: string }>`
|
|
|
39
39
|
|
|
40
40
|
//
|
|
41
41
|
> .${activeClassName}.vui-button-variant-secondaryDark {
|
|
42
|
-
background-color: ${
|
|
42
|
+
background-color: ${th.color('skyBlue.90')};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
> .${activeClassName}.vui-button-variant-buttonGroupRounded {
|
|
46
|
-
background-color: ${
|
|
47
|
-
color: ${
|
|
46
|
+
background-color: ${th.color('seaBlue.main')};
|
|
47
|
+
color: ${th.color('white')};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
> .vui-button-variant-buttonGroupRounded {
|
|
@@ -52,11 +52,11 @@ export const ButtonGroupBase = styled.divBox<{ innerBorderColor: string }>`
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
> .${activeClassName}.vui-button-variant-buttonGroupRounded:hover {
|
|
55
|
-
background-color: ${
|
|
55
|
+
background-color: ${th.color('seaBlue.20')};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
> .${activeClassName}.vui-button-variant-buttonGroupRounded:active {
|
|
59
|
-
background-color: ${
|
|
59
|
+
background-color: ${th.color('seaBlue.35')};
|
|
60
60
|
}
|
|
61
61
|
`
|
|
62
62
|
|
|
@@ -72,7 +72,7 @@ export const ButtonGroup = vui<'div', ButtonGroupProps>((props, ref) => {
|
|
|
72
72
|
filterUndefined({
|
|
73
73
|
disabled,
|
|
74
74
|
size,
|
|
75
|
-
variant: variant === 'default' ? '
|
|
75
|
+
variant: variant === 'default' ? 'buttonGroupDefault' : 'buttonGroupRounded',
|
|
76
76
|
}),
|
|
77
77
|
[disabled, size, variant],
|
|
78
78
|
)
|
package/src/select/select.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { helpTextSize } from '../input/consts'
|
|
|
6
6
|
import HelpText from '../input/helpText'
|
|
7
7
|
import { Popover } from '../popover'
|
|
8
8
|
import { __DEV__ } from '../utils'
|
|
9
|
-
import { SelectProvider
|
|
9
|
+
import { SelectProvider } from './context'
|
|
10
10
|
import { SelectOptionData, SelectProps } from './select.types'
|
|
11
11
|
import SelectButton from './selectButton'
|
|
12
12
|
import SelectContent from './selectContent'
|
|
@@ -39,6 +39,7 @@ export function Select(props: SelectProps) {
|
|
|
39
39
|
onChange,
|
|
40
40
|
options,
|
|
41
41
|
placeholder = 'Please select',
|
|
42
|
+
selectedText,
|
|
42
43
|
readOnly,
|
|
43
44
|
selectButton,
|
|
44
45
|
selectButtonProps,
|
|
@@ -49,7 +50,7 @@ export function Select(props: SelectProps) {
|
|
|
49
50
|
...rest
|
|
50
51
|
} = props
|
|
51
52
|
|
|
52
|
-
const selectProps = useSelect({ defaultValue, isMultiple, onChange, value, options, children })
|
|
53
|
+
const selectProps = useSelect({ defaultValue, isMultiple, onChange, value, options, selectedText, children })
|
|
53
54
|
|
|
54
55
|
if (__DEV__ && isMultiple && !Array.isArray(selectProps.value)) {
|
|
55
56
|
console.error('<Select /> is used with isMultiple but its value is not an array: ', value)
|
|
@@ -68,6 +69,7 @@ export function Select(props: SelectProps) {
|
|
|
68
69
|
name,
|
|
69
70
|
options,
|
|
70
71
|
placeholder,
|
|
72
|
+
selectedText,
|
|
71
73
|
readOnly,
|
|
72
74
|
size,
|
|
73
75
|
variant,
|
|
@@ -48,6 +48,8 @@ export type SelectProps = ThemingProps<'Select'> &
|
|
|
48
48
|
options?: SelectOptionData[]
|
|
49
49
|
/** Displayed inside the trigger when no value is selected. */
|
|
50
50
|
placeholder?: string
|
|
51
|
+
/** Displayed inside the trigger when value(s) selected. */
|
|
52
|
+
selectedText?: string
|
|
51
53
|
/** Select cannot be opened and is styled accordingly. */
|
|
52
54
|
readOnly?: boolean
|
|
53
55
|
/** Custom select button slot. */
|
package/src/select/useSelect.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { ChangeEvent, toggleItem, useCallbackRef } from '../utils'
|
|
|
4
4
|
import { SelectOptionData, SelectValue } from './select.types'
|
|
5
5
|
import { UseSelectProps } from './useSelect.types'
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
export const getOptionText = (value: SelectValue, options: SelectOptionData[]) => {
|
|
8
8
|
const option = options?.find((o: SelectOptionData) => o?.value === value)
|
|
9
9
|
|
|
10
10
|
return option?.text || value
|
|
@@ -12,7 +12,15 @@ const getValueText = (value: SelectValue, options: SelectOptionData[]) => {
|
|
|
12
12
|
|
|
13
13
|
/** Handles controlled/uncontrolled value state. Supports single and multiple values. */
|
|
14
14
|
export default function useSelect(props: UseSelectProps) {
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
defaultValue,
|
|
17
|
+
isMultiple,
|
|
18
|
+
onChange: onChangeProp,
|
|
19
|
+
value: valueProp,
|
|
20
|
+
options = [],
|
|
21
|
+
selectedText,
|
|
22
|
+
children,
|
|
23
|
+
} = props
|
|
16
24
|
|
|
17
25
|
// Not using useControlled here, because we need custom value setter when uncontrolled
|
|
18
26
|
const [stateValue, setStateValue] = useState(defaultValue)
|
|
@@ -38,11 +46,13 @@ export default function useSelect(props: UseSelectProps) {
|
|
|
38
46
|
const valueText =
|
|
39
47
|
isMultiple && Array.isArray(value)
|
|
40
48
|
? value[0]
|
|
41
|
-
?
|
|
42
|
-
|
|
43
|
-
}
|
|
49
|
+
? selectedText && value.length > 1
|
|
50
|
+
? selectedText
|
|
51
|
+
: `${getOptionText(value[0], [...options, ...dynamicOptions])}${
|
|
52
|
+
value.length > 1 ? ` (+${value.length - 1})` : ''
|
|
53
|
+
}`
|
|
44
54
|
: undefined
|
|
45
|
-
:
|
|
55
|
+
: getOptionText(value as SelectValue, [...options, ...dynamicOptions])
|
|
46
56
|
|
|
47
57
|
return { onChange, value, valueText }
|
|
48
58
|
}
|
|
@@ -17,6 +17,8 @@ export type UseSelectProps = {
|
|
|
17
17
|
children?: ReactNode
|
|
18
18
|
/** Props added to the select button */
|
|
19
19
|
selectButtonProps?: ButtonProps
|
|
20
|
+
/** Displayed inside the trigger when multiple options selected. */
|
|
21
|
+
selectedText?: string
|
|
20
22
|
/**
|
|
21
23
|
* Callback triggered when an option is selected.
|
|
22
24
|
*
|