@workday/canvas-kit-react 15.0.0-alpha.0074-next.0 → 15.0.0-alpha.0075-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/pill/index.d.ts +8 -0
- package/dist/commonjs/pill/index.d.ts.map +1 -0
- package/dist/commonjs/pill/index.js +23 -0
- package/dist/commonjs/pill/lib/Pill.d.ts +265 -0
- package/dist/commonjs/pill/lib/Pill.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/Pill.js +147 -0
- package/dist/commonjs/pill/lib/PillAvatar.d.ts +526 -0
- package/dist/commonjs/pill/lib/PillAvatar.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/PillAvatar.js +22 -0
- package/dist/commonjs/pill/lib/PillCount.d.ts +12 -0
- package/dist/commonjs/pill/lib/PillCount.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/PillCount.js +21 -0
- package/dist/commonjs/pill/lib/PillIcon.d.ts +54 -0
- package/dist/commonjs/pill/lib/PillIcon.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/PillIcon.js +20 -0
- package/dist/commonjs/pill/lib/PillIconButton.d.ts +148 -0
- package/dist/commonjs/pill/lib/PillIconButton.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/PillIconButton.js +21 -0
- package/dist/commonjs/pill/lib/PillLabel.d.ts +14 -0
- package/dist/commonjs/pill/lib/PillLabel.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/PillLabel.js +17 -0
- package/dist/commonjs/pill/lib/usePillModel.d.ts +46 -0
- package/dist/commonjs/pill/lib/usePillModel.d.ts.map +1 -0
- package/dist/commonjs/pill/lib/usePillModel.js +24 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControl.js +1 -1
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/dist/es6/pill/index.d.ts +8 -0
- package/dist/es6/pill/index.d.ts.map +1 -0
- package/dist/es6/pill/index.js +7 -0
- package/dist/es6/pill/lib/Pill.d.ts +265 -0
- package/dist/es6/pill/lib/Pill.d.ts.map +1 -0
- package/dist/es6/pill/lib/Pill.js +144 -0
- package/dist/es6/pill/lib/PillAvatar.d.ts +526 -0
- package/dist/es6/pill/lib/PillAvatar.d.ts.map +1 -0
- package/dist/es6/pill/lib/PillAvatar.js +19 -0
- package/dist/es6/pill/lib/PillCount.d.ts +12 -0
- package/dist/es6/pill/lib/PillCount.d.ts.map +1 -0
- package/dist/es6/pill/lib/PillCount.js +18 -0
- package/dist/es6/pill/lib/PillIcon.d.ts +54 -0
- package/dist/es6/pill/lib/PillIcon.d.ts.map +1 -0
- package/dist/es6/pill/lib/PillIcon.js +17 -0
- package/dist/es6/pill/lib/PillIconButton.d.ts +148 -0
- package/dist/es6/pill/lib/PillIconButton.d.ts.map +1 -0
- package/dist/es6/pill/lib/PillIconButton.js +18 -0
- package/dist/es6/pill/lib/PillLabel.d.ts +14 -0
- package/dist/es6/pill/lib/PillLabel.d.ts.map +1 -0
- package/dist/es6/pill/lib/PillLabel.js +14 -0
- package/dist/es6/pill/lib/usePillModel.d.ts +46 -0
- package/dist/es6/pill/lib/usePillModel.d.ts.map +1 -0
- package/dist/es6/pill/lib/usePillModel.js +21 -0
- package/dist/es6/segmented-control/lib/SegmentedControl.d.ts +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControl.js +1 -1
- package/index.ts +1 -0
- package/package.json +5 -5
- package/pill/index.ts +7 -0
- package/pill/lib/Pill.tsx +285 -0
- package/pill/lib/PillAvatar.tsx +35 -0
- package/pill/lib/PillCount.tsx +44 -0
- package/pill/lib/PillIcon.tsx +32 -0
- package/pill/lib/PillIconButton.tsx +86 -0
- package/pill/lib/PillLabel.tsx +32 -0
- package/pill/lib/usePillModel.tsx +23 -0
- package/pill/package.json +6 -0
- package/segmented-control/lib/SegmentedControl.tsx +1 -1
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __exportStar(require("./layout"), exports);
|
|
|
36
36
|
__exportStar(require("./loading-dots"), exports);
|
|
37
37
|
__exportStar(require("./menu"), exports);
|
|
38
38
|
__exportStar(require("./modal"), exports);
|
|
39
|
+
__exportStar(require("./pill"), exports);
|
|
39
40
|
__exportStar(require("./pagination"), exports);
|
|
40
41
|
__exportStar(require("./popup"), exports);
|
|
41
42
|
__exportStar(require("./radio"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './lib/Pill';
|
|
2
|
+
export * from './lib/usePillModel';
|
|
3
|
+
export * from './lib/PillCount';
|
|
4
|
+
export * from './lib/PillIconButton';
|
|
5
|
+
export * from './lib/PillIcon';
|
|
6
|
+
export * from './lib/PillLabel';
|
|
7
|
+
export * from './lib/Pill';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../pill/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/Pill"), exports);
|
|
18
|
+
__exportStar(require("./lib/usePillModel"), exports);
|
|
19
|
+
__exportStar(require("./lib/PillCount"), exports);
|
|
20
|
+
__exportStar(require("./lib/PillIconButton"), exports);
|
|
21
|
+
__exportStar(require("./lib/PillIcon"), exports);
|
|
22
|
+
__exportStar(require("./lib/PillLabel"), exports);
|
|
23
|
+
__exportStar(require("./lib/Pill"), exports);
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { BoxProps } from '@workday/canvas-kit-react/layout';
|
|
2
|
+
export interface PillProps extends BoxProps {
|
|
3
|
+
/**
|
|
4
|
+
* Defines what kind of pill to render stylistically and its interaction states
|
|
5
|
+
* @default 'default'
|
|
6
|
+
*/
|
|
7
|
+
variant?: 'readOnly' | 'removable';
|
|
8
|
+
/**
|
|
9
|
+
* Determines the max width of the pill. If the pill text is longer than the max width,
|
|
10
|
+
* text will be truncated and a tooltip will show the rest of the content when hovered over
|
|
11
|
+
*/
|
|
12
|
+
maxWidth?: string | number;
|
|
13
|
+
}
|
|
14
|
+
export declare const pillStencil: import("@workday/canvas-kit-styling").Stencil<{
|
|
15
|
+
variant: {
|
|
16
|
+
readOnly: {
|
|
17
|
+
[x: string]: string | {
|
|
18
|
+
[x: string]: "--cnvs-sys-color-bg-default" | "--cnvs-sys-color-border-container";
|
|
19
|
+
borderColor: "--cnvs-sys-color-border-container";
|
|
20
|
+
} | {
|
|
21
|
+
[x: string]: "--cnvs-sys-color-bg-default";
|
|
22
|
+
borderColor?: undefined;
|
|
23
|
+
};
|
|
24
|
+
border: string;
|
|
25
|
+
cursor: string;
|
|
26
|
+
'&:hover, &.hover': {
|
|
27
|
+
[x: string]: "--cnvs-sys-color-bg-default" | "--cnvs-sys-color-border-container";
|
|
28
|
+
borderColor: "--cnvs-sys-color-border-container";
|
|
29
|
+
};
|
|
30
|
+
'&:focus-visible, &.focus': {
|
|
31
|
+
[x: string]: "--cnvs-sys-color-bg-default";
|
|
32
|
+
};
|
|
33
|
+
'&:active, &.active': {
|
|
34
|
+
[x: string]: "--cnvs-sys-color-bg-default";
|
|
35
|
+
};
|
|
36
|
+
'&:disabled, &.disabled': {
|
|
37
|
+
[x: string]: "--cnvs-sys-color-bg-default";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
removable: {
|
|
41
|
+
'&:focus-visible, &.focus': {
|
|
42
|
+
[x: string]: string;
|
|
43
|
+
boxShadow: string;
|
|
44
|
+
};
|
|
45
|
+
'&:hover, &.hover': {
|
|
46
|
+
[x: string]: "--cnvs-sys-color-bg-alt-strong";
|
|
47
|
+
};
|
|
48
|
+
'&:active, &.active': {
|
|
49
|
+
[x: string]: "--cnvs-sys-color-bg-alt-stronger";
|
|
50
|
+
};
|
|
51
|
+
'&:disabled, &.disabled': {
|
|
52
|
+
[x: string]: string;
|
|
53
|
+
};
|
|
54
|
+
cursor: string;
|
|
55
|
+
overflow: string;
|
|
56
|
+
position: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}, {}, {
|
|
60
|
+
maxWidth: string;
|
|
61
|
+
}, import("@workday/canvas-kit-styling").Stencil<{
|
|
62
|
+
size: {
|
|
63
|
+
large: {
|
|
64
|
+
fontWeight: "--cnvs-sys-font-weight-bold";
|
|
65
|
+
height: "var(--cnvs-sys-size-xl, 3rem)";
|
|
66
|
+
paddingInline: "var(--cnvs-sys-padding-xxl, var(--cnvs-sys-space-x8))";
|
|
67
|
+
minWidth: "--cnvs-base-size-1400";
|
|
68
|
+
fontFamily: "--cnvs-sys-font-family-default";
|
|
69
|
+
lineHeight: "var(--cnvs-sys-line-height-body-sm, var(--cnvs-sys-line-height-body-small))";
|
|
70
|
+
fontSize: "var(--cnvs-sys-font-size-body-sm, var(--cnvs-sys-font-size-body-small))";
|
|
71
|
+
letterSpacing: "var(--cnvs-sys-letter-spacing-body-sm, var(--cnvs-base-letter-spacing-200))";
|
|
72
|
+
};
|
|
73
|
+
medium: {
|
|
74
|
+
fontWeight: "--cnvs-sys-font-weight-bold";
|
|
75
|
+
minWidth: "--cnvs-base-size-1200";
|
|
76
|
+
paddingInline: "var(--cnvs-sys-padding-xl, var(--cnvs-sys-space-x6))";
|
|
77
|
+
height: "var(--cnvs-sys-size-lg, var(--cnvs-sys-space-x10))";
|
|
78
|
+
fontFamily: "var(--cnvs-sys-font-family-default, var(--cnvs-sys-font-family-default))";
|
|
79
|
+
lineHeight: "var(--cnvs-sys-line-height-subtext-lg, var(--cnvs-sys-line-height-subtext-large))";
|
|
80
|
+
fontSize: "var(--cnvs-sys-font-size-subtext-lg, var(--cnvs-sys-font-size-subtext-large))";
|
|
81
|
+
letterSpacing: "var(--cnvs-sys-letter-spacing-subtext-lg, var(--cnvs-base-letter-spacing-50))";
|
|
82
|
+
};
|
|
83
|
+
small: {
|
|
84
|
+
fontWeight: "--cnvs-sys-font-weight-bold";
|
|
85
|
+
height: "var(--cnvs-sys-size-md, var(--cnvs-sys-space-x8))";
|
|
86
|
+
minWidth: "--cnvs-base-size-1000";
|
|
87
|
+
paddingInline: "var(--cnvs-sys-padding-md, var(--cnvs-sys-space-x4))";
|
|
88
|
+
gap: "var(--cnvs-sys-gap-xs, var(--cnvs-sys-space-x1))";
|
|
89
|
+
fontFamily: "var(--cnvs-sys-font-family-default, var(--cnvs-sys-font-family-default))";
|
|
90
|
+
lineHeight: "var(--cnvs-sys-line-height-subtext-lg, var(--cnvs-sys-line-height-subtext-large))";
|
|
91
|
+
fontSize: "var(--cnvs-sys-font-size-subtext-lg, var(--cnvs-sys-font-size-subtext-large))";
|
|
92
|
+
letterSpacing: "var(--cnvs-sys-letter-spacing-subtext-lg, var(--cnvs-base-letter-spacing-50))";
|
|
93
|
+
};
|
|
94
|
+
extraSmall: {
|
|
95
|
+
fontWeight: "--cnvs-sys-font-weight-bold";
|
|
96
|
+
height: "var(--cnvs-sys-size-sm, var(--cnvs-sys-space-x6))";
|
|
97
|
+
minWidth: string;
|
|
98
|
+
paddingInline: "var(--cnvs-sys-padding-sm, var(--cnvs-sys-space-x3))";
|
|
99
|
+
gap: "var(--cnvs-sys-gap-xs, var(--cnvs-sys-space-x1))";
|
|
100
|
+
fontFamily: "var(--cnvs-sys-font-family-default, var(--cnvs-sys-font-family-default))";
|
|
101
|
+
lineHeight: "var(--cnvs-sys-line-height-subtext-md, var(--cnvs-sys-line-height-subtext-medium))";
|
|
102
|
+
fontSize: "var(--cnvs-sys-font-size-subtext-md, var(--cnvs-sys-font-size-subtext-medium))";
|
|
103
|
+
letterSpacing: "var(--cnvs-sys-letter-spacing-subtext-md, var(--cnvs-base-letter-spacing-100))";
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
grow: {
|
|
107
|
+
true: {
|
|
108
|
+
width: string;
|
|
109
|
+
maxWidth: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
iconPosition: {
|
|
113
|
+
only: {
|
|
114
|
+
padding: "var(--cnvs-sys-padding-none, var(--cnvs-sys-space-zero))";
|
|
115
|
+
};
|
|
116
|
+
start: {};
|
|
117
|
+
end: {};
|
|
118
|
+
};
|
|
119
|
+
}, {}, {
|
|
120
|
+
background: string;
|
|
121
|
+
border: string;
|
|
122
|
+
boxShadowInner: string;
|
|
123
|
+
boxShadowOuter: string;
|
|
124
|
+
label: string;
|
|
125
|
+
opacity: string;
|
|
126
|
+
borderRadius: string;
|
|
127
|
+
}, never, never>, never>;
|
|
128
|
+
/**
|
|
129
|
+
* By default, a `Pill` renders an interactive element that accepts subcomponents. By "interactive"
|
|
130
|
+
* we mean that the Pill container is a focusable element (a `<button>`). All leading elements
|
|
131
|
+
* (icons or avatars) are intended to be descriptive, helping support the label. They should not
|
|
132
|
+
* receive focus.
|
|
133
|
+
*
|
|
134
|
+
* `Pill` is the container component. It also provides a React context model for its subcomponents.
|
|
135
|
+
* Based on the `variant` prop this component will render different styled `Pill`s.
|
|
136
|
+
*
|
|
137
|
+
* Example of read only:
|
|
138
|
+
*
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <Pill variant="readOnly">This is a read only</Pill>
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* Example of interactive:
|
|
144
|
+
*
|
|
145
|
+
* ```tsx
|
|
146
|
+
* <Pill onClick={() => console.log('clicked')}>
|
|
147
|
+
* <Pill.Avatar /> Regina Skeltor
|
|
148
|
+
* </Pill>
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* Example of removable:
|
|
152
|
+
*
|
|
153
|
+
* ```tsx
|
|
154
|
+
* <Pill variant="removable">
|
|
155
|
+
* <Pill.Avatar /> Regina Skeltor
|
|
156
|
+
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('clicked')} />
|
|
157
|
+
* </Pill>
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* If you set the `Pill` `variant` to `removable`, it will render a `<span>` element. You can then
|
|
161
|
+
* provide a `Pill.IconButton` that acts as the focus target. This creates a smaller, more
|
|
162
|
+
* intentional click target that prevents users from accidentally deleting an item.
|
|
163
|
+
*
|
|
164
|
+
* ```tsx
|
|
165
|
+
* <Pill variant="removable">
|
|
166
|
+
* Shoes
|
|
167
|
+
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('handle remove')} />
|
|
168
|
+
* </Pill>
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare const Pill: import("@workday/canvas-kit-react/common").ElementComponentM<"button", PillProps & Partial<{
|
|
172
|
+
disabled: boolean;
|
|
173
|
+
id: string;
|
|
174
|
+
}> & {} & {}, {
|
|
175
|
+
state: {
|
|
176
|
+
id: string;
|
|
177
|
+
disabled: boolean;
|
|
178
|
+
};
|
|
179
|
+
events: {};
|
|
180
|
+
}> & {
|
|
181
|
+
/**
|
|
182
|
+
* This component renders an avatar. It supports all props of the `Avatar` component.
|
|
183
|
+
*
|
|
184
|
+
* ```tsx
|
|
185
|
+
* <Pill variant="removable">
|
|
186
|
+
* <Pill.Avatar url={avatarUrl} />
|
|
187
|
+
* <Pill.Label>Regina Skeltor</Pill.Label>
|
|
188
|
+
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('handle remove')} />
|
|
189
|
+
* </Pill>
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
Avatar: import("@workday/canvas-kit-react/common").ElementComponentM<"div", import("./PillAvatar").PillAvatarProps, {
|
|
193
|
+
state: {
|
|
194
|
+
id: string;
|
|
195
|
+
disabled: boolean;
|
|
196
|
+
};
|
|
197
|
+
events: {};
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* This component renders its `children` as the count.
|
|
201
|
+
*
|
|
202
|
+
* ```tsx
|
|
203
|
+
* <Pill onClick={() => console.warn('clicked')}>
|
|
204
|
+
* <Pill.Label>Shoes</Pill.Label>
|
|
205
|
+
* <Pill.Count>30</Pill.Count>
|
|
206
|
+
* </Pill>
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
Count: import("@workday/canvas-kit-react/common").ElementComponent<"span", import("./PillCount").PillCountProps>;
|
|
210
|
+
/**
|
|
211
|
+
* This component renders an `icon`. By default it renders a `plusIcon` but it can be overridden by
|
|
212
|
+
* providing an icon to the `icon` prop. You must provide an `aria-label` for the icon.
|
|
213
|
+
*
|
|
214
|
+
* ```tsx
|
|
215
|
+
* <Pill onClick={() => console.warn('clicked')}>
|
|
216
|
+
* <Pill.Icon aria-label='Add user' />
|
|
217
|
+
* <Pill.Label>Regina Skeltor</Pill.Label>
|
|
218
|
+
* </Pill>
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
Icon: import("@workday/canvas-kit-react/common").ElementComponentM<"span", import("./PillIcon").PillIconProps, {
|
|
222
|
+
state: {
|
|
223
|
+
id: string;
|
|
224
|
+
disabled: boolean;
|
|
225
|
+
};
|
|
226
|
+
events: {};
|
|
227
|
+
}>;
|
|
228
|
+
/**
|
|
229
|
+
* This component renders a custom icon button. It is only intended to be used with the
|
|
230
|
+
* `removable` variant. By default, it renders a `xSmallIcon` but can be overridden by providing
|
|
231
|
+
* an icon to the `icon` prop.
|
|
232
|
+
*
|
|
233
|
+
* ```tsx
|
|
234
|
+
* <Pill variant="removable">
|
|
235
|
+
* <Pill.Label>Pink Shirts</Pill.Label>
|
|
236
|
+
* <Pill.IconButton aria-label='Remove item' onClick={() => console.warn('clicked')} />
|
|
237
|
+
* </Pill>
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
IconButton: import("@workday/canvas-kit-react/common").ElementComponentM<"button", import("./PillIconButton").PillIconButtonProps, {
|
|
241
|
+
state: {
|
|
242
|
+
id: string;
|
|
243
|
+
disabled: boolean;
|
|
244
|
+
};
|
|
245
|
+
events: {};
|
|
246
|
+
}>;
|
|
247
|
+
/**
|
|
248
|
+
* This component renders a `<span>` that automatically handles overflow by rendering a tooltip.
|
|
249
|
+
* There's no need to use this component directly since the overflow is handled for you automatically unless you have an icon or other element.
|
|
250
|
+
*
|
|
251
|
+
* ```tsx
|
|
252
|
+
* <Pill variant="readOnly">
|
|
253
|
+
* <Pill.Label>Read-only</Pill.Label>
|
|
254
|
+
* </Pill>
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
Label: import("@workday/canvas-kit-react/common").ElementComponentM<"span", import("./PillLabel").PillLabelProps, {
|
|
258
|
+
state: {
|
|
259
|
+
id: string;
|
|
260
|
+
disabled: boolean;
|
|
261
|
+
};
|
|
262
|
+
events: {};
|
|
263
|
+
}>;
|
|
264
|
+
};
|
|
265
|
+
//# sourceMappingURL=Pill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pill.d.ts","sourceRoot":"","sources":["../../../../pill/lib/Pill.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAM,QAAQ,EAAc,MAAM,kCAAkC,CAAC;AAa5E,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwHtB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;IAIb;;;;;;;;;;OAUG;;;;;;;;IAEH;;;;;;;;;OASG;;IAEH;;;;;;;;;;OAUG;;;;;;;;IAEH;;;;;;;;;;;OAWG;;;;;;;;IAEH;;;;;;;;;OASG;;;;;;;;CA8BL,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pill = exports.pillStencil = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
6
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
7
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
8
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
9
|
+
const usePillModel_1 = require("./usePillModel");
|
|
10
|
+
const PillIcon_1 = require("./PillIcon");
|
|
11
|
+
const PillIconButton_1 = require("./PillIconButton");
|
|
12
|
+
const PillCount_1 = require("./PillCount");
|
|
13
|
+
const PillAvatar_1 = require("./PillAvatar");
|
|
14
|
+
const PillLabel_1 = require("./PillLabel");
|
|
15
|
+
const icon_1 = require("@workday/canvas-kit-react/icon");
|
|
16
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
17
|
+
exports.pillStencil = (0, canvas_kit_styling_1.createStencil)({
|
|
18
|
+
extends: button_1.buttonStencil,
|
|
19
|
+
vars: {
|
|
20
|
+
maxWidth: '',
|
|
21
|
+
},
|
|
22
|
+
base: { name: "24wm92", styles: "box-sizing:border-box;display:initial;flex-direction:row;align-items:center;border-radius:var(--cnvs-sys-shape-x1);font-family:var(--cnvs-sys-font-family-default);font-weight:var(--cnvs-sys-font-weight-medium);line-height:var(--cnvs-sys-line-height-subtext-small);font-size:var(--cnvs-sys-font-size-subtext-large);letter-spacing:var(--cnvs-base-letter-spacing-150);box-shadow:none;outline:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:fit-content;padding:0.125rem var(--cnvs-sys-space-x2);height:var(--cnvs-sys-space-x6);position:relative;gap:var(--cnvs-sys-space-x1);max-width:var(--maxWidth-pill-4ef1a0);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-default);--border-button-f6d2bd:var(--cnvs-sys-color-border-input-default);--label-button-f6d2bd:var(--cnvs-sys-color-fg-strong);--color-system-icon-3a4847:currentColor;--borderColor-pill-count-d52af1:transparent;&:has(span){display:flex;line-height:var(--cnvs-sys-line-height-subtext-large);}&:hover, &.hover{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-strong);--border-button-f6d2bd:var(--cnvs-sys-color-border-input-strong);--label-button-f6d2bd:var(--cnvs-sys-color-fg-strong);--color-system-icon-3a4847:currentColor;--backgroundColor-pill-count-d52af1:var(--cnvs-sys-color-bg-muted-softer);--borderColor-pill-count-d52af1:transparent;}&:active, &.active{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-stronger);--border-button-f6d2bd:var(--cnvs-sys-color-border-input-strong);--label-button-f6d2bd:var(--cnvs-sys-color-fg-strong);--color-system-icon-3a4847:currentColor;--backgroundColor-pill-count-d52af1:var(--cnvs-sys-color-bg-muted-softer);--borderColor-pill-count-d52af1:transparent;}&:focus-visible, &.focus{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-default);--border-button-f6d2bd:var(--cnvs-sys-color-border-primary-default);--label-button-f6d2bd:var(--cnvs-sys-color-fg-strong);border-color:var(--cnvs-sys-color-border-primary-default);--color-system-icon-3a4847:currentColor;--borderColor-pill-count-d52af1:var(--cnvs-sys-color-border-primary-default);box-shadow:inset 0 0 0 1px var(--cnvs-sys-color-border-primary-default), 0 0 0 0px var(--cnvs-sys-color-border-primary-default);}&:disabled, &.disabled{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-default);--border-button-f6d2bd:var(--cnvs-sys-color-border-input-disabled);--label-button-f6d2bd:var(--cnvs-sys-color-fg-disabled);--color-system-icon-3a4847:currentColor;--backgroundColor-pill-count-d52af1:var(--cnvs-sys-color-bg-alt-strong);--borderColor-pill-count-d52af1:transparent;}" },
|
|
23
|
+
modifiers: {
|
|
24
|
+
variant: {
|
|
25
|
+
readOnly: { name: "3l435h", styles: "border:0.0625rem solid var(--cnvs-sys-color-border-container);cursor:default;--background-button-f6d2bd:var(--cnvs-sys-color-bg-default);&:hover, &.hover{border-color:var(--cnvs-sys-color-border-container);--background-button-f6d2bd:var(--cnvs-sys-color-bg-default);}&:focus-visible, &.focus{--background-button-f6d2bd:var(--cnvs-sys-color-bg-default);}&:active, &.active{--background-button-f6d2bd:var(--cnvs-sys-color-bg-default);}&:disabled, &.disabled{--background-button-f6d2bd:var(--cnvs-sys-color-bg-default);}" },
|
|
26
|
+
removable: { name: "s6l79", styles: "&:focus-visible, &.focus{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-default);--border-button-f6d2bd:var(--cnvs-sys-color-border-input-default);--label-button-f6d2bd:var(--cnvs-sys-color-fg-strong);box-shadow:none;}&:hover, &.hover{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-strong);}&:active, &.active{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-stronger);}&:disabled, &.disabled{--background-button-f6d2bd:var(--cnvs-sys-color-bg-alt-default);--color-system-icon-3a4847:currentColor;}cursor:default;overflow:revert;position:relative;" }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, "pill-4ef1a0");
|
|
30
|
+
/**
|
|
31
|
+
* By default, a `Pill` renders an interactive element that accepts subcomponents. By "interactive"
|
|
32
|
+
* we mean that the Pill container is a focusable element (a `<button>`). All leading elements
|
|
33
|
+
* (icons or avatars) are intended to be descriptive, helping support the label. They should not
|
|
34
|
+
* receive focus.
|
|
35
|
+
*
|
|
36
|
+
* `Pill` is the container component. It also provides a React context model for its subcomponents.
|
|
37
|
+
* Based on the `variant` prop this component will render different styled `Pill`s.
|
|
38
|
+
*
|
|
39
|
+
* Example of read only:
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <Pill variant="readOnly">This is a read only</Pill>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Example of interactive:
|
|
46
|
+
*
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <Pill onClick={() => console.log('clicked')}>
|
|
49
|
+
* <Pill.Avatar /> Regina Skeltor
|
|
50
|
+
* </Pill>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* Example of removable:
|
|
54
|
+
*
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <Pill variant="removable">
|
|
57
|
+
* <Pill.Avatar /> Regina Skeltor
|
|
58
|
+
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('clicked')} />
|
|
59
|
+
* </Pill>
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* If you set the `Pill` `variant` to `removable`, it will render a `<span>` element. You can then
|
|
63
|
+
* provide a `Pill.IconButton` that acts as the focus target. This creates a smaller, more
|
|
64
|
+
* intentional click target that prevents users from accidentally deleting an item.
|
|
65
|
+
*
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Pill variant="removable">
|
|
68
|
+
* Shoes
|
|
69
|
+
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('handle remove')} />
|
|
70
|
+
* </Pill>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
exports.Pill = (0, common_1.createContainer)('button')({
|
|
74
|
+
displayName: 'Pill',
|
|
75
|
+
modelHook: usePillModel_1.usePillModel,
|
|
76
|
+
subComponents: {
|
|
77
|
+
/**
|
|
78
|
+
* This component renders an avatar. It supports all props of the `Avatar` component.
|
|
79
|
+
*
|
|
80
|
+
* ```tsx
|
|
81
|
+
* <Pill variant="removable">
|
|
82
|
+
* <Pill.Avatar url={avatarUrl} />
|
|
83
|
+
* <Pill.Label>Regina Skeltor</Pill.Label>
|
|
84
|
+
* <Pill.IconButton aria-label='Remove user' onClick={() => console.log('handle remove')} />
|
|
85
|
+
* </Pill>
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
Avatar: PillAvatar_1.PillAvatar,
|
|
89
|
+
/**
|
|
90
|
+
* This component renders its `children` as the count.
|
|
91
|
+
*
|
|
92
|
+
* ```tsx
|
|
93
|
+
* <Pill onClick={() => console.warn('clicked')}>
|
|
94
|
+
* <Pill.Label>Shoes</Pill.Label>
|
|
95
|
+
* <Pill.Count>30</Pill.Count>
|
|
96
|
+
* </Pill>
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
Count: PillCount_1.PillCount,
|
|
100
|
+
/**
|
|
101
|
+
* This component renders an `icon`. By default it renders a `plusIcon` but it can be overridden by
|
|
102
|
+
* providing an icon to the `icon` prop. You must provide an `aria-label` for the icon.
|
|
103
|
+
*
|
|
104
|
+
* ```tsx
|
|
105
|
+
* <Pill onClick={() => console.warn('clicked')}>
|
|
106
|
+
* <Pill.Icon aria-label='Add user' />
|
|
107
|
+
* <Pill.Label>Regina Skeltor</Pill.Label>
|
|
108
|
+
* </Pill>
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
Icon: PillIcon_1.PillIcon,
|
|
112
|
+
/**
|
|
113
|
+
* This component renders a custom icon button. It is only intended to be used with the
|
|
114
|
+
* `removable` variant. By default, it renders a `xSmallIcon` but can be overridden by providing
|
|
115
|
+
* an icon to the `icon` prop.
|
|
116
|
+
*
|
|
117
|
+
* ```tsx
|
|
118
|
+
* <Pill variant="removable">
|
|
119
|
+
* <Pill.Label>Pink Shirts</Pill.Label>
|
|
120
|
+
* <Pill.IconButton aria-label='Remove item' onClick={() => console.warn('clicked')} />
|
|
121
|
+
* </Pill>
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
IconButton: PillIconButton_1.PillIconButton,
|
|
125
|
+
/**
|
|
126
|
+
* This component renders a `<span>` that automatically handles overflow by rendering a tooltip.
|
|
127
|
+
* There's no need to use this component directly since the overflow is handled for you automatically unless you have an icon or other element.
|
|
128
|
+
*
|
|
129
|
+
* ```tsx
|
|
130
|
+
* <Pill variant="readOnly">
|
|
131
|
+
* <Pill.Label>Read-only</Pill.Label>
|
|
132
|
+
* </Pill>
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
Label: PillLabel_1.PillLabel,
|
|
136
|
+
},
|
|
137
|
+
})(({ variant, maxWidth = 200, children, ...elemProps }, Element, model) => {
|
|
138
|
+
const maxWidthCSSValue = typeof maxWidth === 'number' ? (0, canvas_kit_styling_1.px2rem)(maxWidth) : maxWidth;
|
|
139
|
+
const isReadOnly = variant === 'readOnly';
|
|
140
|
+
return (variant === null || variant === void 0 ? void 0 : variant.match(/^(readOnly|removable)$/)) ? ((0, jsx_runtime_1.jsx)(layout_1.Box, { as: Element !== 'button' ? Element : 'span', id: isReadOnly ? model.state.id : undefined, ...(0, layout_1.mergeStyles)(elemProps, [
|
|
141
|
+
model.state.disabled ? 'disabled' : undefined,
|
|
142
|
+
(0, exports.pillStencil)({ maxWidth: maxWidthCSSValue, variant }),
|
|
143
|
+
]), children: isReadOnly ? (0, jsx_runtime_1.jsx)(PillLabel_1.PillLabel, { children: children }) : children })) : ((0, jsx_runtime_1.jsx)(Element, { disabled: model.state.disabled, ...(0, layout_1.mergeStyles)(elemProps, [
|
|
144
|
+
model.state.disabled ? 'disabled' : undefined,
|
|
145
|
+
(0, exports.pillStencil)({ maxWidth: maxWidthCSSValue }),
|
|
146
|
+
]), children: children }));
|
|
147
|
+
});
|