@veracity/vui 2.18.3 → 2.20.0-beta.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/button.d.ts.map +1 -1
- package/dist/cjs/button/button.js +3 -2
- package/dist/cjs/button/button.js.map +1 -1
- package/dist/cjs/checkbox/checkbox.d.ts.map +1 -1
- package/dist/cjs/checkbox/checkbox.js +7 -4
- package/dist/cjs/checkbox/checkbox.js.map +1 -1
- package/dist/cjs/checkbox/consts.d.ts +5 -3
- package/dist/cjs/checkbox/consts.d.ts.map +1 -1
- package/dist/cjs/checkbox/consts.js +5 -3
- package/dist/cjs/checkbox/consts.js.map +1 -1
- package/dist/cjs/checkbox/theme.d.ts +2 -2
- package/dist/cjs/checkbox/theme.js +1 -1
- package/dist/cjs/checkbox/theme.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/input/consts.d.ts +27 -21
- package/dist/cjs/input/consts.d.ts.map +1 -1
- package/dist/cjs/input/consts.js +8 -2
- package/dist/cjs/input/consts.js.map +1 -1
- package/dist/cjs/input/helpText.d.ts +1 -1
- package/dist/cjs/input/helpText.d.ts.map +1 -1
- package/dist/cjs/input/helpText.js +2 -2
- package/dist/cjs/input/helpText.js.map +1 -1
- package/dist/cjs/input/input.d.ts.map +1 -1
- package/dist/cjs/input/input.js +22 -18
- package/dist/cjs/input/input.js.map +1 -1
- package/dist/cjs/input/input.types.d.ts +7 -3
- package/dist/cjs/input/input.types.d.ts.map +1 -1
- package/dist/cjs/input/inputInput.js +3 -2
- package/dist/cjs/input/inputInput.js.map +1 -1
- package/dist/cjs/input/theme.d.ts +20 -8
- package/dist/cjs/input/theme.d.ts.map +1 -1
- package/dist/cjs/input/theme.js +14 -2
- package/dist/cjs/input/theme.js.map +1 -1
- package/dist/cjs/label/index.d.ts +4 -0
- package/dist/cjs/label/index.d.ts.map +1 -0
- package/dist/cjs/label/index.js +25 -0
- package/dist/cjs/label/index.js.map +1 -0
- package/dist/cjs/label/label.d.ts +6 -0
- package/dist/cjs/label/label.d.ts.map +1 -0
- package/dist/cjs/label/label.js +41 -0
- package/dist/cjs/label/label.js.map +1 -0
- package/dist/cjs/label/label.types.d.ts +7 -0
- package/dist/cjs/label/label.types.d.ts.map +1 -0
- package/dist/cjs/label/label.types.js +3 -0
- package/dist/cjs/label/label.types.js.map +1 -0
- package/dist/cjs/label/theme.d.ts +23 -0
- package/dist/cjs/label/theme.d.ts.map +1 -0
- package/dist/cjs/label/theme.js +28 -0
- package/dist/cjs/label/theme.js.map +1 -0
- package/dist/cjs/list/list.d.ts.map +1 -1
- package/dist/cjs/list/list.js +64 -2
- package/dist/cjs/list/list.js.map +1 -1
- package/dist/cjs/menu/menuItem.d.ts.map +1 -1
- package/dist/cjs/menu/menuItem.js +1 -1
- package/dist/cjs/menu/menuItem.js.map +1 -1
- package/dist/cjs/menu/menuList.d.ts.map +1 -1
- package/dist/cjs/menu/menuList.js +1 -1
- package/dist/cjs/menu/menuList.js.map +1 -1
- package/dist/cjs/radio/consts.d.ts +5 -3
- package/dist/cjs/radio/consts.d.ts.map +1 -1
- package/dist/cjs/radio/consts.js +5 -3
- package/dist/cjs/radio/consts.js.map +1 -1
- package/dist/cjs/radio/radio.d.ts.map +1 -1
- package/dist/cjs/radio/radio.js +6 -2
- package/dist/cjs/radio/radio.js.map +1 -1
- package/dist/cjs/radio/theme.d.ts +2 -2
- package/dist/cjs/radio/theme.js +1 -1
- package/dist/cjs/radio/theme.js.map +1 -1
- package/dist/cjs/select/select.d.ts +11 -6
- package/dist/cjs/select/select.d.ts.map +1 -1
- package/dist/cjs/select/select.js +9 -2
- package/dist/cjs/select/select.js.map +1 -1
- package/dist/cjs/select/select.types.d.ts +8 -0
- package/dist/cjs/select/select.types.d.ts.map +1 -1
- package/dist/cjs/select/selectButton.d.ts.map +1 -1
- package/dist/cjs/select/selectButton.js +16 -5
- package/dist/cjs/select/selectButton.js.map +1 -1
- package/dist/cjs/select/selectGroup.js +1 -1
- package/dist/cjs/select/selectGroup.js.map +1 -1
- package/dist/cjs/select/selectOption.js +1 -1
- package/dist/cjs/select/selectOption.js.map +1 -1
- package/dist/cjs/select/theme.d.ts +32 -0
- package/dist/cjs/select/theme.d.ts.map +1 -1
- package/dist/cjs/select/theme.js +33 -1
- package/dist/cjs/select/theme.js.map +1 -1
- package/dist/cjs/switch/switchLabel.d.ts.map +1 -1
- package/dist/cjs/switch/switchLabel.js +4 -0
- package/dist/cjs/switch/switchLabel.js.map +1 -1
- package/dist/cjs/switch/theme.d.ts +17 -0
- package/dist/cjs/switch/theme.d.ts.map +1 -1
- package/dist/cjs/switch/theme.js +18 -0
- package/dist/cjs/switch/theme.js.map +1 -1
- package/dist/cjs/tabs/tabsNavBar.d.ts.map +1 -1
- package/dist/cjs/tabs/tabsNavBar.js +5 -1
- package/dist/cjs/tabs/tabsNavBar.js.map +1 -1
- package/dist/cjs/textarea/textarea.d.ts +1 -1
- package/dist/cjs/textarea/textarea.d.ts.map +1 -1
- package/dist/cjs/textarea/textarea.js +23 -17
- package/dist/cjs/textarea/textarea.js.map +1 -1
- package/dist/cjs/textarea/textarea.types.d.ts +8 -0
- package/dist/cjs/textarea/textarea.types.d.ts.map +1 -1
- package/dist/cjs/textarea/theme.d.ts +8 -8
- package/dist/cjs/textarea/theme.js +2 -2
- package/dist/cjs/textarea/theme.js.map +1 -1
- package/dist/cjs/theme/components.d.ts +101 -20
- package/dist/cjs/theme/components.d.ts.map +1 -1
- package/dist/cjs/theme/components.js +56 -54
- package/dist/cjs/theme/components.js.map +1 -1
- package/dist/cjs/theme/defaultTheme.d.ts +101 -20
- package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
- package/dist/esm/button/button.d.ts.map +1 -1
- package/dist/esm/button/button.js +3 -2
- package/dist/esm/button/button.js.map +1 -1
- package/dist/esm/checkbox/checkbox.d.ts.map +1 -1
- package/dist/esm/checkbox/checkbox.js +7 -4
- package/dist/esm/checkbox/checkbox.js.map +1 -1
- package/dist/esm/checkbox/consts.d.ts +5 -3
- package/dist/esm/checkbox/consts.d.ts.map +1 -1
- package/dist/esm/checkbox/consts.js +5 -3
- package/dist/esm/checkbox/consts.js.map +1 -1
- package/dist/esm/checkbox/theme.d.ts +2 -2
- package/dist/esm/checkbox/theme.js +1 -1
- package/dist/esm/checkbox/theme.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/consts.d.ts +27 -21
- package/dist/esm/input/consts.d.ts.map +1 -1
- package/dist/esm/input/consts.js +7 -1
- package/dist/esm/input/consts.js.map +1 -1
- package/dist/esm/input/helpText.d.ts +1 -1
- package/dist/esm/input/helpText.d.ts.map +1 -1
- package/dist/esm/input/helpText.js +2 -2
- package/dist/esm/input/helpText.js.map +1 -1
- package/dist/esm/input/input.d.ts.map +1 -1
- package/dist/esm/input/input.js +25 -21
- package/dist/esm/input/input.js.map +1 -1
- package/dist/esm/input/input.types.d.ts +7 -3
- package/dist/esm/input/input.types.d.ts.map +1 -1
- package/dist/esm/input/inputInput.js +3 -2
- package/dist/esm/input/inputInput.js.map +1 -1
- package/dist/esm/input/theme.d.ts +20 -8
- package/dist/esm/input/theme.d.ts.map +1 -1
- package/dist/esm/input/theme.js +14 -2
- package/dist/esm/input/theme.js.map +1 -1
- package/dist/esm/label/index.d.ts +4 -0
- package/dist/esm/label/index.d.ts.map +1 -0
- package/dist/esm/label/index.js +4 -0
- package/dist/esm/label/index.js.map +1 -0
- package/dist/esm/label/label.d.ts +6 -0
- package/dist/esm/label/label.d.ts.map +1 -0
- package/dist/esm/label/label.js +24 -0
- package/dist/esm/label/label.js.map +1 -0
- package/dist/esm/label/label.types.d.ts +7 -0
- package/dist/esm/label/label.types.d.ts.map +1 -0
- package/dist/esm/label/label.types.js +2 -0
- package/dist/esm/label/label.types.js.map +1 -0
- package/dist/esm/label/theme.d.ts +23 -0
- package/dist/esm/label/theme.d.ts.map +1 -0
- package/dist/esm/label/theme.js +26 -0
- package/dist/esm/label/theme.js.map +1 -0
- package/dist/esm/list/list.d.ts.map +1 -1
- package/dist/esm/list/list.js +40 -2
- package/dist/esm/list/list.js.map +1 -1
- package/dist/esm/menu/menuItem.d.ts.map +1 -1
- package/dist/esm/menu/menuItem.js +1 -1
- package/dist/esm/menu/menuItem.js.map +1 -1
- package/dist/esm/menu/menuList.d.ts.map +1 -1
- package/dist/esm/menu/menuList.js +1 -1
- package/dist/esm/menu/menuList.js.map +1 -1
- package/dist/esm/radio/consts.d.ts +5 -3
- package/dist/esm/radio/consts.d.ts.map +1 -1
- package/dist/esm/radio/consts.js +5 -3
- package/dist/esm/radio/consts.js.map +1 -1
- package/dist/esm/radio/radio.d.ts.map +1 -1
- package/dist/esm/radio/radio.js +6 -2
- package/dist/esm/radio/radio.js.map +1 -1
- package/dist/esm/radio/theme.d.ts +2 -2
- package/dist/esm/radio/theme.js +1 -1
- package/dist/esm/radio/theme.js.map +1 -1
- package/dist/esm/select/select.d.ts +11 -6
- package/dist/esm/select/select.d.ts.map +1 -1
- package/dist/esm/select/select.js +13 -6
- package/dist/esm/select/select.js.map +1 -1
- package/dist/esm/select/select.types.d.ts +8 -0
- package/dist/esm/select/select.types.d.ts.map +1 -1
- package/dist/esm/select/selectButton.d.ts.map +1 -1
- package/dist/esm/select/selectButton.js +16 -5
- package/dist/esm/select/selectButton.js.map +1 -1
- package/dist/esm/select/selectGroup.js +1 -1
- package/dist/esm/select/selectGroup.js.map +1 -1
- package/dist/esm/select/selectOption.js +2 -2
- package/dist/esm/select/selectOption.js.map +1 -1
- package/dist/esm/select/theme.d.ts +32 -0
- package/dist/esm/select/theme.d.ts.map +1 -1
- package/dist/esm/select/theme.js +33 -1
- package/dist/esm/select/theme.js.map +1 -1
- package/dist/esm/switch/switchLabel.d.ts.map +1 -1
- package/dist/esm/switch/switchLabel.js +4 -0
- package/dist/esm/switch/switchLabel.js.map +1 -1
- package/dist/esm/switch/theme.d.ts +17 -0
- package/dist/esm/switch/theme.d.ts.map +1 -1
- package/dist/esm/switch/theme.js +18 -0
- package/dist/esm/switch/theme.js.map +1 -1
- package/dist/esm/tabs/tabsNavBar.d.ts.map +1 -1
- package/dist/esm/tabs/tabsNavBar.js +4 -1
- package/dist/esm/tabs/tabsNavBar.js.map +1 -1
- package/dist/esm/textarea/textarea.d.ts +1 -1
- package/dist/esm/textarea/textarea.d.ts.map +1 -1
- package/dist/esm/textarea/textarea.js +27 -21
- package/dist/esm/textarea/textarea.js.map +1 -1
- package/dist/esm/textarea/textarea.types.d.ts +8 -0
- package/dist/esm/textarea/textarea.types.d.ts.map +1 -1
- package/dist/esm/textarea/theme.d.ts +8 -8
- package/dist/esm/textarea/theme.js +2 -2
- package/dist/esm/textarea/theme.js.map +1 -1
- package/dist/esm/theme/components.d.ts +101 -20
- package/dist/esm/theme/components.d.ts.map +1 -1
- package/dist/esm/theme/components.js +2 -0
- package/dist/esm/theme/components.js.map +1 -1
- package/dist/esm/theme/defaultTheme.d.ts +101 -20
- 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/button.tsx +11 -6
- package/src/checkbox/checkbox.tsx +7 -5
- package/src/checkbox/consts.ts +6 -4
- package/src/checkbox/theme.ts +1 -1
- package/src/index.ts +1 -0
- package/src/input/consts.ts +12 -5
- package/src/input/helpText.tsx +2 -2
- package/src/input/input.tsx +90 -67
- package/src/input/input.types.ts +7 -4
- package/src/input/inputInput.tsx +2 -2
- package/src/input/theme.ts +14 -2
- package/src/label/index.ts +3 -0
- package/src/label/label.tsx +31 -0
- package/src/label/label.types.ts +8 -0
- package/src/label/theme.ts +29 -0
- package/src/list/list.tsx +44 -3
- package/src/menu/menuItem.tsx +1 -10
- package/src/menu/menuList.tsx +1 -0
- package/src/radio/consts.ts +6 -4
- package/src/radio/radio.tsx +5 -3
- package/src/radio/theme.ts +1 -1
- package/src/select/select.tsx +30 -5
- package/src/select/select.types.ts +8 -0
- package/src/select/selectButton.tsx +18 -5
- package/src/select/selectGroup.tsx +1 -1
- package/src/select/selectOption.tsx +2 -2
- package/src/select/theme.ts +33 -1
- package/src/switch/switchLabel.tsx +5 -0
- package/src/switch/theme.ts +21 -0
- package/src/tabs/tabsNavBar.tsx +4 -1
- package/src/textarea/textarea.tsx +78 -45
- package/src/textarea/textarea.types.ts +8 -0
- package/src/textarea/theme.ts +2 -2
- package/src/theme/components.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veracity/vui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0-beta.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/button.tsx
CHANGED
|
@@ -55,7 +55,7 @@ export const Button = vui<'button', ButtonProps>((props, ref) => {
|
|
|
55
55
|
dropDownIcon = 'falAngleDown',
|
|
56
56
|
icon,
|
|
57
57
|
iconLeft,
|
|
58
|
-
iconRight,
|
|
58
|
+
iconRight: iconRightProp,
|
|
59
59
|
isActive,
|
|
60
60
|
isDropDown,
|
|
61
61
|
isElevated,
|
|
@@ -77,6 +77,8 @@ export const Button = vui<'button', ButtonProps>((props, ref) => {
|
|
|
77
77
|
|
|
78
78
|
const { iconProps: stateIconProps, ...stateProps } = states[state] ?? {}
|
|
79
79
|
|
|
80
|
+
const iconRight = isDropDown ? 'falAngleDown' : iconRightProp
|
|
81
|
+
|
|
80
82
|
const variant = filterUndefined({
|
|
81
83
|
variant: states[state]?.variant ?? variantProp,
|
|
82
84
|
})
|
|
@@ -138,7 +140,7 @@ export const Button = vui<'button', ButtonProps>((props, ref) => {
|
|
|
138
140
|
focusRing={3}
|
|
139
141
|
h={h}
|
|
140
142
|
pl={pl}
|
|
141
|
-
pr={
|
|
143
|
+
pr={pr}
|
|
142
144
|
ref={ref}
|
|
143
145
|
title={title || ariaLabel}
|
|
144
146
|
type="button"
|
|
@@ -159,19 +161,22 @@ export const Button = vui<'button', ButtonProps>((props, ref) => {
|
|
|
159
161
|
{!icon && (
|
|
160
162
|
<>
|
|
161
163
|
{isLoading ? (
|
|
162
|
-
<ButtonIcon mr={
|
|
164
|
+
<ButtonIcon mr={iconLeftMr} {...loadingIconProps} />
|
|
163
165
|
) : isString(iconLeft) ? (
|
|
164
|
-
<ButtonIcon mr={
|
|
166
|
+
<ButtonIcon mr={iconLeftMr} name={iconLeft} />
|
|
165
167
|
) : (
|
|
166
168
|
iconLeft
|
|
167
169
|
)}
|
|
168
170
|
|
|
169
171
|
{children ?? (isReactText(text) ? <ButtonText {...{ isTruncated, text }} /> : text)}
|
|
170
172
|
|
|
171
|
-
{isString(iconRight) ?
|
|
173
|
+
{isString(iconRight) ? (
|
|
174
|
+
<ButtonIcon ml={!children && !text ? 0 : iconRightMl} name={iconRight} />
|
|
175
|
+
) : (
|
|
176
|
+
iconRight
|
|
177
|
+
)}
|
|
172
178
|
</>
|
|
173
179
|
)}
|
|
174
|
-
{isDropDown && <ButtonIcon name={dropDownIcon} />}
|
|
175
180
|
</Content>
|
|
176
181
|
</ButtonBase>
|
|
177
182
|
</ButtonProvider>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { omitThemingProps, styled, th, useStyleConfig, vui } from '../core'
|
|
4
4
|
import Icon from '../icon'
|
|
@@ -38,8 +38,11 @@ export const CheckboxBase = styled.labelBox<CheckboxStyleProps>`
|
|
|
38
38
|
color: ${p => th.color(p.controlHoverColor)};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
.vui-checkboxControl:focus-within {
|
|
42
|
+
color: ${checkboxColors.focus};
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
&[aria-disabled='true'] {
|
|
42
|
-
color: ${checkboxColors.disabled};
|
|
43
46
|
cursor: not-allowed;
|
|
44
47
|
|
|
45
48
|
.vui-checkboxControl {
|
|
@@ -81,8 +84,8 @@ export const Checkbox = vui<'span', CheckboxProps>((props, ref) => {
|
|
|
81
84
|
const { color: controlColor, hoverColor, ...controlStyles } = styles.control
|
|
82
85
|
|
|
83
86
|
const icon = isIndeterminate ? iconIndeterminate : isChecked ? iconChecked : iconProp
|
|
84
|
-
const controlMr = children || label ?
|
|
85
|
-
const color =
|
|
87
|
+
const controlMr = children || label ? 1 : 0
|
|
88
|
+
const color = isChecked || isIndeterminate ? checkboxColors.checked : controlColor
|
|
86
89
|
const controlHoverColor = hoverColor ? hoverColor : checkboxColors.hover
|
|
87
90
|
const isLongLabel = label && label?.length >= 60
|
|
88
91
|
|
|
@@ -119,7 +122,6 @@ export const Checkbox = vui<'span', CheckboxProps>((props, ref) => {
|
|
|
119
122
|
{...controlStyles}
|
|
120
123
|
>
|
|
121
124
|
<CheckboxInput
|
|
122
|
-
aria-label={label ? label : 'input-checkbox'}
|
|
123
125
|
className="vui-checkboxInput"
|
|
124
126
|
onChange={handleOnChange}
|
|
125
127
|
ref={inputRef}
|
package/src/checkbox/consts.ts
CHANGED
package/src/checkbox/theme.ts
CHANGED
package/src/index.ts
CHANGED
package/src/input/consts.ts
CHANGED
|
@@ -7,17 +7,17 @@ export const inputColors = {
|
|
|
7
7
|
helpText: 'sandstone.30',
|
|
8
8
|
icons: 'seaBlue.main',
|
|
9
9
|
disabled: 'sandstone.95',
|
|
10
|
-
focus: '
|
|
10
|
+
focus: 'focusColor',
|
|
11
11
|
error: 'energyRed.45',
|
|
12
12
|
loading: 'seaBlue.80',
|
|
13
13
|
success: 'landGreen.35',
|
|
14
|
-
}
|
|
14
|
+
} as const
|
|
15
15
|
|
|
16
16
|
export const stateIcons = {
|
|
17
17
|
error: 'falExclamationTriangle',
|
|
18
18
|
loading: 'fadSpinnerThird',
|
|
19
19
|
success: 'falCheck',
|
|
20
|
-
}
|
|
20
|
+
} as const
|
|
21
21
|
|
|
22
22
|
export const inputStateMapping: InputStateMapping = {
|
|
23
23
|
error: {
|
|
@@ -49,11 +49,18 @@ export const displayValueOnlyTextSize = {
|
|
|
49
49
|
md: 'sm',
|
|
50
50
|
lg: 'md',
|
|
51
51
|
xl: 'lg',
|
|
52
|
-
}
|
|
52
|
+
} as const
|
|
53
53
|
|
|
54
54
|
export const clearIconSize = {
|
|
55
55
|
sm: 'sm',
|
|
56
56
|
md: 'sm',
|
|
57
57
|
lg: 'sm',
|
|
58
58
|
xl: 'md',
|
|
59
|
-
}
|
|
59
|
+
} as const
|
|
60
|
+
|
|
61
|
+
export const helpTextSize = {
|
|
62
|
+
sm: 'sm',
|
|
63
|
+
md: 'sm',
|
|
64
|
+
lg: 'md',
|
|
65
|
+
xl: 'md',
|
|
66
|
+
} as const
|
package/src/input/helpText.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { inputColors } from './consts'
|
|
|
8
8
|
import { useInputContext } from './context'
|
|
9
9
|
import { HelpTextProps } from './input.types'
|
|
10
10
|
|
|
11
|
-
/** Displaying help text
|
|
11
|
+
/** Displaying help text below the input. */
|
|
12
12
|
export const HelpText = vui<'div', HelpTextProps>((props, ref) => {
|
|
13
13
|
const { className, children, isError, ...rest } = props
|
|
14
14
|
const inputProps = useInputContext()
|
|
@@ -23,7 +23,7 @@ export const HelpText = vui<'div', HelpTextProps>((props, ref) => {
|
|
|
23
23
|
className={cs('vui-inputHelpText', className)}
|
|
24
24
|
color={color}
|
|
25
25
|
display="flex"
|
|
26
|
-
|
|
26
|
+
pt={0.5}
|
|
27
27
|
ref={ref}
|
|
28
28
|
{...styles.helpText}
|
|
29
29
|
{...rest}
|
package/src/input/input.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, useId, useMemo, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { IconButton } from '../button'
|
|
4
4
|
import { styled, useStyleConfig, vui, VuiComponent } from '../core'
|
|
5
|
+
import Label from '../label'
|
|
5
6
|
import { T } from '../t'
|
|
6
7
|
import { ChangeEvent, cs, filterUndefined, isString } from '../utils'
|
|
7
8
|
import AutoCompletePopover from './autoCompletePopover'
|
|
8
|
-
import { clearIconSize, displayValueOnlyTextSize, inputColors, inputStateMapping } from './consts'
|
|
9
|
+
import { clearIconSize, displayValueOnlyTextSize, helpTextSize, inputColors, inputStateMapping } from './consts'
|
|
9
10
|
import { InputProvider } from './context'
|
|
10
11
|
import { getInitialCount } from './helpers'
|
|
11
12
|
import HelpText from './helpText'
|
|
@@ -43,24 +44,27 @@ export const InputBase = styled.divBox`
|
|
|
43
44
|
export const Input = vui<'div', InputProps>((props, ref) => {
|
|
44
45
|
const {
|
|
45
46
|
allowClear,
|
|
47
|
+
ariaLabel,
|
|
46
48
|
autoComplete,
|
|
47
|
-
autoCompleteOptions,
|
|
48
49
|
autoCompleteMaxHeight,
|
|
50
|
+
autoCompleteOptions,
|
|
49
51
|
autoFocus,
|
|
50
52
|
children,
|
|
51
53
|
className,
|
|
52
54
|
defaultValue,
|
|
53
55
|
disabled,
|
|
56
|
+
displayValueOnly,
|
|
54
57
|
errorText,
|
|
58
|
+
helpText,
|
|
55
59
|
iconLeft,
|
|
56
60
|
iconRight,
|
|
57
|
-
id,
|
|
61
|
+
id: idProp,
|
|
58
62
|
input,
|
|
59
63
|
inputProps,
|
|
60
64
|
inputRef,
|
|
61
65
|
itemLeft,
|
|
62
66
|
itemRight,
|
|
63
|
-
|
|
67
|
+
label,
|
|
64
68
|
max,
|
|
65
69
|
maxLength,
|
|
66
70
|
min,
|
|
@@ -73,7 +77,6 @@ export const Input = vui<'div', InputProps>((props, ref) => {
|
|
|
73
77
|
readOnly,
|
|
74
78
|
required,
|
|
75
79
|
showCount,
|
|
76
|
-
displayValueOnly,
|
|
77
80
|
size = 'lg',
|
|
78
81
|
state = '',
|
|
79
82
|
stateMapping,
|
|
@@ -84,10 +87,13 @@ export const Input = vui<'div', InputProps>((props, ref) => {
|
|
|
84
87
|
...rest
|
|
85
88
|
} = props
|
|
86
89
|
|
|
90
|
+
const generatedId = useId()
|
|
87
91
|
const [count, setCount] = useState(getInitialCount(props))
|
|
88
92
|
const [valueInternal, setValueInternal] = useState(defaultValue || '')
|
|
89
93
|
const states = { ...inputStateMapping, ...stateMapping }
|
|
90
94
|
|
|
95
|
+
const id = idProp || generatedId
|
|
96
|
+
|
|
91
97
|
const styles = useStyleConfig('Input', props)
|
|
92
98
|
|
|
93
99
|
const context = useMemo(() => filterUndefined({ disabled, size, variant }), [disabled, size, variant])
|
|
@@ -130,10 +136,7 @@ export const Input = vui<'div', InputProps>((props, ref) => {
|
|
|
130
136
|
return (
|
|
131
137
|
<InputProvider value={context}>
|
|
132
138
|
{displayValueOnly ? (
|
|
133
|
-
<T
|
|
134
|
-
className={cs('vui-input-value', className)}
|
|
135
|
-
size={displayValueOnlyTextSize[size] as 'xs' | 'md' | 'sm' | 'lg'}
|
|
136
|
-
>
|
|
139
|
+
<T className={cs('vui-input-value', className)} size={displayValueOnlyTextSize[size]}>
|
|
137
140
|
{value || defaultValue}
|
|
138
141
|
</T>
|
|
139
142
|
) : (
|
|
@@ -143,67 +146,87 @@ export const Input = vui<'div', InputProps>((props, ref) => {
|
|
|
143
146
|
filterAutoCompleteOptions={filterAutoCompleteOptions}
|
|
144
147
|
onAutoCompleteSelect={onAutoCompleteSelect}
|
|
145
148
|
>
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
autoFocus,
|
|
154
|
-
defaultValue,
|
|
155
|
-
disabled,
|
|
156
|
-
id,
|
|
157
|
-
max,
|
|
158
|
-
maxLength,
|
|
159
|
-
min,
|
|
160
|
-
name,
|
|
161
|
-
onBlur,
|
|
162
|
-
onChange,
|
|
163
|
-
onFocus,
|
|
164
|
-
pattern,
|
|
165
|
-
placeholder,
|
|
166
|
-
readOnly,
|
|
167
|
-
required,
|
|
168
|
-
step,
|
|
169
|
-
type,
|
|
170
|
-
}}
|
|
171
|
-
autoComplete={autoCompleteOptions?.length ? 'off' : autoComplete}
|
|
172
|
-
value={valueInternal}
|
|
173
|
-
{...inputProps}
|
|
174
|
-
/>
|
|
175
|
-
)}
|
|
176
|
-
{isString(iconRight) ? <InputIcon mr={1} name={iconRight} /> : iconRight}
|
|
177
|
-
{itemRight}
|
|
178
|
-
{state && <InputIcon mr={1} {...states[state]?.iconProps} />}
|
|
179
|
-
{allowClear && (
|
|
180
|
-
<IconButton
|
|
181
|
-
disabled={!valueInternal}
|
|
182
|
-
icon="falTimes"
|
|
183
|
-
mr={0.5}
|
|
184
|
-
onClick={onClear}
|
|
185
|
-
size={clearIconSize[size] as 'md' | 'sm' | 'lg'}
|
|
186
|
-
title="Clear"
|
|
187
|
-
/>
|
|
149
|
+
<>
|
|
150
|
+
{isString(label) ? (
|
|
151
|
+
<Label aria-disabled={disabled} className="vui-input-label" htmlFor={id} mb={0.5} {...styles.label}>
|
|
152
|
+
{label}
|
|
153
|
+
</Label>
|
|
154
|
+
) : (
|
|
155
|
+
label
|
|
188
156
|
)}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
157
|
+
<InputBase
|
|
158
|
+
className={cs('vui-input', className)}
|
|
159
|
+
ref={ref}
|
|
160
|
+
{...styles.container}
|
|
161
|
+
{...aliasedProps}
|
|
162
|
+
{...rest}
|
|
163
|
+
>
|
|
164
|
+
{itemLeft}
|
|
165
|
+
{isString(iconLeft) ? <InputIcon ml={1} name={iconLeft} /> : iconLeft}
|
|
166
|
+
{children ?? input ?? (
|
|
167
|
+
<InputInput
|
|
168
|
+
ref={inputRef}
|
|
169
|
+
{...{
|
|
170
|
+
autoFocus,
|
|
171
|
+
ariaLabel,
|
|
172
|
+
defaultValue,
|
|
173
|
+
disabled,
|
|
174
|
+
id,
|
|
175
|
+
max,
|
|
176
|
+
maxLength,
|
|
177
|
+
min,
|
|
178
|
+
name,
|
|
179
|
+
onBlur,
|
|
180
|
+
onChange,
|
|
181
|
+
onFocus,
|
|
182
|
+
pattern,
|
|
183
|
+
placeholder,
|
|
184
|
+
readOnly,
|
|
185
|
+
required,
|
|
186
|
+
step,
|
|
187
|
+
type,
|
|
188
|
+
}}
|
|
189
|
+
autoComplete={autoCompleteOptions?.length ? 'off' : autoComplete}
|
|
190
|
+
value={valueInternal}
|
|
191
|
+
{...inputProps}
|
|
192
|
+
/>
|
|
193
|
+
)}
|
|
194
|
+
{isString(iconRight) ? <InputIcon mr={1} name={iconRight} /> : iconRight}
|
|
195
|
+
{itemRight}
|
|
196
|
+
{state && <InputIcon mr={1} {...states[state]?.iconProps} />}
|
|
197
|
+
{allowClear && (
|
|
198
|
+
<IconButton
|
|
199
|
+
disabled={!valueInternal}
|
|
200
|
+
icon="falTimes"
|
|
201
|
+
mr={0.5}
|
|
202
|
+
onClick={onClear}
|
|
203
|
+
size={clearIconSize[size]}
|
|
204
|
+
title="Clear"
|
|
205
|
+
/>
|
|
206
|
+
)}
|
|
207
|
+
{showCount && (
|
|
208
|
+
<T
|
|
209
|
+
className="vui-inputCount"
|
|
210
|
+
color={maxLength && count > maxLength ? inputColors.error : inputColors.helpText}
|
|
211
|
+
position="absolute"
|
|
212
|
+
right={0}
|
|
213
|
+
size="sm"
|
|
214
|
+
top="calc(100% + 1px)"
|
|
215
|
+
>
|
|
216
|
+
{count} {maxLength ? `/ ${maxLength}` : null}
|
|
217
|
+
</T>
|
|
218
|
+
)}
|
|
219
|
+
</InputBase>
|
|
220
|
+
</>
|
|
202
221
|
</AutoCompletePopover>
|
|
203
222
|
)}
|
|
204
223
|
|
|
205
|
-
{!!helpText && <HelpText>{helpText}</HelpText>}
|
|
206
|
-
{!!errorText &&
|
|
224
|
+
{!!helpText && <HelpText size={helpTextSize[size]}>{helpText}</HelpText>}
|
|
225
|
+
{!!errorText && (
|
|
226
|
+
<HelpText isError size={helpTextSize[size]}>
|
|
227
|
+
{errorText}
|
|
228
|
+
</HelpText>
|
|
229
|
+
)}
|
|
207
230
|
</InputProvider>
|
|
208
231
|
)
|
|
209
232
|
}) as VuiComponent<'div', InputProps> & {
|
package/src/input/input.types.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { ThemingProps } from '../theme'
|
|
|
7
7
|
import { ChangeEventHandler, FocusEventHandler, PropsOf } from '../utils'
|
|
8
8
|
|
|
9
9
|
export type InputInputProps = PropsOf<'input', SystemProps>
|
|
10
|
-
|
|
11
10
|
export type InputProps = SystemProps &
|
|
12
11
|
ThemingProps<'Input'> & {
|
|
13
12
|
/** Allow to remove input content with clear icon. */
|
|
@@ -20,14 +19,18 @@ export type InputProps = SystemProps &
|
|
|
20
19
|
autoCompleteMaxHeight?: number
|
|
21
20
|
/** Passed to the inner input. */
|
|
22
21
|
autoFocus?: boolean
|
|
22
|
+
/** ARIA label for the input element. */
|
|
23
|
+
ariaLabel?: string
|
|
23
24
|
/** Deprecated. Please use variant instead. @deprecated */
|
|
24
25
|
colorScheme?: 'green' | 'grey' | 'red'
|
|
25
26
|
/** Passed to the inner input. */
|
|
26
27
|
defaultValue?: number | string
|
|
27
28
|
/** Passed to the inner input. */
|
|
28
29
|
disabled?: boolean
|
|
29
|
-
/** Socket displaying error text
|
|
30
|
+
/** Socket displaying error text below an input. */
|
|
30
31
|
errorText?: string | React.ReactNode
|
|
32
|
+
/** Socket displaying help text below an input. */
|
|
33
|
+
helpText?: React.ReactNode | string
|
|
31
34
|
/** Socket displaying an icon on the left. */
|
|
32
35
|
iconLeft?: IconProp | JSX.Element
|
|
33
36
|
/** Socket displaying an icon on the right. */
|
|
@@ -44,8 +47,8 @@ export type InputProps = SystemProps &
|
|
|
44
47
|
itemLeft?: React.ReactNode
|
|
45
48
|
/** Socket displaying a custom element on the right. */
|
|
46
49
|
itemRight?: React.ReactNode
|
|
47
|
-
/**
|
|
48
|
-
|
|
50
|
+
/** The label. */
|
|
51
|
+
label?: string | React.ReactNode
|
|
49
52
|
/** Passed to the inner input. */
|
|
50
53
|
max?: number | string
|
|
51
54
|
/** Passed to the inner input. */
|
package/src/input/inputInput.tsx
CHANGED
|
@@ -25,18 +25,18 @@ export const InputInputBase = styled.input`
|
|
|
25
25
|
|
|
26
26
|
/** Displays an input element within the Input component. */
|
|
27
27
|
export const InputInput = vui<'input', InputInputProps>((props, ref) => {
|
|
28
|
-
const { className, autoComplete, ...rest } = props
|
|
28
|
+
const { type, className, autoComplete, ...rest } = props
|
|
29
29
|
const inputProps = useInputContext()
|
|
30
30
|
const mergedProps = { ...inputProps, ...props }
|
|
31
31
|
const styles = useStyleConfig('Input', mergedProps)
|
|
32
32
|
|
|
33
33
|
const aliasedProps = filterUndefined({
|
|
34
34
|
'aria-disabled': mergedProps.disabled,
|
|
35
|
+
'aria-label': mergedProps.ariaLabel,
|
|
35
36
|
})
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
39
|
<InputInputBase
|
|
39
|
-
aria-label="input-text"
|
|
40
40
|
autoComplete={autoComplete}
|
|
41
41
|
className={cs('vui-inputInput', className)}
|
|
42
42
|
ref={ref}
|
package/src/input/theme.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { inputColors } from './consts'
|
|
|
2
2
|
|
|
3
3
|
const baseStyle = {
|
|
4
4
|
container: {
|
|
5
|
-
focusWithinRing:
|
|
5
|
+
focusWithinRing: 3,
|
|
6
6
|
color: inputColors.inputText,
|
|
7
7
|
},
|
|
8
8
|
input: {
|
|
@@ -15,7 +15,7 @@ const defaultProps = {
|
|
|
15
15
|
variant: 'grey',
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const parts = ['container', 'icon', 'input']
|
|
18
|
+
const parts = ['container', 'icon', 'input', 'label']
|
|
19
19
|
|
|
20
20
|
const sizes = {
|
|
21
21
|
sm: {
|
|
@@ -27,6 +27,9 @@ const sizes = {
|
|
|
27
27
|
size: 'xs',
|
|
28
28
|
},
|
|
29
29
|
input: {},
|
|
30
|
+
label: {
|
|
31
|
+
fontSize: 'sm',
|
|
32
|
+
},
|
|
30
33
|
},
|
|
31
34
|
md: {
|
|
32
35
|
container: {
|
|
@@ -37,6 +40,9 @@ const sizes = {
|
|
|
37
40
|
size: 'sm',
|
|
38
41
|
},
|
|
39
42
|
input: {},
|
|
43
|
+
label: {
|
|
44
|
+
fontSize: 'sm',
|
|
45
|
+
},
|
|
40
46
|
},
|
|
41
47
|
lg: {
|
|
42
48
|
container: {
|
|
@@ -47,6 +53,9 @@ const sizes = {
|
|
|
47
53
|
size: 'md',
|
|
48
54
|
},
|
|
49
55
|
input: {},
|
|
56
|
+
label: {
|
|
57
|
+
fontSize: 'md',
|
|
58
|
+
},
|
|
50
59
|
},
|
|
51
60
|
xl: {
|
|
52
61
|
container: {
|
|
@@ -57,6 +66,9 @@ const sizes = {
|
|
|
57
66
|
size: 'md',
|
|
58
67
|
},
|
|
59
68
|
input: {},
|
|
69
|
+
label: {
|
|
70
|
+
fontSize: 'lg',
|
|
71
|
+
},
|
|
60
72
|
},
|
|
61
73
|
}
|
|
62
74
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { omitThemingProps, styled, useStyleConfig, vui } from '../core'
|
|
2
|
+
import T from '../t'
|
|
3
|
+
import { cs } from '../utils'
|
|
4
|
+
import { LabelProps } from './label.types'
|
|
5
|
+
|
|
6
|
+
export const LabelBase = styled.labelBox`
|
|
7
|
+
display: block;
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
width: 100%;
|
|
10
|
+
color: darkBlue.main;
|
|
11
|
+
|
|
12
|
+
&[aria-disabled='true'] {
|
|
13
|
+
color: sandstone.75;
|
|
14
|
+
cursor: not-allowed;
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
/** Displays a paragraph of text. */
|
|
19
|
+
export const Label = vui<'label', LabelProps>((props, ref) => {
|
|
20
|
+
const { children, className, text, ...rest } = omitThemingProps(props)
|
|
21
|
+
const styles = useStyleConfig('Label', props)
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<T as={LabelBase} className={cs('vui-label', className)} ref={ref} {...styles} {...rest}>
|
|
25
|
+
{children ?? text}
|
|
26
|
+
</T>
|
|
27
|
+
)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
Label.displayName = 'Label'
|
|
31
|
+
export default Label
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const baseStyle = {}
|
|
2
|
+
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
size: 'md',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const sizes = {
|
|
8
|
+
xs: {
|
|
9
|
+
fontSize: 'xs',
|
|
10
|
+
},
|
|
11
|
+
sm: {
|
|
12
|
+
fontSize: 'sm',
|
|
13
|
+
},
|
|
14
|
+
md: {
|
|
15
|
+
fontSize: 'md',
|
|
16
|
+
},
|
|
17
|
+
lg: {
|
|
18
|
+
fontSize: 'lg',
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const variants = {}
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
baseStyle,
|
|
26
|
+
defaultProps,
|
|
27
|
+
sizes,
|
|
28
|
+
variants,
|
|
29
|
+
}
|
package/src/list/list.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { is } from '@xstyled/util'
|
|
2
|
+
import React, { useEffect, useMemo, useRef } from 'react'
|
|
2
3
|
|
|
3
4
|
import { styled, useStyleConfig, vui, VuiComponent } from '../core'
|
|
4
5
|
import { cs, filterUndefined, isArray, isReactText } from '../utils'
|
|
@@ -10,6 +11,10 @@ import ListIcon from './listIcon'
|
|
|
10
11
|
import ListItem from './listItem'
|
|
11
12
|
import ListText from './listText'
|
|
12
13
|
|
|
14
|
+
const clickKeys = ['Enter', ' ']
|
|
15
|
+
const nextKeys = ['ArrowDown', 'Tab']
|
|
16
|
+
const prevKeys = ['ArrowUp']
|
|
17
|
+
|
|
13
18
|
export const ListBase = styled.ulBox``
|
|
14
19
|
|
|
15
20
|
/** Displays a list of list link items and optional heading. Exposes some props to the children via context. */
|
|
@@ -19,11 +24,47 @@ export const List = vui<'ul', ListProps>((props, ref) => {
|
|
|
19
24
|
|
|
20
25
|
const context = useMemo(() => filterUndefined({ isInteractive, size, variant }), [isInteractive, size, variant])
|
|
21
26
|
|
|
27
|
+
const listRef = useRef<HTMLUListElement>(null)
|
|
28
|
+
|
|
29
|
+
const [_, setActive] = React.useState(-1)
|
|
30
|
+
|
|
31
|
+
const onKeydown = (event: KeyboardEvent) => {
|
|
32
|
+
if ([...prevKeys, ...nextKeys, ...clickKeys].includes(event.key)) {
|
|
33
|
+
event.preventDefault()
|
|
34
|
+
setActive((a: number) => {
|
|
35
|
+
let active = a
|
|
36
|
+
if (listRef.current) {
|
|
37
|
+
const allChildren = Array.from(listRef.current.childNodes)
|
|
38
|
+
const tabIndexedChildren = allChildren.filter(child => (child as HTMLElement).tabIndex === 0)
|
|
39
|
+
|
|
40
|
+
if (nextKeys.includes(event.key) && active < tabIndexedChildren.length - 1) active++
|
|
41
|
+
if (prevKeys.includes(event.key)) active = active > 0 ? active - 1 : 0
|
|
42
|
+
|
|
43
|
+
tabIndexedChildren.forEach((node, index) => {
|
|
44
|
+
if (index === active) {
|
|
45
|
+
if (clickKeys.includes(event.key)) (node as HTMLElement)?.click()
|
|
46
|
+
else (node as HTMLElement)?.focus()
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
return active
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (listRef.current && isInteractive) {
|
|
57
|
+
listRef.current.addEventListener('keydown', onKeydown)
|
|
58
|
+
return () => {
|
|
59
|
+
listRef.current?.removeEventListener('keydown', onKeydown)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, [listRef.current, isInteractive])
|
|
63
|
+
|
|
22
64
|
return (
|
|
23
65
|
<ListProvider value={context}>
|
|
24
|
-
<ListBase className={cs('vui-list', className)} ref={ref} {...styles.container} {...rest}>
|
|
66
|
+
<ListBase className={cs('vui-list', className)} ref={ref || listRef} {...styles.container} {...rest}>
|
|
25
67
|
{isReactText(heading) ? <ListHeading text={heading} /> : heading}
|
|
26
|
-
|
|
27
68
|
{children ??
|
|
28
69
|
(isArray<ListItemProps>(items)
|
|
29
70
|
? items.map(({ key, ...props }, index) => <ListItem key={key ?? index} {...props} />)
|