@workday/canvas-kit-react 11.0.0-alpha.671-next.0 → 11.0.0-alpha.682-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.
Files changed (92) hide show
  1. package/checkbox/lib/CheckBackground.tsx +48 -0
  2. package/checkbox/lib/Checkbox.tsx +18 -355
  3. package/checkbox/lib/CheckboxCheck.tsx +81 -0
  4. package/checkbox/lib/CheckboxContainer.tsx +58 -0
  5. package/checkbox/lib/CheckboxInput.tsx +279 -0
  6. package/checkbox/lib/CheckboxRipple.tsx +21 -0
  7. package/common/lib/styles/focusRing.ts +4 -17
  8. package/dist/commonjs/avatar/lib/Avatar.js +1 -1
  9. package/dist/commonjs/badge/lib/CountBadge.js +7 -7
  10. package/dist/commonjs/banner/lib/Banner.js +1 -1
  11. package/dist/commonjs/button/lib/BaseButton.js +22 -22
  12. package/dist/commonjs/button/lib/DeleteButton.js +1 -1
  13. package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
  14. package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
  15. package/dist/commonjs/button/lib/TertiaryButton.js +15 -15
  16. package/dist/commonjs/button/lib/ToolbarDropdownButton.js +6 -1
  17. package/dist/commonjs/button/lib/ToolbarIconButton.js +6 -1
  18. package/dist/commonjs/button/lib/deprecated_Button.js +2 -2
  19. package/dist/commonjs/card/lib/Card.js +1 -1
  20. package/dist/commonjs/card/lib/CardHeading.js +1 -1
  21. package/dist/commonjs/checkbox/lib/CheckBackground.d.ts +10 -0
  22. package/dist/commonjs/checkbox/lib/CheckBackground.d.ts.map +1 -0
  23. package/dist/commonjs/checkbox/lib/CheckBackground.js +42 -0
  24. package/dist/commonjs/checkbox/lib/Checkbox.d.ts +3 -45
  25. package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
  26. package/dist/commonjs/checkbox/lib/Checkbox.js +10 -204
  27. package/dist/commonjs/checkbox/lib/CheckboxCheck.d.ts +10 -0
  28. package/dist/commonjs/checkbox/lib/CheckboxCheck.d.ts.map +1 -0
  29. package/dist/commonjs/checkbox/lib/CheckboxCheck.js +51 -0
  30. package/dist/commonjs/checkbox/lib/CheckboxContainer.d.ts +13 -0
  31. package/dist/commonjs/checkbox/lib/CheckboxContainer.d.ts.map +1 -0
  32. package/dist/commonjs/checkbox/lib/CheckboxContainer.js +37 -0
  33. package/dist/commonjs/checkbox/lib/CheckboxInput.d.ts +48 -0
  34. package/dist/commonjs/checkbox/lib/CheckboxInput.d.ts.map +1 -0
  35. package/dist/commonjs/checkbox/lib/CheckboxInput.js +59 -0
  36. package/dist/commonjs/checkbox/lib/CheckboxRipple.d.ts +2 -0
  37. package/dist/commonjs/checkbox/lib/CheckboxRipple.d.ts.map +1 -0
  38. package/dist/commonjs/checkbox/lib/CheckboxRipple.js +33 -0
  39. package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
  40. package/dist/commonjs/common/lib/CanvasProvider.js +1 -1
  41. package/dist/commonjs/common/lib/styles/focusRing.d.ts.map +1 -1
  42. package/dist/commonjs/common/lib/styles/focusRing.js +5 -16
  43. package/dist/commonjs/loading-dots/lib/LoadingDots.js +2 -2
  44. package/dist/commonjs/radio/lib/Radio.js +17 -3
  45. package/dist/commonjs/select/lib/Select.js +1 -1
  46. package/dist/commonjs/switch/lib/Switch.js +2 -2
  47. package/dist/commonjs/tabs/lib/TabsItem.js +1 -1
  48. package/dist/commonjs/text/lib/LabelText.js +24 -24
  49. package/dist/commonjs/text/lib/Text.js +15 -15
  50. package/dist/es6/avatar/lib/Avatar.js +1 -1
  51. package/dist/es6/badge/lib/CountBadge.js +7 -7
  52. package/dist/es6/banner/lib/Banner.js +1 -1
  53. package/dist/es6/button/lib/BaseButton.js +22 -22
  54. package/dist/es6/button/lib/DeleteButton.js +1 -1
  55. package/dist/es6/button/lib/PrimaryButton.js +2 -2
  56. package/dist/es6/button/lib/SecondaryButton.js +2 -2
  57. package/dist/es6/button/lib/TertiaryButton.js +15 -15
  58. package/dist/es6/button/lib/ToolbarDropdownButton.js +6 -1
  59. package/dist/es6/button/lib/ToolbarIconButton.js +6 -1
  60. package/dist/es6/button/lib/deprecated_Button.js +2 -2
  61. package/dist/es6/card/lib/Card.js +1 -1
  62. package/dist/es6/card/lib/CardHeading.js +1 -1
  63. package/dist/es6/checkbox/lib/CheckBackground.d.ts +10 -0
  64. package/dist/es6/checkbox/lib/CheckBackground.d.ts.map +1 -0
  65. package/dist/es6/checkbox/lib/CheckBackground.js +20 -0
  66. package/dist/es6/checkbox/lib/Checkbox.d.ts +3 -45
  67. package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
  68. package/dist/es6/checkbox/lib/Checkbox.js +11 -205
  69. package/dist/es6/checkbox/lib/CheckboxCheck.d.ts +10 -0
  70. package/dist/es6/checkbox/lib/CheckboxCheck.d.ts.map +1 -0
  71. package/dist/es6/checkbox/lib/CheckboxCheck.js +29 -0
  72. package/dist/es6/checkbox/lib/CheckboxContainer.d.ts +13 -0
  73. package/dist/es6/checkbox/lib/CheckboxContainer.d.ts.map +1 -0
  74. package/dist/es6/checkbox/lib/CheckboxContainer.js +15 -0
  75. package/dist/es6/checkbox/lib/CheckboxInput.d.ts +48 -0
  76. package/dist/es6/checkbox/lib/CheckboxInput.d.ts.map +1 -0
  77. package/dist/es6/checkbox/lib/CheckboxInput.js +37 -0
  78. package/dist/es6/checkbox/lib/CheckboxRipple.d.ts +2 -0
  79. package/dist/es6/checkbox/lib/CheckboxRipple.d.ts.map +1 -0
  80. package/dist/es6/checkbox/lib/CheckboxRipple.js +11 -0
  81. package/dist/es6/common/lib/AccessibleHide.js +1 -1
  82. package/dist/es6/common/lib/CanvasProvider.js +1 -1
  83. package/dist/es6/common/lib/styles/focusRing.d.ts.map +1 -1
  84. package/dist/es6/common/lib/styles/focusRing.js +5 -16
  85. package/dist/es6/loading-dots/lib/LoadingDots.js +2 -2
  86. package/dist/es6/radio/lib/Radio.js +17 -3
  87. package/dist/es6/select/lib/Select.js +1 -1
  88. package/dist/es6/switch/lib/Switch.js +2 -2
  89. package/dist/es6/tabs/lib/TabsItem.js +1 -1
  90. package/dist/es6/text/lib/LabelText.js +24 -24
  91. package/dist/es6/text/lib/Text.js +15 -15
  92. package/package.json +4 -4
