@workday/canvas-kit-react 10.0.0-alpha.537-next.0 → 10.0.0-alpha.539-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/button/index.ts +8 -11
- package/button/lib/BaseButton.tsx +274 -256
- package/button/lib/Button.tsx +67 -0
- package/button/lib/DeleteButton.tsx +42 -58
- package/button/lib/PrimaryButton.tsx +82 -149
- package/button/lib/SecondaryButton.tsx +87 -173
- package/button/lib/TertiaryButton.tsx +158 -223
- package/button/lib/ToolbarDropdownButton.tsx +11 -2
- package/button/lib/ToolbarIconButton.tsx +10 -2
- package/button/lib/parts/ButtonLabelIcon.tsx +1 -7
- package/button/lib/types.ts +6 -8
- package/common/lib/CanvasProvider.tsx +50 -24
- package/common/lib/utils/slugify.ts +4 -1
- package/dist/commonjs/button/index.d.ts +8 -5
- package/dist/commonjs/button/index.d.ts.map +1 -1
- package/dist/commonjs/button/index.js +9 -13
- package/dist/commonjs/button/lib/BaseButton.d.ts +69 -5
- package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/BaseButton.js +199 -192
- package/dist/commonjs/button/lib/Button.d.ts +17 -0
- package/dist/commonjs/button/lib/Button.d.ts.map +1 -0
- package/dist/commonjs/button/lib/Button.js +42 -0
- package/dist/commonjs/button/lib/DeleteButton.d.ts +7 -9
- package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/DeleteButton.js +29 -19
- package/dist/commonjs/button/lib/PrimaryButton.d.ts +15 -36
- package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +67 -79
- package/dist/commonjs/button/lib/SecondaryButton.d.ts +16 -43
- package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/SecondaryButton.js +71 -96
- package/dist/commonjs/button/lib/TertiaryButton.d.ts +35 -47
- package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/TertiaryButton.js +136 -134
- package/dist/commonjs/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/ToolbarDropdownButton.js +11 -2
- package/dist/commonjs/button/lib/ToolbarIconButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/ToolbarIconButton.js +10 -2
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/commonjs/button/lib/types.d.ts +6 -7
- package/dist/commonjs/button/lib/types.d.ts.map +1 -1
- package/dist/commonjs/card/lib/Card.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.d.ts +1 -8
- package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +31 -13
- package/dist/commonjs/common/lib/utils/slugify.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/slugify.js +4 -1
- package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
- package/dist/commonjs/layout/lib/Box.d.ts +3 -2
- package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Box.js +2 -1
- package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
- package/dist/commonjs/layout/lib/Grid.d.ts +1 -1
- package/dist/commonjs/menu/lib/MenuItem.d.ts +1 -1
- package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/es6/button/index.d.ts +8 -5
- package/dist/es6/button/index.d.ts.map +1 -1
- package/dist/es6/button/index.js +8 -5
- package/dist/es6/button/lib/BaseButton.d.ts +69 -5
- package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/es6/button/lib/BaseButton.js +199 -192
- package/dist/es6/button/lib/Button.d.ts +17 -0
- package/dist/es6/button/lib/Button.d.ts.map +1 -0
- package/dist/es6/button/lib/Button.js +20 -0
- package/dist/es6/button/lib/DeleteButton.d.ts +7 -9
- package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/es6/button/lib/DeleteButton.js +31 -21
- package/dist/es6/button/lib/PrimaryButton.d.ts +15 -36
- package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +67 -79
- package/dist/es6/button/lib/SecondaryButton.d.ts +16 -43
- package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/SecondaryButton.js +71 -95
- package/dist/es6/button/lib/TertiaryButton.d.ts +35 -47
- package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/TertiaryButton.js +137 -135
- package/dist/es6/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
- package/dist/es6/button/lib/ToolbarDropdownButton.js +11 -2
- package/dist/es6/button/lib/ToolbarIconButton.d.ts.map +1 -1
- package/dist/es6/button/lib/ToolbarIconButton.js +10 -2
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/es6/button/lib/types.d.ts +6 -7
- package/dist/es6/button/lib/types.d.ts.map +1 -1
- package/dist/es6/card/lib/Card.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.d.ts +1 -8
- package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +31 -13
- package/dist/es6/common/lib/utils/slugify.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/slugify.js +4 -1
- package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
- package/dist/es6/layout/lib/Box.d.ts +3 -2
- package/dist/es6/layout/lib/Box.d.ts.map +1 -1
- package/dist/es6/layout/lib/Box.js +2 -1
- package/dist/es6/layout/lib/Flex.d.ts +1 -1
- package/dist/es6/layout/lib/Grid.d.ts +1 -1
- package/dist/es6/menu/lib/MenuItem.d.ts +1 -1
- package/dist/es6/popup/lib/Popup.d.ts +1 -1
- package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
- package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/layout/lib/Box.tsx +6 -4
- package/package.json +5 -3
- package/popup/lib/PopupCloseIcon.tsx +1 -1
- package/segmented-control/lib/SegmentedControlButton.tsx +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../button/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,IAAI,iBAAiB,EACrC,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAC,qBAAqB,EAAE,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAClF,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC"}
|
|
@@ -10,15 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.ExternalHyperlink = exports.
|
|
14
|
-
var PrimaryButton_1 = require("./lib/PrimaryButton");
|
|
15
|
-
Object.defineProperty(exports, "PrimaryButton", { enumerable: true, get: function () { return PrimaryButton_1.PrimaryButton; } });
|
|
16
|
-
var SecondaryButton_1 = require("./lib/SecondaryButton");
|
|
17
|
-
Object.defineProperty(exports, "SecondaryButton", { enumerable: true, get: function () { return SecondaryButton_1.SecondaryButton; } });
|
|
18
|
-
var TertiaryButton_1 = require("./lib/TertiaryButton");
|
|
19
|
-
Object.defineProperty(exports, "TertiaryButton", { enumerable: true, get: function () { return TertiaryButton_1.TertiaryButton; } });
|
|
20
|
-
var DeleteButton_1 = require("./lib/DeleteButton");
|
|
21
|
-
Object.defineProperty(exports, "DeleteButton", { enumerable: true, get: function () { return DeleteButton_1.DeleteButton; } });
|
|
13
|
+
exports.ExternalHyperlink = exports.Hyperlink = exports.ToolbarDropdownButton = exports.ToolbarIconButton = exports.deprecated_Button = void 0;
|
|
22
14
|
var deprecated_Button_1 = require("./lib/deprecated_Button");
|
|
23
15
|
Object.defineProperty(exports, "deprecated_Button", { enumerable: true, get: function () { return deprecated_Button_1.DeprecatedButton; } });
|
|
24
16
|
var ToolbarIconButton_1 = require("./lib/ToolbarIconButton");
|
|
@@ -27,10 +19,14 @@ var ToolbarDropdownButton_1 = require("./lib/ToolbarDropdownButton");
|
|
|
27
19
|
Object.defineProperty(exports, "ToolbarDropdownButton", { enumerable: true, get: function () { return ToolbarDropdownButton_1.ToolbarDropdownButton; } });
|
|
28
20
|
var Hyperlink_1 = require("./lib/Hyperlink");
|
|
29
21
|
Object.defineProperty(exports, "Hyperlink", { enumerable: true, get: function () { return Hyperlink_1.Hyperlink; } });
|
|
30
|
-
var BaseButton_1 = require("./lib/BaseButton");
|
|
31
|
-
Object.defineProperty(exports, "BaseButton", { enumerable: true, get: function () { return BaseButton_1.BaseButton; } });
|
|
32
|
-
Object.defineProperty(exports, "getMinWidthStyles", { enumerable: true, get: function () { return BaseButton_1.getMinWidthStyles; } });
|
|
33
|
-
Object.defineProperty(exports, "getPaddingStyles", { enumerable: true, get: function () { return BaseButton_1.getPaddingStyles; } });
|
|
34
22
|
var ExternalHyperlink_1 = require("./lib/ExternalHyperlink");
|
|
35
23
|
Object.defineProperty(exports, "ExternalHyperlink", { enumerable: true, get: function () { return ExternalHyperlink_1.ExternalHyperlink; } });
|
|
36
24
|
__exportStar(require("./lib/types"), exports);
|
|
25
|
+
__exportStar(require("./lib/PrimaryButton"), exports);
|
|
26
|
+
__exportStar(require("./lib/SecondaryButton"), exports);
|
|
27
|
+
__exportStar(require("./lib/TertiaryButton"), exports);
|
|
28
|
+
__exportStar(require("./lib/DeleteButton"), exports);
|
|
29
|
+
__exportStar(require("./lib/BaseButton"), exports);
|
|
30
|
+
__exportStar(require("./lib/ToolbarDropdownButton"), exports);
|
|
31
|
+
__exportStar(require("./lib/ToolbarIconButton"), exports);
|
|
32
|
+
__exportStar(require("./lib/types"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GrowthBehavior } from '@workday/canvas-kit-react/common';
|
|
3
3
|
import { SystemIconProps } from '@workday/canvas-kit-react/icon';
|
|
4
|
-
import { ButtonColors, ButtonSizes, IconPositions
|
|
4
|
+
import { ButtonColors, ButtonSizes, IconPositions } from './types';
|
|
5
5
|
import { CanvasSystemIcon } from '@workday/design-assets-types';
|
|
6
6
|
export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBehavior {
|
|
7
7
|
/**
|
|
@@ -11,13 +11,33 @@ export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBe
|
|
|
11
11
|
/**
|
|
12
12
|
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
13
13
|
* If no size is provided, it will default to `medium`.
|
|
14
|
+
*
|
|
15
|
+
* @default 'medium
|
|
14
16
|
*/
|
|
15
17
|
size?: ButtonSizes;
|
|
18
|
+
/**
|
|
19
|
+
* The icon of the Button.
|
|
20
|
+
* Note: not displayed at `small` size
|
|
21
|
+
*/
|
|
22
|
+
icon?: CanvasSystemIcon;
|
|
16
23
|
/**
|
|
17
24
|
* Whether the icon should received filled (colored background layer) or regular styles.
|
|
18
25
|
* Corresponds to `toggled` in ToolbarIconButton
|
|
19
26
|
*/
|
|
20
27
|
fillIcon?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Button icon positions can either be `start` or `end`.
|
|
30
|
+
* If no value is provided, it defaults to `start`.
|
|
31
|
+
*
|
|
32
|
+
* @default 'start'
|
|
33
|
+
*/
|
|
34
|
+
iconPosition?: IconPositions;
|
|
35
|
+
/**
|
|
36
|
+
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
shouldMirrorIcon?: boolean;
|
|
40
|
+
children?: React.ReactNode;
|
|
21
41
|
}
|
|
22
42
|
/**
|
|
23
43
|
* Extends all the style properties from Box to our buttons as well as props from ButtonContainerProps.
|
|
@@ -26,10 +46,54 @@ export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBe
|
|
|
26
46
|
*/
|
|
27
47
|
export interface BaseButtonProps extends Omit<ButtonContainerProps, 'ref'> {
|
|
28
48
|
}
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Temporary css variables to be used across all Buttons.
|
|
51
|
+
*/
|
|
52
|
+
export declare const buttonVars: {
|
|
53
|
+
default: import("@workday/canvas-kit-styling").CsVars<"label" | "opacity" | "background" | "border" | "borderRadius" | "icon" | "boxShadowInner" | "boxShadowOuter", never>;
|
|
54
|
+
hover: import("@workday/canvas-kit-styling").CsVars<"label" | "opacity" | "background" | "border" | "borderRadius" | "icon" | "boxShadowInner" | "boxShadowOuter", never>;
|
|
55
|
+
active: import("@workday/canvas-kit-styling").CsVars<"label" | "opacity" | "background" | "border" | "borderRadius" | "icon" | "boxShadowInner" | "boxShadowOuter", never>;
|
|
56
|
+
focus: import("@workday/canvas-kit-styling").CsVars<"label" | "opacity" | "background" | "border" | "borderRadius" | "icon" | "boxShadowInner" | "boxShadowOuter", never>;
|
|
57
|
+
disabled: import("@workday/canvas-kit-styling").CsVars<"label" | "opacity" | "background" | "border" | "borderRadius" | "icon" | "boxShadowInner" | "boxShadowOuter", never>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Button modifiers that will overwrite the base styles of Buttons.
|
|
61
|
+
* - `Size`: These modifiers will dictate a size of a Button and has a set of styles to associated with it.
|
|
62
|
+
* - `iconPosition`: These modifiers will override the existing `Size` styles. These are specific to icon locations
|
|
63
|
+
* within a button or if there is only an icon and no text.
|
|
64
|
+
*/
|
|
65
|
+
export declare const buttonModifiers: {
|
|
66
|
+
size: {
|
|
67
|
+
large: string;
|
|
68
|
+
medium: string;
|
|
69
|
+
small: string;
|
|
70
|
+
extraSmall: string;
|
|
71
|
+
};
|
|
72
|
+
iconPosition: {
|
|
73
|
+
largeOnly: string;
|
|
74
|
+
largeStart: string;
|
|
75
|
+
largeEnd: string;
|
|
76
|
+
mediumOnly: string;
|
|
77
|
+
mediumStart: string;
|
|
78
|
+
mediumEnd: string;
|
|
79
|
+
smallOnly: string;
|
|
80
|
+
smallStart: string;
|
|
81
|
+
smallEnd: string;
|
|
82
|
+
extraSmallOnly: string;
|
|
83
|
+
extraSmallStart: string;
|
|
84
|
+
extraSmallEnd: string;
|
|
85
|
+
};
|
|
86
|
+
} & ((modifiers: Partial<{
|
|
87
|
+
size: "small" | "medium" | "large" | "extraSmall";
|
|
88
|
+
iconPosition: "largeOnly" | "largeStart" | "largeEnd" | "mediumOnly" | "mediumStart" | "mediumEnd" | "smallOnly" | "smallStart" | "smallEnd" | "extraSmallOnly" | "extraSmallStart" | "extraSmallEnd";
|
|
89
|
+
}>) => string);
|
|
90
|
+
export declare function capitalize(string?: string): string;
|
|
91
|
+
export declare function getIconPosition(size?: keyof typeof buttonModifiers.size, iconPosition?: IconPositions, children?: React.ReactNode): keyof typeof buttonModifiers.iconPosition;
|
|
92
|
+
/**
|
|
93
|
+
* The base button which all other buttons are built.
|
|
94
|
+
*/
|
|
31
95
|
export declare const BaseButton: import("@workday/canvas-kit-react/common").ElementComponent<"button", ButtonContainerProps> & {
|
|
32
|
-
Icon: import("@workday/canvas-kit-react/common").ElementComponent<"span", import("
|
|
33
|
-
Label: import("@workday/canvas-kit-react/common").ElementComponent<"span", import("
|
|
96
|
+
Icon: import("@workday/canvas-kit-react/common").ElementComponent<"span", import("../lib/parts/ButtonLabelIcon").ButtonLabelIconProps>;
|
|
97
|
+
Label: import("@workday/canvas-kit-react/common").ElementComponent<"span", import("../lib/parts/ButtonLabel").ButtonLabelProps>;
|
|
34
98
|
};
|
|
35
99
|
//# sourceMappingURL=BaseButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/BaseButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/BaseButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAkB,cAAc,EAAY,MAAM,kCAAkC,CAAC;AAE5F,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EAAC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,eAAe,CAAC,EAAE,cAAc;IACpF;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;CAAG;AAiB7E;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAC;AAkGF;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;cA4E1B,CAAC;AAEH,wBAAgB,UAAU,CAAC,MAAM,GAAE,MAAW,UAE7C;AAED,wBAAgB,eAAe,CAC7B,IAAI,CAAC,EAAE,MAAM,OAAO,eAAe,CAAC,IAAI,EACxC,YAAY,CAAC,EAAE,aAAa,EAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GACzB,MAAM,OAAO,eAAe,CAAC,YAAY,CAE3C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;;;CA8CrB,CAAC"}
|
|
@@ -19,227 +19,234 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.BaseButton = exports.
|
|
22
|
+
exports.BaseButton = exports.getIconPosition = exports.capitalize = exports.buttonModifiers = exports.buttonVars = void 0;
|
|
23
23
|
const React = __importStar(require("react"));
|
|
24
|
-
const ButtonLabelIcon_1 = require("
|
|
25
|
-
const ButtonLabel_1 = require("
|
|
24
|
+
const ButtonLabelIcon_1 = require("../lib/parts/ButtonLabelIcon");
|
|
25
|
+
const ButtonLabel_1 = require("../lib/parts/ButtonLabel");
|
|
26
26
|
const common_1 = require("@workday/canvas-kit-react/common");
|
|
27
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
27
28
|
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
28
29
|
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
31
|
+
/**
|
|
32
|
+
* Factory function for creating Button vars.
|
|
33
|
+
*/
|
|
34
|
+
const createButtonVars = () => canvas_kit_styling_1.createVars('background', 'border', 'boxShadowInner', 'boxShadowOuter', 'icon', 'label', 'opacity', 'borderRadius');
|
|
35
|
+
/**
|
|
36
|
+
* Temporary css variables to be used across all Buttons.
|
|
37
|
+
*/
|
|
38
|
+
exports.buttonVars = {
|
|
39
|
+
default: createButtonVars(),
|
|
40
|
+
hover: createButtonVars(),
|
|
41
|
+
active: createButtonVars(),
|
|
42
|
+
focus: createButtonVars(),
|
|
43
|
+
disabled: createButtonVars(),
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Base styles for Buttons.
|
|
47
|
+
*/
|
|
48
|
+
const baseButtonStyles = canvas_kit_styling_1.createStyles({
|
|
49
|
+
fontFamily: '"Roboto", "Helvetica Neue", "Helvetica", Arial, sans-serif',
|
|
50
|
+
fontSize: '0.875rem',
|
|
51
|
+
lineHeight: 'normal',
|
|
52
|
+
letterSpacing: '0.015rem',
|
|
53
|
+
fontWeight: 'bold',
|
|
54
|
+
backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.default.background, 'transparent'),
|
|
55
|
+
color: canvas_kit_styling_1.cssVar(exports.buttonVars.default.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
56
|
+
borderWidth: '1px',
|
|
57
|
+
borderStyle: 'solid',
|
|
58
|
+
gap: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x2, tokens_1.space.xxs),
|
|
59
|
+
borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.default.border, 'transparent'),
|
|
50
60
|
cursor: 'pointer',
|
|
51
61
|
display: 'inline-flex',
|
|
62
|
+
boxShadow: 'none',
|
|
52
63
|
alignItems: 'center',
|
|
53
64
|
justifyContent: 'center',
|
|
54
65
|
boxSizing: 'border-box',
|
|
55
|
-
|
|
56
|
-
outline: 'none',
|
|
57
|
-
fontWeight: tokens_1.type.properties.fontWeights.bold,
|
|
58
|
-
lineHeight: 'normal',
|
|
66
|
+
outline: '2px transparent',
|
|
59
67
|
whiteSpace: 'nowrap',
|
|
60
68
|
WebkitFontSmoothing: 'antialiased',
|
|
61
69
|
MozOsxFontSmoothing: 'grayscale',
|
|
62
|
-
borderRadius:
|
|
70
|
+
borderRadius: canvas_kit_styling_1.cssVar(exports.buttonVars.default.borderRadius, canvas_tokens_web_1.system.shape.circle),
|
|
63
71
|
position: 'relative',
|
|
64
72
|
verticalAlign: 'middle',
|
|
65
73
|
overflow: 'hidden',
|
|
66
|
-
border: '1px solid transparent',
|
|
67
|
-
background: 'transparent',
|
|
68
74
|
transition: 'box-shadow 120ms linear, border 120ms linear, background-color 120ms linear, color 120ms linear',
|
|
69
75
|
'&:disabled, &:disabled:active': {
|
|
70
76
|
cursor: 'default',
|
|
71
77
|
boxShadow: 'none',
|
|
72
|
-
opacity:
|
|
78
|
+
opacity: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.opacity, '1'),
|
|
73
79
|
},
|
|
74
|
-
'
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
'& span .wd-icon-fill': {
|
|
81
|
+
transitionDuration: '40ms',
|
|
82
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.default.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
77
83
|
},
|
|
78
|
-
'
|
|
79
|
-
|
|
84
|
+
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
85
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.default.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
80
86
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
'& > * ': {
|
|
97
|
-
margin: `0 ${tokens_1.space.xxxs}`,
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
case 'small':
|
|
101
|
-
return {
|
|
102
|
-
height: tokens_1.space.l,
|
|
103
|
-
'& > * ': {
|
|
104
|
-
margin: `0 ${tokens_1.spaceNumbers.xxxs / 2}rem`,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
case 'extraSmall':
|
|
108
|
-
return {
|
|
109
|
-
...tokens_1.type.levels.subtext.medium,
|
|
110
|
-
fontWeight: tokens_1.type.properties.fontWeights.bold,
|
|
111
|
-
height: tokens_1.space.m,
|
|
112
|
-
'& > * ': {
|
|
113
|
-
margin: `0 ${tokens_1.spaceNumbers.xxxs / 2}rem`,
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}, ({ grow }) => grow && { width: '100%', maxWidth: '100%' }, ({ colors, fillIcon, theme }) => {
|
|
118
|
-
if (!colors) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const baseStyles = {
|
|
122
|
-
...(colors.default.icon && {
|
|
123
|
-
'.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2, .wd-icon-background': {
|
|
124
|
-
transition: 'fill 120ms ease-in',
|
|
125
|
-
},
|
|
126
|
-
...getIconColorSelectors(theme, colors.default.icon, fillIcon),
|
|
87
|
+
'&:focus-visible, &.focus': {
|
|
88
|
+
backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.background, 'transparent'),
|
|
89
|
+
borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.border, 'transparent'),
|
|
90
|
+
color: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
91
|
+
'& span .wd-icon-fill': {
|
|
92
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
93
|
+
},
|
|
94
|
+
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
95
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
96
|
+
},
|
|
97
|
+
...common_1.focusRing({
|
|
98
|
+
width: 2,
|
|
99
|
+
separation: 2,
|
|
100
|
+
innerColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.boxShadowInner, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.frenchVanilla100)),
|
|
101
|
+
outerColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.boxShadowOuter, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.primary.base)),
|
|
127
102
|
}),
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
'
|
|
134
|
-
|
|
135
|
-
backgroundColor: colors.hover.background,
|
|
136
|
-
borderColor: colors.hover.border,
|
|
137
|
-
color: colors.hover.label,
|
|
103
|
+
},
|
|
104
|
+
'&:hover, &.hover': {
|
|
105
|
+
backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.background, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
|
|
106
|
+
borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.border, 'transparent'),
|
|
107
|
+
color: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
|
|
108
|
+
'& span .wd-icon-fill': {
|
|
109
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
|
|
138
110
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
'&:active, &:focus:active, &:hover:active': {
|
|
142
|
-
...(colors.active.icon && getIconColorSelectors(theme, colors.active.icon, fillIcon)),
|
|
143
|
-
backgroundColor: colors.active.background,
|
|
144
|
-
borderColor: colors.active.border,
|
|
145
|
-
color: colors.active.label,
|
|
111
|
+
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
112
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
|
|
146
113
|
},
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
color: colors.focus.label,
|
|
114
|
+
},
|
|
115
|
+
'&:hover:active': { transitionDuration: '40ms' },
|
|
116
|
+
'&:active, &.active': {
|
|
117
|
+
backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.active.background, 'transparent'),
|
|
118
|
+
borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.active.border, 'transparent'),
|
|
119
|
+
color: canvas_kit_styling_1.cssVar(exports.buttonVars.active.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
120
|
+
'& span .wd-icon-fill': {
|
|
121
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.active.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
156
122
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
123
|
+
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
124
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.active.icon),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
'&:disabled': {
|
|
128
|
+
backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.background, 'transparent'),
|
|
129
|
+
borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.border, 'transparent'),
|
|
130
|
+
color: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
131
|
+
'& span .wd-icon-fill': {
|
|
132
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
165
133
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
134
|
+
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
135
|
+
fill: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* Button modifiers that will overwrite the base styles of Buttons.
|
|
141
|
+
* - `Size`: These modifiers will dictate a size of a Button and has a set of styles to associated with it.
|
|
142
|
+
* - `iconPosition`: These modifiers will override the existing `Size` styles. These are specific to icon locations
|
|
143
|
+
* within a button or if there is only an icon and no text.
|
|
144
|
+
*/
|
|
145
|
+
exports.buttonModifiers = canvas_kit_styling_1.createModifiers({
|
|
146
|
+
size: {
|
|
147
|
+
large: canvas_kit_styling_1.createStyles({
|
|
148
|
+
fontSize: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
|
|
149
|
+
lineHeight: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
150
|
+
letterSpacing: '0.01rem',
|
|
151
|
+
height: '48px',
|
|
152
|
+
paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
|
|
153
|
+
minWidth: '112px',
|
|
175
154
|
}),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
155
|
+
medium: canvas_kit_styling_1.createStyles({
|
|
156
|
+
fontSize: '0.875rem',
|
|
157
|
+
letterSpacing: '0.015rem',
|
|
158
|
+
minWidth: '96px',
|
|
159
|
+
paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
160
|
+
height: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x10),
|
|
161
|
+
}),
|
|
162
|
+
small: canvas_kit_styling_1.createStyles({
|
|
163
|
+
fontSize: '0.875rem',
|
|
164
|
+
letterSpacing: '0.015rem',
|
|
165
|
+
height: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
|
|
166
|
+
minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x20),
|
|
167
|
+
paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
|
|
168
|
+
gap: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x1),
|
|
169
|
+
}),
|
|
170
|
+
extraSmall: canvas_kit_styling_1.createStyles({
|
|
171
|
+
fontSize: '0.75rem',
|
|
172
|
+
lineHeight: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
|
|
173
|
+
letterSpacing: '0.02rem',
|
|
174
|
+
height: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
175
|
+
minWidth: 'auto',
|
|
176
|
+
paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
|
|
177
|
+
gap: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x1),
|
|
178
|
+
}),
|
|
179
|
+
},
|
|
180
|
+
iconPosition: {
|
|
181
|
+
largeOnly: canvas_kit_styling_1.createStyles({
|
|
182
|
+
padding: '0',
|
|
183
|
+
minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x12),
|
|
184
|
+
}),
|
|
185
|
+
largeStart: canvas_kit_styling_1.createStyles({
|
|
186
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
187
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
|
|
188
|
+
}),
|
|
189
|
+
largeEnd: canvas_kit_styling_1.createStyles({
|
|
190
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
|
|
191
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
192
|
+
}),
|
|
193
|
+
mediumOnly: canvas_kit_styling_1.createStyles({ padding: '0', minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x10, tokens_1.space.xl) }),
|
|
194
|
+
mediumStart: canvas_kit_styling_1.createStyles({
|
|
195
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x5),
|
|
196
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
197
|
+
}),
|
|
198
|
+
mediumEnd: canvas_kit_styling_1.createStyles({
|
|
199
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
|
|
200
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x5),
|
|
201
|
+
}),
|
|
202
|
+
smallOnly: canvas_kit_styling_1.createStyles({ padding: '0', minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8, tokens_1.space.l) }),
|
|
203
|
+
smallStart: canvas_kit_styling_1.createStyles({
|
|
204
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
|
|
205
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
|
|
206
|
+
}),
|
|
207
|
+
smallEnd: canvas_kit_styling_1.createStyles({
|
|
208
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
|
|
209
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
|
|
210
|
+
}),
|
|
211
|
+
extraSmallOnly: canvas_kit_styling_1.createStyles({ padding: '0', minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6, tokens_1.space.m) }),
|
|
212
|
+
extraSmallStart: canvas_kit_styling_1.createStyles({
|
|
213
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x2),
|
|
214
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
|
|
215
|
+
}),
|
|
216
|
+
extraSmallEnd: canvas_kit_styling_1.createStyles({
|
|
217
|
+
paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
|
|
218
|
+
paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x2),
|
|
219
|
+
}),
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
function capitalize(string = '') {
|
|
223
|
+
return string.charAt(0).toUpperCase() + string.substring(1);
|
|
224
|
+
}
|
|
225
|
+
exports.capitalize = capitalize;
|
|
226
|
+
function getIconPosition(size, iconPosition, children) {
|
|
227
|
+
return `${size}${capitalize(iconPosition)}`;
|
|
228
|
+
}
|
|
229
|
+
exports.getIconPosition = getIconPosition;
|
|
230
|
+
/**
|
|
231
|
+
* The base button which all other buttons are built.
|
|
232
|
+
*/
|
|
239
233
|
exports.BaseButton = common_1.createComponent('button')({
|
|
240
|
-
displayName: '
|
|
241
|
-
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
242
|
-
|
|
234
|
+
displayName: 'BaseButton',
|
|
235
|
+
Component: ({ children, cs, size, fillIcon, iconPosition, icon, colors, shouldMirrorIcon = false, ...elemProps }, ref, Element) => {
|
|
236
|
+
// console.log('iconPosition', children, getIconPosition(size, iconPosition));
|
|
237
|
+
return (React.createElement(layout_1.Box, Object.assign({ as: Element, ref: ref, type: "button", cs: [
|
|
238
|
+
baseButtonStyles,
|
|
239
|
+
exports.buttonModifiers({
|
|
240
|
+
size: size,
|
|
241
|
+
iconPosition: getIconPosition(size, iconPosition, children),
|
|
242
|
+
}),
|
|
243
|
+
exports.buttonVars.default((colors === null || colors === void 0 ? void 0 : colors.default) || {}),
|
|
244
|
+
exports.buttonVars.focus((colors === null || colors === void 0 ? void 0 : colors.focus) || {}),
|
|
245
|
+
exports.buttonVars.hover((colors === null || colors === void 0 ? void 0 : colors.hover) || {}),
|
|
246
|
+
exports.buttonVars.active((colors === null || colors === void 0 ? void 0 : colors.active) || {}),
|
|
247
|
+
exports.buttonVars.disabled((colors === null || colors === void 0 ? void 0 : colors.disabled) || {}),
|
|
248
|
+
cs,
|
|
249
|
+
] }, elemProps), children));
|
|
243
250
|
},
|
|
244
251
|
subComponents: {
|
|
245
252
|
Icon: ButtonLabelIcon_1.ButtonLabelIcon,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ButtonContainerProps } from './BaseButton';
|
|
2
|
+
/**
|
|
3
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonContainerProps.
|
|
4
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
5
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
6
|
+
*/
|
|
7
|
+
export interface ButtonProps extends Omit<ButtonContainerProps, 'ref'> {
|
|
8
|
+
/**
|
|
9
|
+
* Button icon positions can either be `start` or `end`.
|
|
10
|
+
* If no value is provided, it defaults to `start`.
|
|
11
|
+
*
|
|
12
|
+
* @default 'start'
|
|
13
|
+
*/
|
|
14
|
+
iconPosition?: 'start' | 'end';
|
|
15
|
+
}
|
|
16
|
+
export declare const Button: import("@workday/canvas-kit-react/common").ElementComponent<"button", ButtonProps>;
|
|
17
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../button/lib/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAG9D;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;IACpE;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CAChC;AAED,eAAO,MAAM,MAAM,oFA8CjB,CAAC"}
|