@workday/canvas-kit-react 12.0.0-alpha.852-next.0 → 12.0.0-alpha.862-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.
@@ -1,57 +1,29 @@
1
1
  import * as React from 'react';
2
- import { createComponent, ErrorType, errorRing, styled, } from '@workday/canvas-kit-react/common';
3
- import { borderRadius, inputColors, space, type } from '@workday/canvas-kit-react/tokens';
4
- const StyledTextInput = styled('input')({
5
- ...type.levels.subtext.large,
6
- border: `1px solid ${inputColors.border}`,
7
- display: 'block',
8
- backgroundColor: inputColors.background,
9
- borderRadius: borderRadius.m,
10
- boxSizing: 'border-box',
11
- height: 40,
12
- transition: '0.2s box-shadow, 0.2s border-color',
13
- padding: space.xxs,
14
- margin: 0,
15
- '&::placeholder': {
16
- color: inputColors.placeholder,
2
+ import { createComponent, ErrorType } from '@workday/canvas-kit-react/common';
3
+ import { createStencil, cssVar, px2rem, calc, handleCsProp } from '@workday/canvas-kit-styling';
4
+ import { brand, system } from '@workday/canvas-tokens-web';
5
+ export const textInputStencil = createStencil({
6
+ vars: {
7
+ width: '',
17
8
  },
18
- '&:hover, &.hover': {
19
- borderColor: inputColors.hoverBorder,
20
- },
21
- '&:focus-visible:not([disabled]), &.focus:not([disabled]), &:focus:not([disabled])': {
22
- borderColor: inputColors.focusBorder,
23
- boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
24
- outline: 'none',
25
- },
26
- '&:disabled': {
27
- backgroundColor: inputColors.disabled.background,
28
- borderColor: inputColors.disabled.border,
29
- color: inputColors.disabled.text,
30
- '&::placeholder': {
31
- color: inputColors.disabled.text,
9
+ base: { name: "edcc19", 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-ac8e50);min-width:var(--width-text-input-ac8e50, calc(calc(var(--cnvs-sys-space-x20) * 3) + var(--cnvs-sys-space-x10)));color:var(--cnvs-sys-color-text-default);::-ms-clear{display:none;}&::placeholder{color:var(--cnvs-sys-color-text-hint);}&:hover, &.hover{border-color:var(--cnvs-sys-color-border-input-strong);}&:focus-visible:not([disabled]), &.focus: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;}&: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);}}" },
10
+ modifiers: {
11
+ grow: {
12
+ true: { name: "6c63b7", styles: "width:100%;resize:vertical;" },
13
+ false: { name: "ba7d2f", styles: "width:initial;" }
32
14
  },
15
+ error: {
16
+ error: { name: "a75f3c", styles: "border-color:var(--cnvs-brand-error-base);box-shadow:inset 0 0 0 0.0625rem var(--cnvs-brand-error-base);&:hover, &.hover, &:disabled, &.disabled, &:focus-visible:not([disabled]), &.focus:not([disabled]){border-color:var(--cnvs-brand-error-base);}&:focus-visible:not([disabled]), &.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);}" },
17
+ alert: { name: "277895", styles: "border-color:var(--cnvs-brand-alert-darkest);box-shadow:inset 0 0 0 0.125rem var(--cnvs-brand-alert-base);&:hover, &.hover, &:disabled, &.disabled, &:focus-visible:not([disabled]), &.focus:not([disabled]){border-color:var(--cnvs-brand-alert-darkest);}&:focus-visible:not([disabled]), &.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);}" }
18
+ }
33
19
  },
34
- '::-ms-clear': {
35
- display: 'none',
36
- },
37
- }, ({ width }) => ({
38
- minWidth: width || 280,
39
- width,
40
- }), ({ grow }) => grow && {
41
- width: '100%',
42
- }, ({ theme, error }) => {
43
- return {
44
- '&:focus-visible:not([disabled]), &.focus:not([disabled])': {
45
- borderColor: theme.canvas.palette.common.focusOutline,
46
- boxShadow: `inset 0 0 0 1px ${theme.canvas.palette.common.focusOutline}`,
47
- outline: 'none',
48
- },
49
- ...errorRing(error, theme),
50
- };
51
- });
20
+ defaultModifiers: {
21
+ grow: 'false',
22
+ }
23
+ }, "text-input-ac8e50");
52
24
  export const TextInput = createComponent('input')({
53
25
  displayName: 'TextInput',
54
- Component: ({ grow, error, width, ...elemProps }, ref, Element) => (React.createElement(StyledTextInput, Object.assign({ type: "text", ref: ref, as: Element, grow: grow, error: error, width: width }, elemProps))),
26
+ Component: ({ grow, error, width, ...elemProps }, ref, Element) => (React.createElement(Element, Object.assign({ type: "text", ref: ref }, handleCsProp(elemProps, textInputStencil({ width: typeof width === 'number' ? px2rem(width) : width, grow, error }))))),
55
27
  subComponents: {
56
28
  ErrorType,
57
29
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "12.0.0-alpha.852-next.0",
3
+ "version": "12.0.0-alpha.862-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.852-next.0",
53
- "@workday/canvas-kit-styling": "^12.0.0-alpha.852-next.0",
52
+ "@workday/canvas-kit-popup-stack": "^12.0.0-alpha.862-next.0",
53
+ "@workday/canvas-kit-styling": "^12.0.0-alpha.862-next.0",
54
54
  "@workday/canvas-system-icons-web": "^3.0.0",
55
55
  "@workday/canvas-tokens-web": "^2.0.0",
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": "bbd7343aec2a6657b8eff4981a7aa4a6e47af161"
70
+ "gitHead": "3b7726adda5b24aff4229e4ee8ca9f4f83522be3"
71
71
  }
@@ -1,107 +1,67 @@
1
1
  import * as React from 'react';
2
- import {
3
- createComponent,
4
- StyledType,
5
- GrowthBehavior,
6
- ErrorType,
7
- errorRing,
8
- styled,
9
- Themeable,
10
- } from '@workday/canvas-kit-react/common';
11
- import {borderRadius, inputColors, space, type} from '@workday/canvas-kit-react/tokens';
2
+ import {createComponent, GrowthBehavior, ErrorType} from '@workday/canvas-kit-react/common';
3
+ import {createStencil, calc, handleCsProp} from '@workday/canvas-kit-styling';
4
+ import {system} from '@workday/canvas-tokens-web';
5
+ import {textInputStencil} from '@workday/canvas-kit-react/text-input';
6
+ export type ValueOf<T> = T[keyof T];
12
7
 
13
- export interface TextAreaProps extends Themeable, GrowthBehavior {
14
- /**
15
- * If true, set the TextArea to the disabled state.
16
- * @default false
17
- */
18
- disabled?: boolean;
8
+ export interface TextAreaProps extends GrowthBehavior {
19
9
  /**
20
10
  * The type of error associated with the TextArea (if applicable).
21
11
  */
22
12
  error?: ErrorType;
23
- /**
24
- * The function called when the TextArea state changes.
25
- */
26
- onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
27
- /**
28
- * The placeholder text of the TextArea.
29
- */
30
- placeholder?: string;
31
- /**
32
- * If true, set the TextArea to read-only. The user will be unable to interact with the TextArea.
33
- * @default false
34
- */
35
- readOnly?: boolean;
36
13
  /**
37
14
  * The resize constraints of the TextArea.
38
15
  * @default TextArea.ResizeDirection.Both
39
16
  */
40
- resize?: TextAreaResizeDirection;
41
- /**
42
- * The value of the TextArea.
43
- */
44
- value?: any;
17
+ resize?: ValueOf<typeof TextAreaResizeDirection>;
45
18
  }
46
19
 
47
- export enum TextAreaResizeDirection {
48
- None = 'none',
49
- Both = 'both',
50
- Horizontal = 'horizontal',
51
- Vertical = 'vertical',
52
- }
20
+ export const TextAreaResizeDirection = {
21
+ None: 'none',
22
+ Both: 'both',
23
+ Horizontal: 'horizontal',
24
+ Vertical: 'vertical',
25
+ } as const;
53
26
 
54
- const StyledTextArea = styled('textarea')<TextAreaProps & StyledType>(
55
- ({theme, error}) => ({
56
- ...type.levels.subtext.large,
57
- border: `1px solid ${inputColors.border}`,
58
- display: 'block',
59
- backgroundColor: inputColors.background,
60
- borderRadius: borderRadius.m,
61
- boxSizing: 'border-box',
62
- minHeight: space.xxl,
63
- minWidth: `calc((${space.xxxl} * 3) + ${space.xl})`,
64
- transition: '0.2s box-shadow, 0.2s border-color',
65
- padding: space.xxs, // Compensate for border
66
- margin: 0, // Fix Safari
27
+ export const textAreaStencil = createStencil({
28
+ extends: textInputStencil,
29
+ base: {
30
+ minHeight: system.space.x16,
31
+ minWidth: calc.add(calc.multiply(system.space.x20, 3), system.space.x10),
67
32
  '&::webkit-resizer': {
68
33
  display: 'none',
69
34
  },
70
- '&::placeholder': {
71
- color: inputColors.placeholder,
72
- },
73
- '&:hover': {
74
- borderColor: inputColors.hoverBorder,
75
- },
76
- '&:focus:not([disabled])': {
77
- borderColor: theme.canvas.palette.common.focusOutline,
78
- boxShadow: `inset 0 0 0 1px ${theme.canvas.palette.common.focusOutline}`,
79
- outline: 'none',
80
- },
81
- '&:disabled': {
82
- backgroundColor: inputColors.disabled.background,
83
- borderColor: inputColors.disabled.border,
84
- color: inputColors.disabled.text,
85
- '&::placeholder': {
86
- color: inputColors.disabled.text,
35
+ },
36
+
37
+ modifiers: {
38
+ resize: {
39
+ both: {
40
+ resize: 'both',
41
+ },
42
+ horizontal: {
43
+ resize: 'horizontal',
44
+ },
45
+ vertical: {
46
+ resize: 'vertical',
47
+ },
48
+ none: {
49
+ resize: 'none',
87
50
  },
88
51
  },
89
- ...errorRing(error, theme),
90
- }),
91
-
92
- ({resize, grow}) => ({
93
- width: grow ? '100%' : undefined,
94
- resize: grow ? TextAreaResizeDirection.Vertical : resize,
95
- })
96
- );
52
+ },
53
+ defaultModifiers: {
54
+ resize: 'both',
55
+ },
56
+ });
97
57
 
98
58
  export const TextArea = createComponent('textarea')({
99
59
  displayName: 'TextArea',
100
60
  Component: (
101
- {resize = TextAreaResizeDirection.Both, grow, ...elemProps}: TextAreaProps,
61
+ {resize = TextAreaResizeDirection.Both, grow, error, ...elemProps}: TextAreaProps,
102
62
  ref,
103
63
  Element
104
- ) => <StyledTextArea ref={ref} as={Element} grow={grow} resize={resize} {...elemProps} />,
64
+ ) => <Element ref={ref} {...handleCsProp(elemProps, textAreaStencil({error, grow, resize}))} />,
105
65
  subComponents: {
106
66
  ErrorType,
107
67
  ResizeDirection: TextAreaResizeDirection,
@@ -1,16 +1,9 @@
1
1
  import * as React from 'react';
2
- import {
3
- createComponent,
4
- StyledType,
5
- GrowthBehavior,
6
- ErrorType,
7
- errorRing,
8
- styled,
9
- Themeable,
10
- } from '@workday/canvas-kit-react/common';
11
- import {borderRadius, inputColors, space, type} from '@workday/canvas-kit-react/tokens';
2
+ import {createComponent, GrowthBehavior, ErrorType} from '@workday/canvas-kit-react/common';
3
+ import {createStencil, cssVar, px2rem, calc, handleCsProp} from '@workday/canvas-kit-styling';
4
+ import {brand, system} from '@workday/canvas-tokens-web';
12
5
 
13
- export interface TextInputProps extends Themeable, GrowthBehavior {
6
+ export interface TextInputProps extends GrowthBehavior {
14
7
  /**
15
8
  * The type of error associated with the TextInput (if applicable).
16
9
  */
@@ -21,74 +14,103 @@ export interface TextInputProps extends Themeable, GrowthBehavior {
21
14
  width?: number | string;
22
15
  }
23
16
 
24
- const StyledTextInput = styled('input')<
25
- Pick<TextInputProps, 'error' | 'grow' | 'width' | 'theme'> & StyledType
26
- >(
27
- {
28
- ...type.levels.subtext.large,
29
- border: `1px solid ${inputColors.border}`,
17
+ export const textInputStencil = createStencil({
18
+ vars: {
19
+ width: '',
20
+ },
21
+ base: ({width}) => ({
22
+ ...system.type.subtext.large,
30
23
  display: 'block',
31
- backgroundColor: inputColors.background,
32
- borderRadius: borderRadius.m,
24
+ border: `${px2rem(1)} solid ${cssVar(system.color.border.input.default)}`,
25
+ backgroundColor: system.color.bg.default,
26
+ borderRadius: system.shape.x1,
33
27
  boxSizing: 'border-box',
34
- height: 40,
28
+ height: system.space.x10,
35
29
  transition: '0.2s box-shadow, 0.2s border-color',
36
- padding: space.xxs, // Compensate for border
37
- margin: 0, // Fix Safari
30
+ padding: system.space.x2, // Compensate for border
31
+ margin: px2rem(0), // Fix Safari
32
+ width: cssVar(width),
33
+ minWidth: cssVar(width, calc.add(calc.multiply(system.space.x20, 3), system.space.x10)),
34
+ color: system.color.text.default,
35
+ '::-ms-clear': {
36
+ display: 'none',
37
+ },
38
38
  '&::placeholder': {
39
- color: inputColors.placeholder,
39
+ color: system.color.text.hint,
40
40
  },
41
41
  '&:hover, &.hover': {
42
- borderColor: inputColors.hoverBorder,
42
+ borderColor: system.color.border.input.strong,
43
43
  },
44
- '&:focus-visible:not([disabled]), &.focus:not([disabled]), &:focus:not([disabled])': {
45
- borderColor: inputColors.focusBorder,
46
- boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
44
+ '&:focus-visible:not([disabled]), &.focus:not([disabled])': {
45
+ borderColor: brand.common.focusOutline,
46
+ boxShadow: `inset 0 0 0 1px ${cssVar(brand.common.focusOutline)}`,
47
47
  outline: 'none',
48
48
  },
49
- '&:disabled': {
50
- backgroundColor: inputColors.disabled.background,
51
- borderColor: inputColors.disabled.border,
52
- color: inputColors.disabled.text,
49
+ '&:disabled, .disabled': {
50
+ backgroundColor: system.color.bg.alt.softer,
51
+ borderColor: system.color.border.input.disabled,
52
+ color: system.color.text.disabled,
53
53
  '&::placeholder': {
54
- color: inputColors.disabled.text,
54
+ color: system.color.text.disabled,
55
55
  },
56
56
  },
57
- '::-ms-clear': {
58
- display: 'none',
59
- },
60
- },
61
- ({width}) => ({
62
- minWidth: width || 280,
63
- width,
64
57
  }),
65
- ({grow}) =>
66
- grow && {
67
- width: '100%',
58
+ modifiers: {
59
+ grow: {
60
+ true: {
61
+ width: '100%',
62
+ resize: 'vertical',
63
+ },
64
+ false: {
65
+ width: 'initial',
66
+ },
68
67
  },
69
- ({theme, error}) => {
70
- return {
71
- '&:focus-visible:not([disabled]), &.focus:not([disabled])': {
72
- borderColor: theme.canvas.palette.common.focusOutline,
73
- boxShadow: `inset 0 0 0 1px ${theme.canvas.palette.common.focusOutline}`,
74
- outline: 'none',
68
+
69
+ error: {
70
+ error: {
71
+ borderColor: brand.error.base,
72
+ boxShadow: `inset 0 0 0 ${px2rem(1)} ${brand.error.base}`,
73
+ '&:hover, &.hover, &:disabled, &.disabled, &:focus-visible:not([disabled]), &.focus:not([disabled])':
74
+ {
75
+ borderColor: brand.error.base,
76
+ },
77
+ '&:focus-visible:not([disabled]), &.focus:not([disabled])': {
78
+ boxShadow: `inset 0 0 0 ${px2rem(1)} ${brand.error.base}, 0 0 0 2px ${
79
+ system.color.border.inverse
80
+ }, 0 0 0 4px ${brand.common.focusOutline}`,
81
+ },
82
+ },
83
+ alert: {
84
+ borderColor: brand.alert.darkest,
85
+ boxShadow: `inset 0 0 0 ${px2rem(2)} ${brand.alert.base}`,
86
+ '&:hover, &.hover, &:disabled, &.disabled, &:focus-visible:not([disabled]), &.focus:not([disabled])':
87
+ {
88
+ borderColor: brand.alert.darkest,
89
+ },
90
+
91
+ '&:focus-visible:not([disabled]), &.focus:not([disabled])': {
92
+ boxShadow: `inset 0 0 0 ${px2rem(2)} ${brand.alert.base},
93
+ 0 0 0 2px ${system.color.border.inverse},
94
+ 0 0 0 4px ${brand.common.focusOutline}`,
95
+ },
75
96
  },
76
- ...errorRing(error, theme),
77
- };
78
- }
79
- );
97
+ },
98
+ },
99
+ defaultModifiers: {
100
+ grow: 'false',
101
+ },
102
+ });
80
103
 
81
104
  export const TextInput = createComponent('input')({
82
105
  displayName: 'TextInput',
83
106
  Component: ({grow, error, width, ...elemProps}: TextInputProps, ref, Element) => (
84
- <StyledTextInput
107
+ <Element
85
108
  type="text"
86
109
  ref={ref}
87
- as={Element}
88
- grow={grow}
89
- error={error}
90
- width={width}
91
- {...elemProps}
110
+ {...handleCsProp(
111
+ elemProps,
112
+ textInputStencil({width: typeof width === 'number' ? px2rem(width) : width, grow, error})
113
+ )}
92
114
  />
93
115
  ),
94
116
  subComponents: {