@workday/canvas-kit-react 12.0.0-alpha.899-next.0 → 12.0.0-alpha.903-next.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/commonjs/avatar/lib/Avatar.js +21 -21
- package/dist/commonjs/badge/lib/CountBadge.js +3 -3
- package/dist/commonjs/button/lib/BaseButton.js +21 -21
- package/dist/commonjs/button/lib/DeleteButton.js +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
- package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
- package/dist/commonjs/button/lib/TertiaryButton.js +18 -18
- package/dist/commonjs/card/lib/Card.js +1 -1
- package/dist/commonjs/card/lib/CardBody.js +1 -1
- package/dist/commonjs/card/lib/CardHeading.js +1 -1
- package/dist/commonjs/checkbox/lib/CheckBackground.js +3 -3
- package/dist/commonjs/checkbox/lib/CheckboxCheck.js +5 -5
- package/dist/commonjs/checkbox/lib/CheckboxContainer.js +1 -1
- package/dist/commonjs/checkbox/lib/CheckboxInput.js +5 -5
- package/dist/commonjs/checkbox/lib/CheckboxRipple.js +1 -1
- package/dist/commonjs/collection/lib/ListBox.js +4 -4
- package/dist/commonjs/combobox/lib/ComboboxMenuItem.js +2 -2
- package/dist/commonjs/combobox/lib/ComboboxMenuList.js +1 -1
- package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldContainer.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldField.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldGroupLabel.js +5 -5
- package/dist/commonjs/form-field/lib/FormFieldGroupList.js +3 -3
- package/dist/commonjs/form-field/lib/FormFieldHint.js +3 -3
- package/dist/commonjs/form-field/lib/FormFieldLabel.js +5 -5
- package/dist/commonjs/form-field/lib/formFieldStencil.js +8 -8
- package/dist/commonjs/icon/lib/AccentIcon.js +2 -2
- package/dist/commonjs/icon/lib/AppletIcon.js +1 -1
- package/dist/commonjs/icon/lib/Graphic.js +2 -2
- package/dist/commonjs/icon/lib/Svg.js +2 -2
- package/dist/commonjs/icon/lib/SystemIcon.js +1 -1
- package/dist/commonjs/icon/lib/SystemIconCircle.js +1 -1
- package/dist/commonjs/loading-dots/lib/LoadingDots.js +3 -3
- package/dist/commonjs/menu/lib/MenuCard.js +1 -1
- package/dist/commonjs/menu/lib/MenuList.js +3 -3
- package/dist/commonjs/modal/lib/ModalBody.js +1 -1
- package/dist/commonjs/modal/lib/ModalCard.js +1 -1
- package/dist/commonjs/modal/lib/ModalHeading.js +1 -1
- package/dist/commonjs/modal/lib/ModalOverflowOverlay.js +1 -1
- package/dist/commonjs/modal/lib/ModalOverlay.js +2 -2
- package/dist/commonjs/popup/lib/PopupBody.js +1 -1
- package/dist/commonjs/popup/lib/PopupCard.js +2 -2
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/commonjs/popup/lib/PopupHeading.js +1 -1
- package/dist/commonjs/select/lib/Select.js +4 -4
- package/dist/commonjs/switch/lib/Switch.js +7 -7
- package/dist/commonjs/table/lib/Table.js +1 -1
- package/dist/commonjs/table/lib/TableBody.js +1 -1
- package/dist/commonjs/table/lib/TableCaption.js +1 -1
- package/dist/commonjs/table/lib/TableCell.js +1 -1
- package/dist/commonjs/table/lib/TableFooter.js +1 -1
- package/dist/commonjs/table/lib/TableHead.js +1 -1
- package/dist/commonjs/table/lib/TableHeader.js +1 -1
- package/dist/commonjs/table/lib/TableRow.js +1 -1
- package/dist/commonjs/text/lib/LabelText.js +6 -6
- package/dist/commonjs/text/lib/Text.js +16 -16
- package/dist/commonjs/text/lib/TypeLevelComponents.js +4 -4
- package/dist/commonjs/text-area/lib/TextArea.d.ts +4 -4
- package/dist/commonjs/text-area/lib/TextArea.js +5 -5
- package/dist/commonjs/text-input/lib/InputGroup.d.ts +58 -31
- package/dist/commonjs/text-input/lib/InputGroup.d.ts.map +1 -1
- package/dist/commonjs/text-input/lib/InputGroup.js +92 -49
- package/dist/commonjs/text-input/lib/TextInput.d.ts +4 -4
- package/dist/commonjs/text-input/lib/TextInput.d.ts.map +1 -1
- package/dist/commonjs/text-input/lib/TextInput.js +8 -6
- package/dist/commonjs/toast/lib/Toast.js +1 -1
- package/dist/commonjs/toast/lib/ToastBody.js +1 -1
- package/dist/commonjs/toast/lib/ToastCloseIcon.js +1 -1
- package/dist/commonjs/toast/lib/ToastIcon.js +1 -1
- package/dist/commonjs/toast/lib/ToastMessage.js +1 -1
- package/dist/es6/avatar/lib/Avatar.js +21 -21
- package/dist/es6/badge/lib/CountBadge.js +3 -3
- package/dist/es6/button/lib/BaseButton.js +21 -21
- package/dist/es6/button/lib/DeleteButton.js +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +2 -2
- package/dist/es6/button/lib/SecondaryButton.js +2 -2
- package/dist/es6/button/lib/TertiaryButton.js +18 -18
- package/dist/es6/card/lib/Card.js +1 -1
- package/dist/es6/card/lib/CardBody.js +1 -1
- package/dist/es6/card/lib/CardHeading.js +1 -1
- package/dist/es6/checkbox/lib/CheckBackground.js +3 -3
- package/dist/es6/checkbox/lib/CheckboxCheck.js +5 -5
- package/dist/es6/checkbox/lib/CheckboxContainer.js +1 -1
- package/dist/es6/checkbox/lib/CheckboxInput.js +5 -5
- package/dist/es6/checkbox/lib/CheckboxRipple.js +1 -1
- package/dist/es6/collection/lib/ListBox.js +4 -4
- package/dist/es6/combobox/lib/ComboboxMenuItem.js +2 -2
- package/dist/es6/combobox/lib/ComboboxMenuList.js +1 -1
- package/dist/es6/common/lib/AccessibleHide.js +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +1 -1
- package/dist/es6/form-field/lib/FormFieldContainer.js +1 -1
- package/dist/es6/form-field/lib/FormFieldField.js +1 -1
- package/dist/es6/form-field/lib/FormFieldGroupLabel.js +5 -5
- package/dist/es6/form-field/lib/FormFieldGroupList.js +3 -3
- package/dist/es6/form-field/lib/FormFieldHint.js +3 -3
- package/dist/es6/form-field/lib/FormFieldLabel.js +5 -5
- package/dist/es6/form-field/lib/formFieldStencil.js +8 -8
- package/dist/es6/icon/lib/AccentIcon.js +2 -2
- package/dist/es6/icon/lib/AppletIcon.js +1 -1
- package/dist/es6/icon/lib/Graphic.js +2 -2
- package/dist/es6/icon/lib/Svg.js +2 -2
- package/dist/es6/icon/lib/SystemIcon.js +1 -1
- package/dist/es6/icon/lib/SystemIconCircle.js +1 -1
- package/dist/es6/loading-dots/lib/LoadingDots.js +3 -3
- package/dist/es6/menu/lib/MenuCard.js +1 -1
- package/dist/es6/menu/lib/MenuList.js +3 -3
- package/dist/es6/modal/lib/ModalBody.js +1 -1
- package/dist/es6/modal/lib/ModalCard.js +1 -1
- package/dist/es6/modal/lib/ModalHeading.js +1 -1
- package/dist/es6/modal/lib/ModalOverflowOverlay.js +1 -1
- package/dist/es6/modal/lib/ModalOverlay.js +2 -2
- package/dist/es6/popup/lib/PopupBody.js +1 -1
- package/dist/es6/popup/lib/PopupCard.js +2 -2
- package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/es6/popup/lib/PopupHeading.js +1 -1
- package/dist/es6/select/lib/Select.js +4 -4
- package/dist/es6/switch/lib/Switch.js +7 -7
- package/dist/es6/table/lib/Table.js +1 -1
- package/dist/es6/table/lib/TableBody.js +1 -1
- package/dist/es6/table/lib/TableCaption.js +1 -1
- package/dist/es6/table/lib/TableCell.js +1 -1
- package/dist/es6/table/lib/TableFooter.js +1 -1
- package/dist/es6/table/lib/TableHead.js +1 -1
- package/dist/es6/table/lib/TableHeader.js +1 -1
- package/dist/es6/table/lib/TableRow.js +1 -1
- package/dist/es6/text/lib/LabelText.js +6 -6
- package/dist/es6/text/lib/Text.js +16 -16
- package/dist/es6/text/lib/TypeLevelComponents.js +4 -4
- package/dist/es6/text-area/lib/TextArea.d.ts +4 -4
- package/dist/es6/text-area/lib/TextArea.js +5 -5
- package/dist/es6/text-input/lib/InputGroup.d.ts +58 -31
- package/dist/es6/text-input/lib/InputGroup.d.ts.map +1 -1
- package/dist/es6/text-input/lib/InputGroup.js +84 -41
- package/dist/es6/text-input/lib/TextInput.d.ts +4 -4
- package/dist/es6/text-input/lib/TextInput.d.ts.map +1 -1
- package/dist/es6/text-input/lib/TextInput.js +8 -6
- package/dist/es6/toast/lib/Toast.js +1 -1
- package/dist/es6/toast/lib/ToastBody.js +1 -1
- package/dist/es6/toast/lib/ToastCloseIcon.js +1 -1
- package/dist/es6/toast/lib/ToastIcon.js +1 -1
- package/dist/es6/toast/lib/ToastMessage.js +1 -1
- package/package.json +4 -4
- package/text-input/lib/InputGroup.tsx +147 -72
- package/text-input/lib/TextInput.tsx +20 -17
|
@@ -7,15 +7,15 @@ export const textInputStencil = createStencil({
|
|
|
7
7
|
vars: {
|
|
8
8
|
width: '',
|
|
9
9
|
},
|
|
10
|
-
base: { name: "
|
|
10
|
+
base: { name: "p7t93u", styles: "box-sizing:border-box;font-family:var(--cnvs-base-font-family-50);font-weight:var(--cnvs-base-font-weight-400);line-height:var(--cnvs-base-line-height-100);font-size:var(--cnvs-base-font-size-75);letter-spacing:var(--cnvs-base-letter-spacing-150);display:block;border:0.0625rem solid var(--cnvs-sys-color-border-input-default);background-color:var(--cnvs-sys-color-bg-default);border-radius:var(--cnvs-sys-shape-x1);height:var(--cnvs-sys-space-x10);transition:0.2s box-shadow, 0.2s border-color;padding:var(--cnvs-sys-space-x2);margin:0rem;width:var(--width-text-input-d81f49);min-width:var(--width-text-input-d81f49, calc(calc(var(--cnvs-sys-space-x20) * 3) + var(--cnvs-sys-space-x10)));color:var(--cnvs-sys-color-text-default);text-overflow:ellipsis;::-ms-clear{display:none;}&::placeholder{color:var(--cnvs-sys-color-text-hint);}&:is(:hover, .hover){border-color:var(--cnvs-sys-color-border-input-strong);}&:is(:focus-visible, .focus):where(:not([disabled])){border-color:var(--cnvs-brand-common-focus-outline);box-shadow:inset 0 0 0 1px var(--cnvs-brand-common-focus-outline);outline:none;}&:is(:disabled, .disabled){background-color:var(--cnvs-sys-color-bg-alt-softer);border-color:var(--cnvs-sys-color-border-input-disabled);color:var(--cnvs-sys-color-text-disabled);&::placeholder{color:var(--cnvs-sys-color-text-disabled);}}" },
|
|
11
11
|
modifiers: {
|
|
12
12
|
grow: {
|
|
13
|
-
true: { name: "
|
|
14
|
-
false: { name: "
|
|
13
|
+
true: { name: "p7t93v", styles: "width:100%;resize:vertical;" },
|
|
14
|
+
false: { name: "p7t93w", styles: "width:initial;" }
|
|
15
15
|
},
|
|
16
16
|
error: {
|
|
17
|
-
error: { name: "
|
|
18
|
-
alert: { name: "
|
|
17
|
+
error: { name: "p7t93x", styles: "border-color:var(--cnvs-brand-error-base);box-shadow:inset 0 0 0 0.0625rem var(--cnvs-brand-error-base);&:is(:hover, .hover, :disabled, .disabled, :focus-visible:not([disabled]), .focus:not([disabled])){border-color:var(--cnvs-brand-error-base);}&:is(:focus-visible, .focus):not([disabled]){box-shadow:inset 0 0 0 0.0625rem var(--cnvs-brand-error-base), 0 0 0 2px var(--cnvs-sys-color-border-inverse), 0 0 0 4px var(--cnvs-brand-common-focus-outline);}" },
|
|
18
|
+
alert: { name: "p7t93y", styles: "border-color:var(--cnvs-brand-alert-darkest);box-shadow:inset 0 0 0 0.125rem var(--cnvs-brand-alert-base);&:is(:hover, .hover, :disabled, .disabled, :focus-visible:not([disabled]), .focus:not([disabled])){border-color:var(--cnvs-brand-alert-darkest);}&:is(:focus-visible, .focus):not([disabled]){box-shadow:inset 0 0 0 0.125rem var(--cnvs-brand-alert-base),\n 0 0 0 2px var(--cnvs-sys-color-border-inverse),\n 0 0 0 4px var(--cnvs-brand-common-focus-outline);}" }
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
defaultModifiers: {
|
|
@@ -24,7 +24,9 @@ export const textInputStencil = createStencil({
|
|
|
24
24
|
}, "text-input-d81f49");
|
|
25
25
|
export const TextInput = createComponent('input')({
|
|
26
26
|
displayName: 'TextInput',
|
|
27
|
-
Component: ({ grow, error, width, ...elemProps }, ref, Element) =>
|
|
27
|
+
Component: ({ grow, error, width, ...elemProps }, ref, Element) => {
|
|
28
|
+
return (React.createElement(Element, { type: "text", ref: ref, ...mergeStyles(elemProps, textInputStencil({ width: typeof width === 'number' ? px2rem(width) : width, grow, error })) }));
|
|
29
|
+
},
|
|
28
30
|
subComponents: {
|
|
29
31
|
ErrorType,
|
|
30
32
|
},
|
|
@@ -42,7 +42,7 @@ const getAriaAttributes = (mode, id) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
const toastStencil = createStencil({
|
|
45
|
-
base: { name: "
|
|
45
|
+
base: { name: "p7t95z", styles: "box-sizing:border-box;display:flex;flex-direction:row;width:calc(calc(var(--cnvs-sys-space-x20) * 4) + var(--cnvs-sys-space-x10));padding:var(--cnvs-sys-space-zero);gap:var(--cnvs-sys-space-x1);" }
|
|
46
46
|
}, "toast-55513d");
|
|
47
47
|
/**
|
|
48
48
|
* Toast is a compound component that has different modes based on its contents. The modes add the proper aria attributes for accessibility
|
|
@@ -4,7 +4,7 @@ import { Flex, mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
|
4
4
|
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
5
|
import { system } from '@workday/canvas-tokens-web';
|
|
6
6
|
export const toastBodyStencil = createStencil({
|
|
7
|
-
base: { name: "
|
|
7
|
+
base: { name: "p7t95y", styles: "box-sizing:border-box;align-items:flex-start;flex-direction:column;justify-content:center;padding-top:var(--cnvs-sys-space-x4);padding-bottom:var(--cnvs-sys-space-x4);flex-grow:1;gap:var(--cnvs-sys-space-x1);" }
|
|
8
8
|
}, "toast-body-7d81ac");
|
|
9
9
|
export const ToastBody = createComponent('div')({
|
|
10
10
|
displayName: 'Toast.Body',
|
|
@@ -4,7 +4,7 @@ import { Popup } from '@workday/canvas-kit-react/popup';
|
|
|
4
4
|
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
5
|
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
6
6
|
export const toastCloseIconStencil = createStencil({
|
|
7
|
-
base: { name: "
|
|
7
|
+
base: { name: "p7t95v", styles: "box-sizing:border-box;position:relative;" }
|
|
8
8
|
}, "toast-close-icon-be7e9f");
|
|
9
9
|
export const ToastCloseIcon = createComponent('button')({
|
|
10
10
|
displayName: 'Toast.CloseIcon',
|
|
@@ -4,7 +4,7 @@ import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
|
4
4
|
import { createStencil, handleCsProp } from '@workday/canvas-kit-styling';
|
|
5
5
|
import { system } from '@workday/canvas-tokens-web';
|
|
6
6
|
export const toastIconStencil = createStencil({
|
|
7
|
-
base: { name: "
|
|
7
|
+
base: { name: "p7t95w", styles: "box-sizing:border-box;align-self:start;margin:var(--cnvs-sys-space-x4) var(--cnvs-sys-space-x3);" }
|
|
8
8
|
}, "toast-icon-4b0701");
|
|
9
9
|
export const ToastIcon = createComponent('div')({
|
|
10
10
|
displayName: 'Toast.Icon',
|
|
@@ -6,7 +6,7 @@ import { createStencil } from '@workday/canvas-kit-styling';
|
|
|
6
6
|
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
7
7
|
import { system } from '@workday/canvas-tokens-web';
|
|
8
8
|
export const toastMessageStencil = createStencil({
|
|
9
|
-
base: { name: "
|
|
9
|
+
base: { name: "p7t95x", styles: "box-sizing:border-box;word-break:break-word;margin-block-start:var(--cnvs-sys-space-zero);margin-block-end:var(--cnvs-sys-space-zero);" }
|
|
10
10
|
}, "toast-message-759382");
|
|
11
11
|
export const ToastMessage = createSubcomponent('p')({
|
|
12
12
|
modelHook: useToastModel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.903-next.0",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@emotion/styled": "^11.6.0",
|
|
50
50
|
"@popperjs/core": "^2.5.4",
|
|
51
51
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
52
|
-
"@workday/canvas-kit-popup-stack": "^12.0.0-alpha.
|
|
53
|
-
"@workday/canvas-kit-styling": "^12.0.0-alpha.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^12.0.0-alpha.903-next.0",
|
|
53
|
+
"@workday/canvas-kit-styling": "^12.0.0-alpha.903-next.0",
|
|
54
54
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
55
55
|
"@workday/canvas-tokens-web": "^2.0.1",
|
|
56
56
|
"@workday/design-assets-types": "^0.2.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
68
68
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "06b35f786069a81a2aba5fbd42b46ec88857e5a8"
|
|
71
71
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {maybeWrapCSSVariables} from '@workday/canvas-kit-styling';
|
|
3
|
+
import {createStencil, handleCsProp, maybeWrapCSSVariables} from '@workday/canvas-kit-styling';
|
|
4
4
|
import {system} from '@workday/canvas-tokens-web';
|
|
5
5
|
import {
|
|
6
6
|
createContainer,
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
dispatchInputEvent,
|
|
11
11
|
ExtractProps,
|
|
12
12
|
useForkRef,
|
|
13
|
-
useIsRTL,
|
|
14
13
|
} from '@workday/canvas-kit-react/common';
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
import {Flex, mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
16
16
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
17
17
|
import {xSmallIcon} from '@workday/canvas-system-icons-web';
|
|
18
18
|
|
|
@@ -29,39 +29,85 @@ export const useInputGroupModel = createModelHook({})(() => {
|
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
export const inputGroupInnerStencil = createStencil({
|
|
33
|
+
vars: {
|
|
34
|
+
/**
|
|
35
|
+
* Offset of the inner item. Set by the `InputGroup` and depends on siblings. Do not change this
|
|
36
|
+
* on your own.
|
|
37
|
+
*/
|
|
38
|
+
insetInlineStart: 'initial',
|
|
39
|
+
/**
|
|
40
|
+
* Offset of the inner item. Set by the `InputGroup` and depends on siblings. Do not change this
|
|
41
|
+
* on your own.
|
|
42
|
+
*/
|
|
43
|
+
insetInlineEnd: 'initial',
|
|
44
|
+
width: system.space.x10,
|
|
45
|
+
height: system.space.x10,
|
|
46
|
+
/**
|
|
47
|
+
* Some inner input group elements are decoration only and should not have pointer events
|
|
48
|
+
*/
|
|
49
|
+
pointerEvents: '',
|
|
50
|
+
},
|
|
51
|
+
base: ({width, height, insetInlineStart, insetInlineEnd}) => ({
|
|
52
|
+
display: 'flex',
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
insetInlineStart,
|
|
59
|
+
insetInlineEnd,
|
|
60
|
+
}),
|
|
61
|
+
modifiers: {
|
|
62
|
+
pointerEvents: {
|
|
63
|
+
_: ({pointerEvents}) => ({pointerEvents}),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
46
66
|
});
|
|
47
67
|
|
|
48
|
-
|
|
68
|
+
const InputGroupInnerStart = createSubcomponent('div')({
|
|
49
69
|
modelHook: useInputGroupModel,
|
|
50
|
-
})<ExtractProps<typeof Flex, never>>(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
70
|
+
})<ExtractProps<typeof Flex, never>>(
|
|
71
|
+
({pointerEvents, insetInlineStart, insetInlineEnd, width, height, ...elemProps}, Element) => {
|
|
72
|
+
return (
|
|
73
|
+
<Element
|
|
74
|
+
{...mergeStyles(
|
|
75
|
+
elemProps,
|
|
76
|
+
inputGroupInnerStencil({
|
|
77
|
+
pointerEvents,
|
|
78
|
+
insetInlineStart: toPx(insetInlineStart),
|
|
79
|
+
insetInlineEnd: toPx(insetInlineEnd),
|
|
80
|
+
width: toPx(width),
|
|
81
|
+
height: toPx(height),
|
|
82
|
+
})
|
|
83
|
+
)}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
63
88
|
|
|
64
|
-
const
|
|
89
|
+
const InputGroupInnerEnd = createSubcomponent('div')({
|
|
90
|
+
modelHook: useInputGroupModel,
|
|
91
|
+
})<ExtractProps<typeof Flex, never>>(
|
|
92
|
+
({pointerEvents, insetInlineStart, insetInlineEnd, width, height, ...elemProps}, Element) => {
|
|
93
|
+
return (
|
|
94
|
+
<Element
|
|
95
|
+
{...mergeStyles(
|
|
96
|
+
elemProps,
|
|
97
|
+
inputGroupInnerStencil({
|
|
98
|
+
pointerEvents,
|
|
99
|
+
insetInlineStart: insetInlineStart as string,
|
|
100
|
+
insetInlineEnd: insetInlineEnd as string,
|
|
101
|
+
width: toPx(width),
|
|
102
|
+
height: toPx(height),
|
|
103
|
+
})
|
|
104
|
+
)}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
export const useInputGroupInput = createElemPropsHook(useInputGroupModel)((model, ref) => {
|
|
65
111
|
const elementRef = useForkRef(ref, model.state.inputRef);
|
|
66
112
|
|
|
67
113
|
return {
|
|
@@ -69,26 +115,46 @@ const useInputGroupInput = createElemPropsHook(useInputGroupModel)((model, ref)
|
|
|
69
115
|
};
|
|
70
116
|
});
|
|
71
117
|
|
|
72
|
-
export const
|
|
118
|
+
export const inputGroupInputStencil = createStencil({
|
|
119
|
+
vars: {
|
|
120
|
+
paddingInlineStart: '',
|
|
121
|
+
paddingInlineEnd: '',
|
|
122
|
+
},
|
|
123
|
+
base: {
|
|
124
|
+
display: 'flex',
|
|
125
|
+
width: '100%',
|
|
126
|
+
},
|
|
127
|
+
modifiers: {
|
|
128
|
+
paddingInlineStart: {
|
|
129
|
+
_: ({paddingInlineStart}) => ({paddingInlineStart}),
|
|
130
|
+
},
|
|
131
|
+
paddingInlineEnd: {
|
|
132
|
+
_: ({paddingInlineEnd}) => ({paddingInlineEnd}),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const InputGroupInput = createSubcomponent(TextInput)({
|
|
73
138
|
modelHook: useInputGroupModel,
|
|
74
139
|
elemPropsHook: useInputGroupInput,
|
|
75
|
-
})<ExtractProps<typeof Flex, never>>(
|
|
76
|
-
|
|
77
|
-
|
|
140
|
+
})<ExtractProps<typeof Flex, never>>(
|
|
141
|
+
({paddingInlineStart, paddingInlineEnd, ...elemProps}, Element) => {
|
|
142
|
+
return (
|
|
143
|
+
<Element
|
|
144
|
+
as={Element}
|
|
145
|
+
{...mergeStyles(
|
|
146
|
+
elemProps,
|
|
147
|
+
inputGroupInputStencil({
|
|
148
|
+
paddingInlineStart: toPx(paddingInlineStart),
|
|
149
|
+
paddingInlineEnd: toPx(paddingInlineEnd),
|
|
150
|
+
})
|
|
151
|
+
)}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
);
|
|
78
156
|
|
|
79
157
|
export const useClearButton = createElemPropsHook(useInputGroupModel)(model => {
|
|
80
|
-
const [inputHasValue, setInputHasValue] = React.useState(false);
|
|
81
|
-
|
|
82
|
-
React.useLayoutEffect(() => {
|
|
83
|
-
const input = model.state.inputRef.current;
|
|
84
|
-
|
|
85
|
-
if (input) {
|
|
86
|
-
input.addEventListener('input', () => {
|
|
87
|
-
setInputHasValue(!!input.value);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}, [model.state.inputRef]);
|
|
91
|
-
|
|
92
158
|
return {
|
|
93
159
|
// This element does not need to be accessible via screen reader. The user can already clear
|
|
94
160
|
// an input
|
|
@@ -98,7 +164,6 @@ export const useClearButton = createElemPropsHook(useInputGroupModel)(model => {
|
|
|
98
164
|
icon: xSmallIcon,
|
|
99
165
|
// "small" is needed to render correctly within a `TextInput`
|
|
100
166
|
size: 'small',
|
|
101
|
-
transition: 'opacity 300ms ease',
|
|
102
167
|
// prevent a focus change to the button. Focus should stay in the input.
|
|
103
168
|
onMouseDown(event: React.MouseEvent) {
|
|
104
169
|
event.preventDefault();
|
|
@@ -107,25 +172,22 @@ export const useClearButton = createElemPropsHook(useInputGroupModel)(model => {
|
|
|
107
172
|
// This will clear the input's value
|
|
108
173
|
dispatchInputEvent(model.state.inputRef.current, '');
|
|
109
174
|
},
|
|
110
|
-
|
|
111
|
-
opacity: inputHasValue ? 1 : 0,
|
|
112
|
-
pointerEvents: inputHasValue ? 'auto' : 'none',
|
|
113
|
-
},
|
|
175
|
+
placeholder: '', // Make sure a placeholder attribute always exists for `:placeholder-shown`
|
|
114
176
|
} as const;
|
|
115
177
|
});
|
|
116
178
|
|
|
117
179
|
/**
|
|
118
180
|
* A clear input button. This can be a component later.
|
|
119
181
|
*/
|
|
120
|
-
|
|
182
|
+
const ClearButton = createSubcomponent(TertiaryButton)({
|
|
121
183
|
modelHook: useInputGroupModel,
|
|
122
184
|
elemPropsHook: useClearButton,
|
|
123
185
|
})<ExtractProps<typeof TertiaryButton, never>>((elemProps, Element) => {
|
|
124
|
-
return <Element {...elemProps} />;
|
|
186
|
+
return <Element data-part="input-group-clear-button" {...handleCsProp(elemProps)} />;
|
|
125
187
|
});
|
|
126
188
|
|
|
127
189
|
// make sure we always use pixels if the input is a number - this is required for `calc`
|
|
128
|
-
const toPx = (input: string | number): string => {
|
|
190
|
+
const toPx = (input: string | number | undefined): string | undefined => {
|
|
129
191
|
return typeof input === 'number' ? `${input}px` : input;
|
|
130
192
|
};
|
|
131
193
|
|
|
@@ -141,6 +203,26 @@ const wrapInCalc = (values: (string | number)[]): string | number | undefined =>
|
|
|
141
203
|
return `calc(${values.map(toPx).join(' + ')})`;
|
|
142
204
|
};
|
|
143
205
|
|
|
206
|
+
export const inputGroupStencil = createStencil({
|
|
207
|
+
base: {
|
|
208
|
+
display: 'flex',
|
|
209
|
+
position: 'relative',
|
|
210
|
+
|
|
211
|
+
// Clear Button
|
|
212
|
+
'& :has([data-part="input-group-clear-button"])': {
|
|
213
|
+
transition: 'opacity 300ms ease',
|
|
214
|
+
opacity: 1,
|
|
215
|
+
pointerEvents: 'auto',
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
// Clear Button when a placeholder is being shown (no value)
|
|
219
|
+
'&:where(:has(input:placeholder-shown)) :has([data-part="input-group-clear-button"])': {
|
|
220
|
+
opacity: 0,
|
|
221
|
+
pointerEvents: 'none',
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
|
|
144
226
|
/**
|
|
145
227
|
* An `InputGroup` is a container around a {@link TextInput} with optional inner start and end
|
|
146
228
|
* elements. The inner start and end elements are usually icons or icon buttons visually represented
|
|
@@ -167,7 +249,7 @@ export const InputGroup = createContainer('div')({
|
|
|
167
249
|
subComponents: {
|
|
168
250
|
/**
|
|
169
251
|
* A component to show inside and at the start of the input. The input's padding will be
|
|
170
|
-
* adjusted to not overlap with this element. Use `width`
|
|
252
|
+
* adjusted by the `InputGroup` to not overlap with this element. Use `width` to adjust the
|
|
171
253
|
* width offset. The width defaults to 40px which is the correct width for icons or icon
|
|
172
254
|
* buttons.
|
|
173
255
|
*/
|
|
@@ -179,9 +261,9 @@ export const InputGroup = createContainer('div')({
|
|
|
179
261
|
Input: InputGroupInput,
|
|
180
262
|
/**
|
|
181
263
|
* A component to show inside and at the end of the input. The input's padding will be adjusted
|
|
182
|
-
* to not overlap with this element. Use `width`
|
|
183
|
-
*
|
|
184
|
-
*
|
|
264
|
+
* by the `InputGroup` to not overlap with this element. Use `width` to adjust the width offset.
|
|
265
|
+
* The width defaults to 40px which is the correct width for icons or icon buttons within the
|
|
266
|
+
* input.
|
|
185
267
|
*/
|
|
186
268
|
InnerEnd: InputGroupInnerEnd,
|
|
187
269
|
/**
|
|
@@ -191,7 +273,6 @@ export const InputGroup = createContainer('div')({
|
|
|
191
273
|
ClearButton: ClearButton,
|
|
192
274
|
},
|
|
193
275
|
})<ExtractProps<typeof Flex, never>>(({children, ...elemProps}, Element) => {
|
|
194
|
-
const isRTL = useIsRTL();
|
|
195
276
|
const offsetsStart: (string | number)[] = [];
|
|
196
277
|
const offsetsEnd: (string | number)[] = [];
|
|
197
278
|
|
|
@@ -222,30 +303,24 @@ export const InputGroup = createContainer('div')({
|
|
|
222
303
|
});
|
|
223
304
|
}
|
|
224
305
|
if (child.type === InputGroupInnerStart) {
|
|
225
|
-
const offset = wrapInCalc(offsetsStart.slice(0, indexStart)) ||
|
|
306
|
+
const offset = wrapInCalc(offsetsStart.slice(0, indexStart)) || '0px';
|
|
226
307
|
indexStart++;
|
|
227
308
|
|
|
228
309
|
return React.cloneElement(child, {
|
|
229
|
-
|
|
230
|
-
right: isRTL ? offset : undefined,
|
|
310
|
+
insetInlineStart: offset,
|
|
231
311
|
});
|
|
232
312
|
}
|
|
233
313
|
if (child.type === InputGroupInnerEnd) {
|
|
234
|
-
const offset = wrapInCalc(offsetsEnd.slice(indexEnd, -1)) ||
|
|
314
|
+
const offset = wrapInCalc(offsetsEnd.slice(indexEnd, -1)) || '0px';
|
|
235
315
|
indexEnd++;
|
|
236
316
|
|
|
237
317
|
return React.cloneElement(child, {
|
|
238
|
-
|
|
239
|
-
right: isRTL ? undefined : offset,
|
|
318
|
+
insetInlineEnd: offset,
|
|
240
319
|
});
|
|
241
320
|
}
|
|
242
321
|
}
|
|
243
322
|
return child;
|
|
244
323
|
});
|
|
245
324
|
|
|
246
|
-
return (
|
|
247
|
-
<Flex as={Element} position="relative" {...elemProps}>
|
|
248
|
-
{mappedChildren}
|
|
249
|
-
</Flex>
|
|
250
|
-
);
|
|
325
|
+
return <Element {...mergeStyles(elemProps, inputGroupStencil())}>{mappedChildren}</Element>;
|
|
251
326
|
});
|
|
@@ -33,21 +33,22 @@ export const textInputStencil = createStencil({
|
|
|
33
33
|
width: cssVar(width),
|
|
34
34
|
minWidth: cssVar(width, calc.add(calc.multiply(system.space.x20, 3), system.space.x10)),
|
|
35
35
|
color: system.color.text.default,
|
|
36
|
+
textOverflow: 'ellipsis',
|
|
36
37
|
'::-ms-clear': {
|
|
37
38
|
display: 'none',
|
|
38
39
|
},
|
|
39
40
|
'&::placeholder': {
|
|
40
41
|
color: system.color.text.hint,
|
|
41
42
|
},
|
|
42
|
-
'&:hover,
|
|
43
|
+
'&:is(:hover, .hover)': {
|
|
43
44
|
borderColor: system.color.border.input.strong,
|
|
44
45
|
},
|
|
45
|
-
'&:focus-visible
|
|
46
|
+
'&:is(:focus-visible, .focus):where(:not([disabled]))': {
|
|
46
47
|
borderColor: brand.common.focusOutline,
|
|
47
48
|
boxShadow: `inset 0 0 0 1px ${cssVar(brand.common.focusOutline)}`,
|
|
48
49
|
outline: 'none',
|
|
49
50
|
},
|
|
50
|
-
'&:disabled, .disabled': {
|
|
51
|
+
'&:is(:disabled, .disabled)': {
|
|
51
52
|
backgroundColor: system.color.bg.alt.softer,
|
|
52
53
|
borderColor: system.color.border.input.disabled,
|
|
53
54
|
color: system.color.text.disabled,
|
|
@@ -71,11 +72,11 @@ export const textInputStencil = createStencil({
|
|
|
71
72
|
error: {
|
|
72
73
|
borderColor: brand.error.base,
|
|
73
74
|
boxShadow: `inset 0 0 0 ${px2rem(1)} ${brand.error.base}`,
|
|
74
|
-
'&:hover,
|
|
75
|
+
'&:is(:hover, .hover, :disabled, .disabled, :focus-visible:not([disabled]), .focus:not([disabled]))':
|
|
75
76
|
{
|
|
76
77
|
borderColor: brand.error.base,
|
|
77
78
|
},
|
|
78
|
-
'&:focus-visible
|
|
79
|
+
'&:is(:focus-visible, .focus):not([disabled])': {
|
|
79
80
|
boxShadow: `inset 0 0 0 ${px2rem(1)} ${brand.error.base}, 0 0 0 2px ${
|
|
80
81
|
system.color.border.inverse
|
|
81
82
|
}, 0 0 0 4px ${brand.common.focusOutline}`,
|
|
@@ -84,12 +85,12 @@ export const textInputStencil = createStencil({
|
|
|
84
85
|
alert: {
|
|
85
86
|
borderColor: brand.alert.darkest,
|
|
86
87
|
boxShadow: `inset 0 0 0 ${px2rem(2)} ${brand.alert.base}`,
|
|
87
|
-
'&:hover,
|
|
88
|
+
'&:is(:hover, .hover, :disabled, .disabled, :focus-visible:not([disabled]), .focus:not([disabled]))':
|
|
88
89
|
{
|
|
89
90
|
borderColor: brand.alert.darkest,
|
|
90
91
|
},
|
|
91
92
|
|
|
92
|
-
'&:focus-visible
|
|
93
|
+
'&:is(:focus-visible, .focus):not([disabled])': {
|
|
93
94
|
boxShadow: `inset 0 0 0 ${px2rem(2)} ${brand.alert.base},
|
|
94
95
|
0 0 0 2px ${system.color.border.inverse},
|
|
95
96
|
0 0 0 4px ${brand.common.focusOutline}`,
|
|
@@ -104,16 +105,18 @@ export const textInputStencil = createStencil({
|
|
|
104
105
|
|
|
105
106
|
export const TextInput = createComponent('input')({
|
|
106
107
|
displayName: 'TextInput',
|
|
107
|
-
Component: ({grow, error, width, ...elemProps}: TextInputProps, ref, Element) =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
Component: ({grow, error, width, ...elemProps}: TextInputProps, ref, Element) => {
|
|
109
|
+
return (
|
|
110
|
+
<Element
|
|
111
|
+
type="text"
|
|
112
|
+
ref={ref}
|
|
113
|
+
{...mergeStyles(
|
|
114
|
+
elemProps,
|
|
115
|
+
textInputStencil({width: typeof width === 'number' ? px2rem(width) : width, grow, error})
|
|
116
|
+
)}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
},
|
|
117
120
|
subComponents: {
|
|
118
121
|
ErrorType,
|
|
119
122
|
},
|