@@ -31,7 +31,12 @@ const StyledToolbarDropdownButton = common_1.styled(BaseButton_1.BaseButton)({
31
31
  width: 18, // decrease the space between a custom icon and the chevron per design
32
32
  },
33
33
  '&:focus-visible, &.focus': {
34
- ...{ boxShadow: `0 0 0 ${0} ${'transparent'}, 0 0 0 calc(${2} + ${0}) ${canvas_tokens_web_1.brand.common.focusOutline}` },
34
+ ...common_1.focusRing({
35
+ width: 2,
36
+ separation: 0,
37
+ innerColor: 'transparent',
38
+ outerColor: canvas_tokens_web_1.brand.common.focusOutline,
39
+ }),
35
40
  },
36
41
  });
37
42
  exports.ToolbarDropdownButton = common_1.createComponent('button')({
@@ -32,7 +32,12 @@ const StyledToolbarIconButton = common_1.styled(BaseButton_1.BaseButton)({
32
32
  height: 20,
33
33
  },
34
34
  '&:focus-visible, &.focus': {
35
- ...{ boxShadow: `0 0 0 ${0} ${'transparent'}, 0 0 0 calc(${2} + ${0}) ${canvas_tokens_web_1.brand.common.focusOutline}` },
35
+ ...common_1.focusRing({
36
+ width: 2,
37
+ separation: 0,
38
+ innerColor: 'transparent',
39
+ outerColor: canvas_tokens_web_1.brand.common.focusOutline,
40
+ }),
36
41
  },
37
42
  });
38
43
  exports.ToolbarIconButton = common_1.createComponent('button')({
@@ -130,11 +130,11 @@ const Container = styled_1.default('button')({
130
130
  '&:not([disabled])': {
131
131
  '&:focus': {
132
132
  borderColor: buttonColors.focusBorder,
133
- ...{ boxShadow: `0 0 0 ${"0px"} ${"--cnvs-base-palette-french-vanilla-100"}, 0 0 0 calc(${"2px"} + ${"0px"}) ${"--cnvs-brand-common-focus-outline"}` },
133
+ ...common_1.focusRing(),
134
134
  },
135
135
  '&:active': {
136
136
  borderColor: buttonColors.activeBorder,
137
- ...{ boxShadow: `0 0 0 ${"0px"} ${"--cnvs-base-palette-french-vanilla-100"}, 0 0 0 calc(${"2px"} + ${"0px"}) ${"--cnvs-brand-common-focus-outline"}` },
137
+ ...common_1.focusRing(),
138
138
  },
139
139
  },
140
140
  ...common_1.mouseFocusBehavior({
@@ -27,7 +27,7 @@ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
27
27
  const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
28
28
  const CardHeading_1 = require("./CardHeading");
29
29
  const CardBody_1 = require("./CardBody");
30
- const cardBaseStyles = canvas_kit_styling_1.createStyles({ name: "ydm410", styles: "box-shadow:var(--cnvs-sys-depth-1, 0 0.0625rem 0.25rem 0 rgba(31,38,46,0.12),0 0.125rem 0.5rem 0 rgba(31,38,46,0.08));padding:var(--cnvs-sys-space-x8, calc(0.25rem * 8));background-color:var(--cnvs-base-palette-french-vanilla-100, rgba(255,255,255,1));border:0.0625rem solid var(--cnvs-base-palette-soap-500, rgba(206,211,217,1));border-radius:var(--cnvs-sys-shape-x2, calc(0.25rem * 2));" });
30
+ const cardBaseStyles = canvas_kit_styling_1.createStyles({ name: "1t9ablw", styles: "box-shadow:var(--cnvs-sys-depth-1, 0 0.0625rem 0.25rem 0 rgba(31,38,46,0.12),0 0.125rem 0.5rem 0 rgba(31,38,46,0.08));padding:var(--cnvs-sys-space-x8, calc(0.25rem * 8));background-color:var(--cnvs-base-palette-french-vanilla-100, rgba(255,255,255,1));border:0.0625rem solid var(--cnvs-base-palette-soap-500, rgba(206,211,217,1));border-radius:var(--cnvs-sys-shape-x2, calc(0.25rem * 2));" });
31
31
  /**
32
32
  * `Card` is a container component that holds a {@link CardBody Card.Body} and an optional
33
33
  * {@link CardHeading Card.Heading}. `Card` wraps a non-semantic `div` element. The element can be
@@ -26,7 +26,7 @@ const layout_1 = require("@workday/canvas-kit-react/layout");
26
26
  const text_1 = require("@workday/canvas-kit-react/text");
27
27
  const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
28
28
  const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
29
- const cardHeadingBaseStyles = canvas_kit_styling_1.createStyles({ name: "ydm4z", styles: "font-weight:var(--cnvs-sys-font-weight-bold, 700);margin-bottom:var(--cnvs-sys-space-x6, calc(0.25rem * 6));margin-top:0px;" });
29
+ const cardHeadingBaseStyles = canvas_kit_styling_1.createStyles({ name: "1oy61zb", styles: "font-weight:var(--cnvs-sys-font-weight-bold, 700);margin-bottom:var(--cnvs-sys-space-x6, calc(0.25rem * 6));margin-top:0px;" });
30
30
  exports.CardHeading = common_1.createComponent('h3')({
31
31
  displayName: 'Card.Heading',
32
32
  Component: ({ children, ...elemProps }, ref, Element) => {
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ErrorType } from '@workday/canvas-kit-react/common';
3
+ interface CheckBackgroundProps {
4
+ children: React.ReactNode;
5
+ error?: ErrorType;
6
+ }
7
+ export declare const backgroundVars: import("@workday/canvas-kit-styling").CsVars<"inner" | "outer", never>;
8
+ export declare const CheckBackground: import("@workday/canvas-kit-react/common").ElementComponent<"div", CheckBackgroundProps>;
9
+ export {};
10
+ //# sourceMappingURL=CheckBackground.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckBackground.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/CheckBackground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAkB,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAI5E,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,wEAA+B,CAAC;AAgC3D,eAAO,MAAM,eAAe,0FAK1B,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.CheckBackground = exports.backgroundVars = void 0;
23
+ const React = __importStar(require("react"));
24
+ const common_1 = require("@workday/canvas-kit-react/common");
25
+ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
26
+ const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
27
+ exports.backgroundVars = canvas_kit_styling_1.createVars({ id: "cnvs-background", args: ["inner", "outer"] });
28
+ const checkboxBackgroundStencil = canvas_kit_styling_1.createStencil({
29
+ base: { name: "13c6rci", styles: "align-items:center;background-color:var(--cnvs-base-palette-french-vanilla-100, rgba(255,255,255,1));border-radius:var(--cnvs-sys-shape-half, calc(0.25rem * 0.5));box-sizing:border-box;display:flex;height:calc(var(--cnvs-sys-space-x4) + 0.125rem);justify-content:center;padding:var(--cnvs-sys-space-zero, 0) calc(var(--cnvs-sys-space-x1) / 2);pointer-events:none;position:absolute;transition:border 200ms ease, background 200ms;width:calc(var(--cnvs-sys-space-x4) + 0.125rem);border:0.0625rem solid var(--cnvs-base-palette-licorice-200, rgba(123,133,143,1));" },
30
+ modifiers: {
31
+ modifiers: {
32
+ error: { name: "1oai5jc", styles: "--cnvs-background-inner:var(--cnvs-brand-error-base, var(--cnvs-base-palette-cinnamon-500));--cnvs-background-outer:transparent;" },
33
+ alert: { name: "6w2nb6", styles: "--cnvs-background-inner:var(--cnvs-brand-alert-base, var(--cnvs-base-palette-cantaloupe-600));--cnvs-background-outer:var(--cnvs-brand-alert-darkest, var(--cnvs-base-palette-cantaloupe-400));" }
34
+ }
35
+ }
36
+ }, "checkbox-background");
37
+ exports.CheckBackground = common_1.createComponent('div')({
38
+ displayName: 'CheckBackground',
39
+ Component: ({ error, children }) => {
40
+ return React.createElement("div", Object.assign({}, checkboxBackgroundStencil({ error })), children);
41
+ },
42
+ });
@@ -1,49 +1,7 @@
1
- import * as React from 'react';
2
- import { ErrorType, Themeable } from '@workday/canvas-kit-react/common';
3
- export interface CheckboxProps extends Themeable {
4
- /**
5
- * If true, set the Checkbox to the checked state.
6
- * @default false
7
- */
8
- checked?: boolean;
9
- /**
10
- * If true, set the Checkbox to the disabled state.
11
- * @default false
12
- */
13
- disabled?: boolean;
14
- /**
15
- * The HTML `id` of the underlying checkbox input element. This is required if `label` is defined as a non-empty string.
16
- * @default {useUniqueId}
17
- */
18
- id?: string;
19
- /**
20
- * The text of the Checkbox label.
21
- * @default ''
22
- */
23
- label?: string;
24
- /**
25
- * The function called when the Checkbox state changes.
26
- */
27
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
28
- /**
29
- * The value of the Checkbox.
30
- */
31
- value?: string;
32
- /**
33
- * The type of error associated with the Checkbox (if applicable).
34
- */
35
- error?: ErrorType;
36
- /**
37
- * If true, set the Checkbox to an indeterminate state. Use this on a Checkbox with nested child Checkboxes to denote that some (but not all) child Checkboxes are checked.
38
- * @default false
39
- */
40
- indeterminate?: boolean;
41
- /**
42
- * The variant for the checkbox
43
- */
44
- variant?: 'inverse' | undefined;
45
- }
1
+ import { ErrorType } from '@workday/canvas-kit-react/common';
2
+ import { CheckboxProps } from './CheckboxInput';
46
3
  export declare const Checkbox: import("@workday/canvas-kit-react/common").ElementComponent<"input", CheckboxProps> & {
47
4
  ErrorType: typeof ErrorType;
48
5
  };
6
+ export { CheckboxProps };
49
7
  //# sourceMappingURL=Checkbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,SAAS,EAOT,SAAS,EAEV,MAAM,kCAAkC,CAAC;AAQ1C,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAkPD,eAAO,MAAM,QAAQ;;CA2EnB,CAAC"}
1
+ {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/Checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,EAGV,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAAgB,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE7D,eAAO,MAAM,QAAQ;;CA6BnB,CAAC;AAEH,OAAO,EAAC,aAAa,EAAC,CAAC"}
@@ -22,203 +22,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.Checkbox = void 0;
23
23
  const React = __importStar(require("react"));
24
24
  const common_1 = require("@workday/canvas-kit-react/common");
25
- const tokens_1 = require("@workday/canvas-kit-react/tokens");
26
- const icon_1 = require("@workday/canvas-kit-react/icon");
27
- const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
28
- const text_1 = require("@workday/canvas-kit-react/text");
29
- const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
30
- const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
31
- const CheckboxContainer = common_1.styled('div')({
32
- display: 'flex',
33
- alignItems: 'center',
34
- minHeight: tokens_1.space.m,
35
- position: 'relative',
36
- });
37
- /**
38
- * Using a wrapper prevents the browser default behavior of trigging
39
- * :hover on the checkbox when you hover on it's corresponding label.
40
- * This stops the ripple from showing when you hover on the label.
41
- */
42
- const CheckboxInputWrapper = common_1.styled('div')({
43
- display: 'flex',
44
- height: `calc(${tokens_1.space.s} + 2px)`,
45
- minWidth: `calc(${tokens_1.space.s} + 2px)`,
46
- marginTop: '3px',
47
- alignSelf: 'flex-start',
48
- });
49
- const CheckboxRipple = common_1.styled('span')({
50
- borderRadius: tokens_1.borderRadius.circle,
51
- boxShadow: `0 0 0 0 ${tokens_1.colors.soap200}`,
52
- height: `calc(${tokens_1.space.s} + 2px)`,
53
- transition: 'box-shadow 150ms ease-out',
54
- width: `calc(${tokens_1.space.s} + 2px)`,
55
- position: 'absolute',
56
- pointerEvents: 'none', // This is a decorative element we don't want it to block clicks to input
57
- }, ({ variant }) => ({
58
- opacity: variant === 'inverse' ? '0.4' : '1',
59
- }));
60
- /**
61
- * Note: `~ div:first-of-type` refers to `CheckboxBackground`
62
- * and was easier to use than a component selector in this case.
63
- */
64
- const CheckboxInput = common_1.styled('input')(({ theme: { canvas: { palette: { primary: themePrimary, common: { focusOutline: themeFocusOutline }, }, }, }, variant, }) => ({
65
- borderRadius: tokens_1.borderRadius.s,
66
- width: tokens_1.space.m,
67
- height: tokens_1.space.m,
68
- margin: 0,
69
- marginTop: '-3px',
70
- marginLeft: '-3px',
71
- position: 'absolute',
72
- opacity: 0,
73
- '&:not(:disabled)': {
74
- cursor: 'pointer',
75
- },
76
- // States
77
- '&:not(:checked):not(:indeterminate):not(:disabled):not(:focus):hover, &:not(:checked):not(:indeterminate):not(:disabled):active': {
78
- '~ div:first-of-type': {
79
- borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : tokens_1.inputColors.hoverBorder,
80
- },
81
- },
82
- '&:checked ~ div:first-of-type, &:indeterminate ~ div:first-of-type': {
83
- borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.main,
84
- backgroundColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.main,
85
- },
86
- '&:disabled ~ div:first-of-type': {
87
- borderColor: canvas_tokens_web_1.base.licorice100,
88
- backgroundColor: variant === 'inverse' ? tokens_1.colors.soap300 : tokens_1.inputColors.disabled.background,
89
- opacity: variant === 'inverse' ? '.4' : '1',
90
- },
91
- '&:disabled:checked ~ div:first-of-type, &:disabled:indeterminate ~ div:first-of-type': {
92
- borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.light,
93
- backgroundColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.light,
94
- },
95
- // Focus
96
- '&:focus, &:active': {
97
- outline: 'none',
98
- },
99
- '&:focus ~ div:first-of-type': {
100
- borderColor: variant === 'inverse' ? tokens_1.colors.blackPepper400 : themePrimary.main,
101
- borderWidth: '2px',
102
- boxShadow: 'none',
103
- ...{ boxShadow: `0 0 0 ${0} ${variant === 'inverse' ? tokens_1.colors.blackPepper400 : undefined}, 0 0 0 calc(${variant === 'inverse' ? 2 : 0} + ${0}) ${variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : undefined}` },
104
- },
105
- '&:checked:focus ~ div:first-of-type, &:indeterminate:focus ~ div:first-of-type': {
106
- ...{ boxShadow: `0 0 0 ${2} ${variant === 'inverse' ? tokens_1.colors.blackPepper400 : undefined}, 0 0 0 calc(${2} + ${2}) ${variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themeFocusOutline}` },
107
- borderColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.main,
108
- borderWidth: '2px',
109
- '& span': {
110
- marginLeft: '-7px',
111
- },
112
- },
113
- ...common_1.mouseFocusBehavior({
114
- '&:focus ~ div:first-of-type': {
115
- border: variant === 'inverse'
116
- ? `1px solid ${tokens_1.colors.soap300}`
117
- : `1px solid ${tokens_1.inputColors.hoverBorder}`,
118
- boxShadow: 'none',
119
- '& span': {
120
- marginLeft: '-6px',
121
- },
122
- },
123
- '&:checked ~ div:first-of-type, &:indeterminate ~ div:first-of-type': {
124
- borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : themePrimary.main,
125
- },
126
- '&:disabled:checked ~ div:first-of-type, &:disabled:indeterminate ~ div:first-of-type': {
127
- borderColor: themePrimary.light,
128
- backgroundColor: variant === 'inverse' ? tokens_1.colors.frenchVanilla100 : themePrimary.light,
129
- },
130
- }),
131
- }), ({ disabled }) => ({
132
- '&:hover ~ span:first-of-type': {
133
- boxShadow: disabled
134
- ? undefined
135
- : `0 0 0 calc((${tokens_1.space.l} - (${tokens_1.space.s} + 2px)) / 2) ${tokens_1.colors.soap200}`,
136
- },
137
- }), ({ theme, error, variant }) => {
138
- const errorColors = common_1.getErrorColors(error, theme);
139
- if (errorColors.outer === errorColors.inner) {
140
- errorColors.outer = 'transparent';
141
- }
142
- const errorStyles = {
143
- '& ~ div:first-of-type': {
144
- border: variant === 'inverse' ? `1px solid ${tokens_1.colors.soap300}` : `1px solid ${errorColors.inner}`,
145
- boxShadow: `0 0 0 1px ${errorColors.inner}, 0 0 0 2px ${errorColors.outer}`,
146
- },
147
- '&:not(:checked):not(:indeterminate):not(:disabled):not(:focus):hover, &:not(:checked):not(:indeterminate):not(:disabled):active': {
148
- '~ div:first-of-type': {
149
- borderColor: variant === 'inverse' ? `1px solid ${tokens_1.colors.soap300}` : errorColors.inner,
150
- },
151
- },
152
- '&:checked ~ div:first-of-type, &:indeterminate ~ div:first-of-type': {
153
- borderColor: variant === 'inverse' ? tokens_1.colors.soap300 : theme.canvas.palette.primary.main,
154
- boxShadow: `
155
- 0 0 0 2px ${tokens_1.colors.frenchVanilla100},
156
- 0 0 0 4px ${errorColors.inner},
157
- 0 0 0 5px ${errorColors.outer}`,
158
- },
159
- };
160
- return {
161
- // Error rings take precedence over focus
162
- ...common_1.mouseFocusBehavior({
163
- ...errorStyles,
164
- '&:not(:checked):not(:indeterminate):focus ~ div:first-of-type': {
165
- border: `1px solid ${errorColors.inner}`,
166
- boxShadow: `0 0 0 1px ${errorColors.inner}, 0 0 0 2px ${errorColors.outer}`,
167
- },
168
- }),
169
- ...errorStyles,
170
- };
171
- });
172
- const CheckboxBackground = common_1.styled('div')({
173
- alignItems: 'center',
174
- backgroundColor: tokens_1.colors.frenchVanilla100,
175
- borderRadius: tokens_1.borderRadius.s,
176
- boxSizing: 'border-box',
177
- display: 'flex',
178
- height: `calc(${tokens_1.space.s} + 2px)`,
179
- justifyContent: 'center',
180
- padding: '0px 2px',
181
- pointerEvents: 'none',
182
- position: 'absolute',
183
- transition: 'border 200ms ease, background 200ms',
184
- width: `calc(${tokens_1.space.s} + 2px)`,
185
- }, ({ variant }) => ({
186
- border: `1px solid ${variant === 'inverse' ? tokens_1.colors.soap300 : tokens_1.inputColors.border}`,
187
- }));
188
- const CheckboxCheck = common_1.styled('div')({
189
- display: 'flex',
190
- flexDirection: 'column',
191
- // When using align-items: center on a flex container in the column direction,
192
- // the contents of flex item, if too big, will overflow their container in IE 10-11.
193
- // max-width: 100%; is a workaround
194
- // https://github.com/philipwalton/flexbugs#flexbug-2
195
- maxWidth: '100%',
196
- pointerEvents: 'none',
197
- transition: 'transform 200ms ease, opacity 200ms ease',
198
- span: {
199
- // This is necessary because we're using max-width: 100% in the CheckboxCheck container
200
- // in order for the Checkbox to render properly on IE 11
201
- marginLeft: '-6px',
202
- transition: 'margin 200ms ease',
203
- },
204
- }, ({ checked, indeterminate }) => ({
205
- opacity: checked || indeterminate ? 1 : 0,
206
- transform: checked || indeterminate ? 'scale(1)' : 'scale(0.5)',
207
- }));
208
- const IndeterminateBox = common_1.styled('div')({
209
- width: '10px',
210
- height: '2px',
211
- }, ({ theme, variant }) => ({
212
- backgroundColor: variant === 'inverse'
213
- ? theme.canvas.palette.primary.main
214
- : theme.canvas.palette.primary.contrast,
215
- }));
25
+ const CheckboxRipple_1 = require("./CheckboxRipple");
26
+ const CheckboxContainer_1 = require("./CheckboxContainer");
27
+ const CheckboxCheck_1 = require("./CheckboxCheck");
28
+ const CheckboxInput_1 = require("./CheckboxInput");
216
29
  exports.Checkbox = common_1.createComponent('input')({
217
30
  displayName: 'Checkbox',
218
- Component: ({ checked = false, label = '',
219
- // TODO: Fix useTheme and make it a real hook
220
- // eslint-disable-next-line react-hooks/rules-of-hooks
221
- theme = common_1.useTheme(), id, disabled, indeterminate, variant, ...elemProps }, ref, Element) => {
31
+ Component: ({ id, label = '', ...elemProps }, ref, Element) => {
32
+ const { checked = false, disabled, error, indeterminate, variant } = elemProps;
222
33
  const inputId = common_1.useUniqueId(id);
223
34
  const { localRef, elementRef } = common_1.useLocalRef(ref);
224
35
  React.useEffect(() => {
@@ -226,15 +37,10 @@ exports.Checkbox = common_1.createComponent('input')({
226
37
  localRef.current.indeterminate = indeterminate;
227
38
  }
228
39
  }, [indeterminate, localRef]);
229
- return (React.createElement(CheckboxContainer, null,
230
- React.createElement(CheckboxInputWrapper, { disabled: disabled },
231
- React.createElement(CheckboxInput, Object.assign({ as: Element, checked: checked, disabled: disabled, id: inputId, ref: elementRef, type: "checkbox", variant: variant, "aria-checked": indeterminate ? 'mixed' : checked }, elemProps)),
232
- React.createElement(CheckboxRipple, { variant: variant }),
233
- React.createElement(CheckboxBackground, { variant: variant, checked: checked, disabled: disabled },
234
- React.createElement(CheckboxCheck, { checked: checked, indeterminate: indeterminate }, indeterminate ? (React.createElement(IndeterminateBox, { variant: variant })) : checked ? (React.createElement(icon_1.SystemIcon, { icon: canvas_system_icons_web_1.checkSmallIcon, color: variant === 'inverse'
235
- ? theme.canvas.palette.primary.main
236
- : theme.canvas.palette.primary.contrast })) : null))),
237
- label && (React.createElement(text_1.LabelText, { htmlFor: inputId, disabled: disabled, variant: variant, paddingInlineStart: tokens_1.space.xs, cursor: "pointer" }, label))));
40
+ return (React.createElement(CheckboxContainer_1.CheckboxContainer, { label: label, disabled: disabled, id: inputId, variant: variant },
41
+ React.createElement(CheckboxInput_1.CheckboxInput, Object.assign({ as: Element, id: inputId, ref: elementRef }, elemProps)),
42
+ React.createElement(CheckboxRipple_1.CheckboxRipple, null),
43
+ React.createElement(CheckboxCheck_1.CheckboxCheck, { variant: variant, checked: checked, indeterminate: indeterminate, error: error })));
238
44
  },
239
45
  subComponents: {
240
46
  ErrorType: common_1.ErrorType,
@@ -0,0 +1,10 @@
1
+ import { ErrorType } from '@workday/canvas-kit-react/common';
2
+ interface CheckboxCheckProps {
3
+ checked: boolean;
4
+ error?: ErrorType;
5
+ indeterminate?: boolean;
6
+ variant?: 'inverse';
7
+ }
8
+ export declare const CheckboxCheck: import("@workday/canvas-kit-react/common").ElementComponent<"div", CheckboxCheckProps>;
9
+ export {};
10
+ //# sourceMappingURL=CheckboxCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxCheck.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/CheckboxCheck.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAkB,MAAM,kCAAkC,CAAC;AAO5E,UAAU,kBAAkB;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AA6CD,eAAO,MAAM,aAAa,wFAsBxB,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.CheckboxCheck = void 0;
23
+ const React = __importStar(require("react"));
24
+ const common_1 = require("@workday/canvas-kit-react/common");
25
+ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
26
+ const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
27
+ const icon_1 = require("@workday/canvas-kit-react/icon");
28
+ const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
29
+ const CheckBackground_1 = require("./CheckBackground");
30
+ const checkboxCheckStencil = canvas_kit_styling_1.createStencil({
31
+ base: { name: "e9m2ww", styles: "display:flex;flex-direction:column;max-width:100%;pointer-events:none;transition:transform 200ms ease, opacity 200ms ease;span{margin-inline-start:calc(0.375rem * -1);transition:margin 200ms ease;}opacity:0px;transform:scale(0.5);" },
32
+ modifiers: {
33
+ modifiers: {
34
+ true: { name: "11cckse", styles: "opacity:1px;transform:scale(1);" }
35
+ },
36
+ modifiers: {
37
+ true: { name: "11cckse", styles: "opacity:1px;transform:scale(1);" }
38
+ },
39
+ modifiers: {
40
+ inverse: { name: "18xh6xb", styles: "& > div{background-color:var(--cnvs-brand-primary-base, rgba(8,117,225,1));}" }
41
+ }
42
+ }
43
+ }, "checkbox-check");
44
+ const indeterminateBoxStyles = canvas_kit_styling_1.createStyles({ name: "1ekwrf6", styles: "width:calc(var(--cnvs-sys-space-x2) + 0.125rem);height:calc(var(--cnvs-sys-space-x1) / 2);background-color:var(--cnvs-brand-primary-accent, rgba(255,255,255,1));" });
45
+ exports.CheckboxCheck = common_1.createComponent('div')({
46
+ displayName: 'CheckboxCheck',
47
+ Component: ({ checked, error, indeterminate, variant }) => {
48
+ return (React.createElement(CheckBackground_1.CheckBackground, { error: error },
49
+ React.createElement("div", Object.assign({}, checkboxCheckStencil({ checked, indeterminate, variant })), indeterminate ? (React.createElement("div", { className: indeterminateBoxStyles })) : (checked && (React.createElement(icon_1.SystemIcon, { icon: canvas_system_icons_web_1.checkSmallIcon, color: variant === 'inverse' ? canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.primary.base) : canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.primary.accent) }))))));
50
+ },
51
+ });
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { CSProps } from '@workday/canvas-kit-styling';
3
+ interface CheckboxContainerProps extends CSProps {
4
+ children: React.ReactNode;
5
+ disabled?: boolean;
6
+ id: string;
7
+ label: string;
8
+ variant?: 'inverse';
9
+ }
10
+ export declare const inputVars: import("@workday/canvas-kit-styling").CsVars<"errorInner" | "errorOuter" | "alertInner" | "alertOuter", never>;
11
+ export declare const CheckboxContainer: import("@workday/canvas-kit-react/common").ElementComponent<"div", CheckboxContainerProps>;
12
+ export {};
13
+ //# sourceMappingURL=CheckboxContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxContainer.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/CheckboxContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,OAAO,EAAiD,MAAM,6BAA6B,CAAC;AAIpG,UAAU,sBAAuB,SAAQ,OAAO;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,gHAAqE,CAAC;AAwB5F,eAAO,MAAM,iBAAiB,4FAmB5B,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.CheckboxContainer = exports.inputVars = void 0;
23
+ const React = __importStar(require("react"));
24
+ const common_1 = require("@workday/canvas-kit-react/common");
25
+ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
26
+ const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
27
+ const text_1 = require("@workday/canvas-kit-react/text");
28
+ exports.inputVars = canvas_kit_styling_1.createVars({ id: "cnvs-input", args: ["errorInner", "errorOuter", "alertInner", "alertOuter"] });
29
+ const checkboxContainerStyles = canvas_kit_styling_1.createStyles({ name: "flsw04", styles: "display:flex;align-items:center;min-height:var(--cnvs-sys-space-x6, calc(0.25rem * 6));position:relative;&>div{display:flex;height:calc(var(--cnvs-sys-space-x4) + 0.125rem);min-width:calc(var(--cnvs-sys-space-x4) + 0.125rem);margin-top:0.1875rem;align-self:flex-start;}& > label{padding-inline-start:var(--cnvs-sys-space-x3, calc(var(--cnvs-base-unit) * 3));}" });
30
+ exports.CheckboxContainer = common_1.createComponent('div')({
31
+ displayName: 'CheckboxContainer',
32
+ Component: ({ children, disabled, id, label, variant }) => {
33
+ return (React.createElement("div", { className: checkboxContainerStyles },
34
+ React.createElement("div", null, children),
35
+ label && (React.createElement(text_1.LabelText, { htmlFor: id, disabled: disabled, variant: variant, style: { cursor: disabled ? 'default' : 'pointer' } }, label))));
36
+ },
37
+ });
@@ -0,0 +1,48 @@
1
+ import * as React from 'react';
2
+ import { ErrorType } from '@workday/canvas-kit-react/common';
3
+ import { CSProps } from '@workday/canvas-kit-styling';
4
+ export interface CheckboxProps extends CSProps {
5
+ /**
6
+ * If true, set the Checkbox to the checked state.
7
+ * @default false
8
+ */
9
+ checked?: boolean;
10
+ /**
11
+ * If true, set the Checkbox to the disabled state.
12
+ * @default false
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * The type of error associated with the Checkbox (if applicable).
17
+ */
18
+ error?: ErrorType;
19
+ /**
20
+ * The HTML `id` of the underlying checkbox input element. This is required if `label` is defined as a non-empty string.
21
+ * @default {useUniqueId}
22
+ */
23
+ id?: string;
24
+ /**
25
+ * If true, set the Checkbox to an indeterminate state. Use this on a Checkbox with nested child Checkboxes to denote that some (but not all) child Checkboxes are checked.
26
+ * @default false
27
+ */
28
+ indeterminate?: boolean;
29
+ /**
30
+ * The text of the Checkbox label.
31
+ * @default ''
32
+ */
33
+ label?: string;
34
+ /**
35
+ * The function called when the Checkbox state changes.
36
+ */
37
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
38
+ /**
39
+ * The value of the Checkbox.
40
+ */
41
+ value?: string;
42
+ /**
43
+ * The variant for the checkbox
44
+ */
45
+ variant?: 'inverse' | undefined;
46
+ }
47
+ export declare const CheckboxInput: import("@workday/canvas-kit-react/common").ElementComponent<"input", CheckboxProps>;
48
+ //# sourceMappingURL=CheckboxInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxInput.d.ts","sourceRoot":"","sources":["../../../../checkbox/lib/CheckboxInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA6B,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEvF,OAAO,EAML,OAAO,EACR,MAAM,6BAA6B,CAAC;AAIrC,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAgND,eAAO,MAAM,aAAa,qFAcxB,CAAC"}