@workday/canvas-kit-preview-react 8.0.0-alpha.235-next.6 → 8.0.0-alpha.237-next.8
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/menu/lib/Menu.d.ts.map +1 -1
- package/dist/commonjs/menu/lib/Menu.js +0 -2
- package/dist/commonjs/segmented-control/index.d.ts +3 -0
- package/dist/commonjs/segmented-control/index.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/index.js +14 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts +1562 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControl.js +22 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts +126 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +130 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts +89 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +64 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +60 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.js +44 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +1613 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.js +74 -0
- 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/menu/lib/Menu.d.ts.map +1 -1
- package/dist/es6/menu/lib/Menu.js +0 -2
- package/dist/es6/segmented-control/index.d.ts +3 -0
- package/dist/es6/segmented-control/index.d.ts.map +1 -0
- package/dist/es6/segmented-control/index.js +2 -0
- package/dist/es6/segmented-control/lib/SegmentedControl.d.ts +1562 -0
- package/dist/es6/segmented-control/lib/SegmentedControl.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/SegmentedControl.js +16 -0
- package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts +126 -0
- package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/SegmentedControlItem.js +108 -0
- package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts +89 -0
- package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/SegmentedControlList.js +42 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +60 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.js +41 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +1613 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.js +68 -0
- package/index.ts +1 -0
- package/menu/lib/Menu.tsx +0 -2
- package/package.json +4 -4
- package/segmented-control/LICENSE +126 -0
- package/segmented-control/README.md +6 -0
- package/segmented-control/index.ts +2 -0
- package/segmented-control/lib/SegmentedControl.tsx +21 -0
- package/segmented-control/lib/SegmentedControlItem.tsx +175 -0
- package/segmented-control/lib/SegmentedControlList.tsx +48 -0
- package/segmented-control/lib/hooks/useSegmentedControlItem.tsx +74 -0
- package/segmented-control/lib/hooks/useSegmentedControlModel.tsx +81 -0
- package/segmented-control/package.json +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../../segmented-control/lib/SegmentedControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS3B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SegmentedControl = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var common_1 = require("@workday/canvas-kit-react/common");
|
|
9
|
+
var useSegmentedControlModel_1 = require("./hooks/useSegmentedControlModel");
|
|
10
|
+
var SegmentedControlList_1 = require("./SegmentedControlList");
|
|
11
|
+
var SegmentedControlItem_1 = require("./SegmentedControlItem");
|
|
12
|
+
exports.SegmentedControl = common_1.createContainer()({
|
|
13
|
+
displayName: 'SegmentedControl',
|
|
14
|
+
modelHook: useSegmentedControlModel_1.useSegmentedControlModel,
|
|
15
|
+
subComponents: {
|
|
16
|
+
List: SegmentedControlList_1.SegmentedControlList,
|
|
17
|
+
Item: SegmentedControlItem_1.SegmentedControlItem,
|
|
18
|
+
},
|
|
19
|
+
})(function (_a) {
|
|
20
|
+
var children = _a.children;
|
|
21
|
+
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
22
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TooltipProps } from '@workday/canvas-kit-react/tooltip';
|
|
3
|
+
import { ButtonContainerProps } from '@workday/canvas-kit-react/button';
|
|
4
|
+
import { CanvasSystemIcon } from '@workday/design-assets-types';
|
|
5
|
+
export interface ItemProps extends ButtonContainerProps {
|
|
6
|
+
/**
|
|
7
|
+
* Optionally pass index to the item. This should be done if `SegmentedControl.Item` components were created
|
|
8
|
+
* via a `[Array::map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)` function. This index will ensure keyboard navigation works even if items are
|
|
9
|
+
* inserted out of order.
|
|
10
|
+
*/
|
|
11
|
+
index?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The contents of the item. This is text used as the accessible name of the button for screen readers.
|
|
14
|
+
*/
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* The identifier of the item. This identifier will be used in change events and for `initialTab`.
|
|
18
|
+
* If this property is not provided, it will default to a string representation
|
|
19
|
+
* of the the zero-based index of the item when it was initialized.
|
|
20
|
+
*/
|
|
21
|
+
'data-id'?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional id. If not set, it will inherit the ID passed to the `SegmentedControl` component and append the
|
|
24
|
+
* index at the end. Only set this for advanced cases.
|
|
25
|
+
*/
|
|
26
|
+
id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Part of the ARIA specification for buttons. Lets screen readers know which button is active. This
|
|
29
|
+
* should either be `true` or `false`. This is automatically set by the
|
|
30
|
+
* component and should only be used in advanced cases.
|
|
31
|
+
*/
|
|
32
|
+
'aria-pressed'?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The icon of the button.
|
|
35
|
+
*/
|
|
36
|
+
icon?: CanvasSystemIcon;
|
|
37
|
+
/**
|
|
38
|
+
* Tooltip Props
|
|
39
|
+
*/
|
|
40
|
+
tooltipProps?: Omit<TooltipProps, 'children'>;
|
|
41
|
+
}
|
|
42
|
+
export declare const SegmentedControlItem: import("@workday/canvas-kit-react/common").ElementComponentM<"button", ItemProps, {
|
|
43
|
+
state: {
|
|
44
|
+
disabled: boolean;
|
|
45
|
+
size: "small" | "medium" | "large";
|
|
46
|
+
nonInteractiveIds: never[];
|
|
47
|
+
hiddenIds: never[];
|
|
48
|
+
itemWidthCache: Record<string, number>;
|
|
49
|
+
containerWidth: number;
|
|
50
|
+
overflowTargetWidth: number;
|
|
51
|
+
selectedIds: import("@workday/canvas-kit-react/collection/lib/useSelectionListModel").SelectedIds;
|
|
52
|
+
unselectedIds: string[];
|
|
53
|
+
cursorId: string;
|
|
54
|
+
columnCount: number;
|
|
55
|
+
UNSTABLE_virtual: {
|
|
56
|
+
virtualItems: import("@workday/canvas-kit-react/collection/lib/react-virtual").VirtualItem[];
|
|
57
|
+
totalSize: number; /**
|
|
58
|
+
* Optional id. If not set, it will inherit the ID passed to the `SegmentedControl` component and append the
|
|
59
|
+
* index at the end. Only set this for advanced cases.
|
|
60
|
+
*/
|
|
61
|
+
scrollToOffset: (index: number, options?: import("@workday/canvas-kit-react/collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
|
|
62
|
+
scrollToIndex: (index: number, options?: import("@workday/canvas-kit-react/collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
|
|
63
|
+
measure: () => void;
|
|
64
|
+
};
|
|
65
|
+
UNSTABLE_defaultItemHeight: number;
|
|
66
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
67
|
+
id: string;
|
|
68
|
+
orientation: "horizontal" | "vertical";
|
|
69
|
+
indexRef: React.MutableRefObject<number>;
|
|
70
|
+
isVirtualized: boolean;
|
|
71
|
+
items: import("@workday/canvas-kit-react/collection").Item<any>[];
|
|
72
|
+
};
|
|
73
|
+
events: {
|
|
74
|
+
select(data: {
|
|
75
|
+
id: string;
|
|
76
|
+
}): void;
|
|
77
|
+
setContainerWidth(data: {
|
|
78
|
+
width?: number | undefined;
|
|
79
|
+
}): void;
|
|
80
|
+
setOverflowTargetWidth(data: {
|
|
81
|
+
width: number;
|
|
82
|
+
}): void;
|
|
83
|
+
addItemWidth(data: {
|
|
84
|
+
id: string;
|
|
85
|
+
width: number;
|
|
86
|
+
}): void;
|
|
87
|
+
removeItemWidth(data: {
|
|
88
|
+
id: string;
|
|
89
|
+
}): void;
|
|
90
|
+
addHiddenKey(data: {
|
|
91
|
+
id: string;
|
|
92
|
+
}): void;
|
|
93
|
+
removeHiddenKey(data: {
|
|
94
|
+
id: string;
|
|
95
|
+
}): void;
|
|
96
|
+
selectAll(): void;
|
|
97
|
+
unselectAll(): void;
|
|
98
|
+
registerItem(data: {
|
|
99
|
+
item: any;
|
|
100
|
+
textValue: string;
|
|
101
|
+
}): void;
|
|
102
|
+
goTo(data: {
|
|
103
|
+
id: string;
|
|
104
|
+
}): void;
|
|
105
|
+
goToNext(): void;
|
|
106
|
+
goToPrevious(): void;
|
|
107
|
+
goToPreviousRow(): void;
|
|
108
|
+
goToNextRow(): void;
|
|
109
|
+
goToFirst(): void;
|
|
110
|
+
goToLast(): void;
|
|
111
|
+
goToFirstOfRow(): void;
|
|
112
|
+
goToLastOfRow(): void;
|
|
113
|
+
goToNextPage(): void;
|
|
114
|
+
goToPreviousPage(): void;
|
|
115
|
+
unregisterItem(data: {
|
|
116
|
+
id: string;
|
|
117
|
+
}): void;
|
|
118
|
+
updateItemHeight(data: {
|
|
119
|
+
value: number;
|
|
120
|
+
}): void;
|
|
121
|
+
};
|
|
122
|
+
selection: import("@workday/canvas-kit-react/collection/lib/useSelectionListModel").SelectionManager;
|
|
123
|
+
navigation: import("@workday/canvas-kit-react/collection/lib/useCursorListModel").NavigationManager;
|
|
124
|
+
getId: (item: any) => string;
|
|
125
|
+
}>;
|
|
126
|
+
//# sourceMappingURL=SegmentedControlItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControlItem.d.ts","sourceRoot":"","sources":["../../../../segmented-control/lib/SegmentedControlItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAU,YAAY,EAAC,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAEL,oBAAoB,EAIrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAK9D,MAAM,WAAW,SAAU,SAAQ,oBAAoB;IACrD;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;CAC/C;AA0FD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;+BA7G/B;;;eAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyIH,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
33
|
+
var t = {};
|
|
34
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
35
|
+
t[p] = s[p];
|
|
36
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
38
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
39
|
+
t[p[i]] = s[p[i]];
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.SegmentedControlItem = void 0;
|
|
45
|
+
var React = __importStar(require("react"));
|
|
46
|
+
var tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
47
|
+
var common_1 = require("@workday/canvas-kit-react/common");
|
|
48
|
+
var tooltip_1 = require("@workday/canvas-kit-react/tooltip");
|
|
49
|
+
var button_1 = require("@workday/canvas-kit-react/button");
|
|
50
|
+
var useSegmentedControlModel_1 = require("./hooks/useSegmentedControlModel");
|
|
51
|
+
var text_1 = require("@workday/canvas-kit-react/text");
|
|
52
|
+
var useSegmentedControlItem_1 = require("./hooks/useSegmentedControlItem");
|
|
53
|
+
var getButtonSize = function (size) {
|
|
54
|
+
switch (size) {
|
|
55
|
+
case 'large':
|
|
56
|
+
return 'medium';
|
|
57
|
+
case 'medium':
|
|
58
|
+
return 'small';
|
|
59
|
+
case 'small':
|
|
60
|
+
return 'extraSmall';
|
|
61
|
+
default:
|
|
62
|
+
return 'medium';
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var getIconButtonColors = function (toggled) {
|
|
66
|
+
return {
|
|
67
|
+
default: {
|
|
68
|
+
background: toggled ? tokens_1.colors.frenchVanilla100 : tokens_1.colors.soap200,
|
|
69
|
+
border: toggled ? tokens_1.colors.licorice200 : 'transparent',
|
|
70
|
+
icon: toggled ? tokens_1.colors.blackPepper400 : tokens_1.colors.licorice400,
|
|
71
|
+
label: toggled ? tokens_1.colors.blackPepper400 : tokens_1.colors.licorice400,
|
|
72
|
+
},
|
|
73
|
+
hover: {
|
|
74
|
+
background: toggled ? tokens_1.colors.frenchVanilla100 : tokens_1.colors.soap400,
|
|
75
|
+
icon: tokens_1.colors.licorice400,
|
|
76
|
+
label: tokens_1.colors.licorice400,
|
|
77
|
+
},
|
|
78
|
+
active: {
|
|
79
|
+
background: toggled ? tokens_1.colors.frenchVanilla100 : tokens_1.colors.soap400,
|
|
80
|
+
icon: tokens_1.colors.licorice400,
|
|
81
|
+
label: tokens_1.colors.licorice400,
|
|
82
|
+
},
|
|
83
|
+
focus: {},
|
|
84
|
+
disabled: {
|
|
85
|
+
background: tokens_1.colors.soap200,
|
|
86
|
+
opacity: '1',
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var getPaddingStyles = function (children, size, icon) {
|
|
91
|
+
if (!children) {
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
switch (size) {
|
|
95
|
+
case 'large':
|
|
96
|
+
return icon ? "0 " + tokens_1.space.m + " 0 20px" : "0 " + tokens_1.space.m;
|
|
97
|
+
case 'medium':
|
|
98
|
+
return icon ? "0 20px 0 " + tokens_1.space.s : "0 " + tokens_1.space.s;
|
|
99
|
+
case 'small':
|
|
100
|
+
return icon ? "0 " + tokens_1.space.xs + " 0 " + tokens_1.space.xxs : "0 " + tokens_1.space.xs;
|
|
101
|
+
default:
|
|
102
|
+
return icon ? "0 20px 0 " + tokens_1.space.s : "0 " + tokens_1.space.s;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var geButtonStyles = function (size, children, icon) {
|
|
106
|
+
var buttonSize = getButtonSize(size);
|
|
107
|
+
var minWidthValue = button_1.getMinWidthStyles(children, children ? size : buttonSize);
|
|
108
|
+
return {
|
|
109
|
+
height: button_1.getMinWidthStyles(false, buttonSize),
|
|
110
|
+
minWidth: minWidthValue,
|
|
111
|
+
padding: getPaddingStyles(children, size, icon),
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
var Container = function (_a) {
|
|
115
|
+
var tooltipProps = _a.tooltipProps, children = _a.children;
|
|
116
|
+
return tooltipProps ? (React.createElement(tooltip_1.Tooltip, __assign({}, tooltipProps), children)) : (React.createElement(React.Fragment, null, children));
|
|
117
|
+
};
|
|
118
|
+
exports.SegmentedControlItem = common_1.createSubcomponent('button')({
|
|
119
|
+
displayName: 'SegmentedControl.Item',
|
|
120
|
+
modelHook: useSegmentedControlModel_1.useSegmentedControlModel,
|
|
121
|
+
elemPropsHook: useSegmentedControlItem_1.useSegmentedControlItem,
|
|
122
|
+
})(function (_a, Element, _b) {
|
|
123
|
+
var size = _b.state.size;
|
|
124
|
+
var children = _a.children, icon = _a.icon, tooltipProps = _a.tooltipProps, elemProps = __rest(_a, ["children", "icon", "tooltipProps"]);
|
|
125
|
+
var _c = tokens_1.type.levels.subtext[size === 'small' ? 'medium' : 'large'], color = _c.color, textStyles = __rest(_c, ["color"]);
|
|
126
|
+
return (React.createElement(Container, { tooltipProps: tooltipProps },
|
|
127
|
+
React.createElement(button_1.BaseButton, __assign({ as: Element, borderRadius: "m", colors: getIconButtonColors(elemProps['aria-pressed']) }, geButtonStyles(size, children, icon), elemProps),
|
|
128
|
+
icon && (React.createElement(button_1.BaseButton.Icon, { size: size === 'small' ? 'extraSmall' : 'medium', icon: icon, shouldMirrorIcon: common_1.useIsRTL() })),
|
|
129
|
+
children && (React.createElement(text_1.Text, __assign({}, textStyles, { fontWeight: "bold", textAlign: "left" }), children)))));
|
|
130
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { Stack } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
export interface SegmentedControlListProps<T = any> extends Omit<Partial<ExtractProps<typeof Stack, never>>, 'children'> {
|
|
5
|
+
'aria-label': string;
|
|
6
|
+
children: ((item: T) => React.ReactNode) | React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const SegmentedControlList: import("@workday/canvas-kit-react/common").ElementComponentM<"div", SegmentedControlListProps<any>, {
|
|
9
|
+
state: {
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
size: "small" | "medium" | "large";
|
|
12
|
+
nonInteractiveIds: never[];
|
|
13
|
+
hiddenIds: never[];
|
|
14
|
+
itemWidthCache: Record<string, number>;
|
|
15
|
+
containerWidth: number;
|
|
16
|
+
overflowTargetWidth: number;
|
|
17
|
+
selectedIds: import("@workday/canvas-kit-react/collection/lib/useSelectionListModel").SelectedIds;
|
|
18
|
+
unselectedIds: string[];
|
|
19
|
+
cursorId: string;
|
|
20
|
+
columnCount: number;
|
|
21
|
+
UNSTABLE_virtual: {
|
|
22
|
+
virtualItems: import("@workday/canvas-kit-react/collection/lib/react-virtual").VirtualItem[];
|
|
23
|
+
totalSize: number;
|
|
24
|
+
scrollToOffset: (index: number, options?: import("@workday/canvas-kit-react/collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
|
|
25
|
+
scrollToIndex: (index: number, options?: import("@workday/canvas-kit-react/collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
|
|
26
|
+
measure: () => void;
|
|
27
|
+
};
|
|
28
|
+
UNSTABLE_defaultItemHeight: number;
|
|
29
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
30
|
+
id: string;
|
|
31
|
+
orientation: "horizontal" | "vertical";
|
|
32
|
+
indexRef: React.MutableRefObject<number>;
|
|
33
|
+
isVirtualized: boolean;
|
|
34
|
+
items: import("@workday/canvas-kit-react/collection").Item<any>[];
|
|
35
|
+
};
|
|
36
|
+
events: {
|
|
37
|
+
select(data: {
|
|
38
|
+
id: string;
|
|
39
|
+
}): void;
|
|
40
|
+
setContainerWidth(data: {
|
|
41
|
+
width?: number | undefined;
|
|
42
|
+
}): void;
|
|
43
|
+
setOverflowTargetWidth(data: {
|
|
44
|
+
width: number;
|
|
45
|
+
}): void;
|
|
46
|
+
addItemWidth(data: {
|
|
47
|
+
id: string;
|
|
48
|
+
width: number;
|
|
49
|
+
}): void;
|
|
50
|
+
removeItemWidth(data: {
|
|
51
|
+
id: string;
|
|
52
|
+
}): void;
|
|
53
|
+
addHiddenKey(data: {
|
|
54
|
+
id: string;
|
|
55
|
+
}): void;
|
|
56
|
+
removeHiddenKey(data: {
|
|
57
|
+
id: string;
|
|
58
|
+
}): void;
|
|
59
|
+
selectAll(): void;
|
|
60
|
+
unselectAll(): void;
|
|
61
|
+
registerItem(data: {
|
|
62
|
+
item: any;
|
|
63
|
+
textValue: string;
|
|
64
|
+
}): void;
|
|
65
|
+
goTo(data: {
|
|
66
|
+
id: string;
|
|
67
|
+
}): void;
|
|
68
|
+
goToNext(): void;
|
|
69
|
+
goToPrevious(): void;
|
|
70
|
+
goToPreviousRow(): void;
|
|
71
|
+
goToNextRow(): void;
|
|
72
|
+
goToFirst(): void;
|
|
73
|
+
goToLast(): void;
|
|
74
|
+
goToFirstOfRow(): void;
|
|
75
|
+
goToLastOfRow(): void;
|
|
76
|
+
goToNextPage(): void;
|
|
77
|
+
goToPreviousPage(): void;
|
|
78
|
+
unregisterItem(data: {
|
|
79
|
+
id: string;
|
|
80
|
+
}): void;
|
|
81
|
+
updateItemHeight(data: {
|
|
82
|
+
value: number;
|
|
83
|
+
}): void;
|
|
84
|
+
};
|
|
85
|
+
selection: import("@workday/canvas-kit-react/collection/lib/useSelectionListModel").SelectionManager;
|
|
86
|
+
navigation: import("@workday/canvas-kit-react/collection/lib/useCursorListModel").NavigationManager;
|
|
87
|
+
getId: (item: any) => string;
|
|
88
|
+
}>;
|
|
89
|
+
//# sourceMappingURL=SegmentedControlList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControlList.d.ts","sourceRoot":"","sources":["../../../../segmented-control/lib/SegmentedControlList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,YAAY,EAEb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,kCAAkC,CAAC;AAIvD,MAAM,WAAW,yBAAyB,CAAC,CAAC,GAAG,GAAG,CAChD,SAAQ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;CAC5D;AAWD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB/B,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
33
|
+
var t = {};
|
|
34
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
35
|
+
t[p] = s[p];
|
|
36
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
38
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
39
|
+
t[p[i]] = s[p[i]];
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.SegmentedControlList = void 0;
|
|
45
|
+
var React = __importStar(require("react"));
|
|
46
|
+
var common_1 = require("@workday/canvas-kit-react/common");
|
|
47
|
+
var layout_1 = require("@workday/canvas-kit-react/layout");
|
|
48
|
+
var collection_1 = require("@workday/canvas-kit-react/collection");
|
|
49
|
+
var useSegmentedControlModel_1 = require("./hooks/useSegmentedControlModel");
|
|
50
|
+
var useSegmentedControlList = common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(function (_a) {
|
|
51
|
+
var _b = _a.state, orientation = _b.orientation, disabled = _b.disabled;
|
|
52
|
+
return {
|
|
53
|
+
flexDirection: orientation === 'vertical' ? 'column' : 'row',
|
|
54
|
+
opacity: disabled ? 0.4 : 1,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
exports.SegmentedControlList = common_1.createSubcomponent('div')({
|
|
58
|
+
displayName: 'SegmentedControl.List',
|
|
59
|
+
modelHook: useSegmentedControlModel_1.useSegmentedControlModel,
|
|
60
|
+
elemPropsHook: useSegmentedControlList,
|
|
61
|
+
})(function (_a, Element, model) {
|
|
62
|
+
var children = _a.children, elemProps = __rest(_a, ["children"]);
|
|
63
|
+
return (React.createElement(layout_1.Stack, __assign({ as: Element, display: "inline-flex", role: "group", backgroundColor: "soap200", border: "1px solid transparent", borderColor: "licorice200", borderRadius: "l", spacing: "xxs", padding: "3px" }, elemProps), collection_1.useListRenderItems(model, children)));
|
|
64
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const useSegmentedControlItem: <P extends {}, R>(model: {
|
|
3
|
+
state: {
|
|
4
|
+
selectedIds: import("@workday/canvas-kit-react/collection/lib/useSelectionListModel").SelectedIds;
|
|
5
|
+
unselectedIds: string[];
|
|
6
|
+
cursorId: string;
|
|
7
|
+
columnCount: number;
|
|
8
|
+
UNSTABLE_virtual: {
|
|
9
|
+
virtualItems: import("@workday/canvas-kit-react/collection/lib/react-virtual").VirtualItem[];
|
|
10
|
+
totalSize: number;
|
|
11
|
+
scrollToOffset: (index: number, options?: import("@workday/canvas-kit-react/collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
|
|
12
|
+
scrollToIndex: (index: number, options?: import("@workday/canvas-kit-react/collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
|
|
13
|
+
measure: () => void;
|
|
14
|
+
};
|
|
15
|
+
UNSTABLE_defaultItemHeight: number;
|
|
16
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
17
|
+
id: string;
|
|
18
|
+
orientation: "horizontal" | "vertical";
|
|
19
|
+
indexRef: React.MutableRefObject<number>;
|
|
20
|
+
nonInteractiveIds: string[];
|
|
21
|
+
isVirtualized: boolean;
|
|
22
|
+
items: import("@workday/canvas-kit-react/collection").Item<any>[];
|
|
23
|
+
};
|
|
24
|
+
events: {
|
|
25
|
+
select(data: {
|
|
26
|
+
id: string;
|
|
27
|
+
}): void;
|
|
28
|
+
selectAll(): void;
|
|
29
|
+
unselectAll(): void;
|
|
30
|
+
registerItem(data: {
|
|
31
|
+
item: any;
|
|
32
|
+
textValue: string;
|
|
33
|
+
}): void;
|
|
34
|
+
goTo(data: {
|
|
35
|
+
id: string;
|
|
36
|
+
}): void;
|
|
37
|
+
goToNext(): void;
|
|
38
|
+
goToPrevious(): void;
|
|
39
|
+
goToPreviousRow(): void;
|
|
40
|
+
goToNextRow(): void;
|
|
41
|
+
goToFirst(): void;
|
|
42
|
+
goToLast(): void;
|
|
43
|
+
goToFirstOfRow(): void;
|
|
44
|
+
goToLastOfRow(): void;
|
|
45
|
+
goToNextPage(): void;
|
|
46
|
+
goToPreviousPage(): void;
|
|
47
|
+
unregisterItem(data: {
|
|
48
|
+
id: string;
|
|
49
|
+
}): void;
|
|
50
|
+
updateItemHeight(data: {
|
|
51
|
+
value: number;
|
|
52
|
+
}): void;
|
|
53
|
+
};
|
|
54
|
+
selection: import("@workday/canvas-kit-react/collection/lib/useSelectionListModel").SelectionManager;
|
|
55
|
+
navigation: import("@workday/canvas-kit-react/collection/lib/useCursorListModel").NavigationManager;
|
|
56
|
+
getId: (item: any) => string;
|
|
57
|
+
}, elemProps?: P | undefined, ref?: ((instance: R | null) => void) | React.RefObject<R> | null | undefined) => {} & P & (R extends HTMLOrSVGElement ? {
|
|
58
|
+
ref: React.Ref<R>;
|
|
59
|
+
} : {});
|
|
60
|
+
//# sourceMappingURL=useSegmentedControlItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSegmentedControlItem.d.ts","sourceRoot":"","sources":["../../../../../segmented-control/lib/hooks/useSegmentedControlItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0DnC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSegmentedControlItem = void 0;
|
|
4
|
+
var common_1 = require("@workday/canvas-kit-react/common");
|
|
5
|
+
var collection_1 = require("@workday/canvas-kit-react/collection");
|
|
6
|
+
var useSegmentedControlModel_1 = require("./useSegmentedControlModel");
|
|
7
|
+
exports.useSegmentedControlItem = common_1.composeHooks(collection_1.useListItemSelect, common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(function (model, ref, elemProps) {
|
|
8
|
+
if (elemProps === void 0) { elemProps = {}; }
|
|
9
|
+
var _a = common_1.useLocalRef(ref), elementRef = _a.elementRef, localRef = _a.localRef;
|
|
10
|
+
var name = elemProps['data-id'] || '';
|
|
11
|
+
var id = model.state.id + "-" + name;
|
|
12
|
+
common_1.useMountLayout(function () {
|
|
13
|
+
if (localRef.current) {
|
|
14
|
+
var styles = getComputedStyle(localRef.current);
|
|
15
|
+
model.events.addItemWidth({
|
|
16
|
+
id: name,
|
|
17
|
+
width: localRef.current.offsetWidth +
|
|
18
|
+
parseFloat(styles.marginLeft) +
|
|
19
|
+
parseFloat(styles.marginRight),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return function () {
|
|
23
|
+
model.events.removeItemWidth({ id: name });
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
var selected = !!name && collection_1.isSelected(name, model.state);
|
|
27
|
+
var longest = Object.keys(model.state.itemWidthCache)
|
|
28
|
+
.map(function (e) { return model.state.itemWidthCache[e]; })
|
|
29
|
+
.sort(function (a, b) { return (a < b ? 1 : -1); })[0];
|
|
30
|
+
return {
|
|
31
|
+
ref: elementRef,
|
|
32
|
+
id: id,
|
|
33
|
+
'aria-pressed': selected,
|
|
34
|
+
disabled: model.state.disabled || undefined,
|
|
35
|
+
width: elemProps.children && longest + "px",
|
|
36
|
+
};
|
|
37
|
+
}), collection_1.useListItemRegister, common_1.createElemPropsHook(useSegmentedControlModel_1.useSegmentedControlModel)(function (_a, _ref, elemProps) {
|
|
38
|
+
var state = _a.state;
|
|
39
|
+
if (elemProps === void 0) { elemProps = {}; }
|
|
40
|
+
return {
|
|
41
|
+
// override the default disabled functionality of `useListItemRegister`
|
|
42
|
+
disabled: elemProps.disabled || state.disabled ? true : undefined,
|
|
43
|
+
};
|
|
44
|
+
}));
|