@workday/canvas-kit-react 9.0.0-alpha.405-next.7 → 9.0.0-alpha.406-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/common/lib/utils/components.ts +1 -1
- package/common/lib/utils/dispatchInputEvent.ts +16 -0
- package/common/lib/utils/index.ts +1 -0
- package/dist/commonjs/common/lib/utils/components.d.ts +1 -3
- package/dist/commonjs/common/lib/utils/components.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/dispatchInputEvent.d.ts +2 -0
- package/dist/commonjs/common/lib/utils/dispatchInputEvent.d.ts.map +1 -0
- package/dist/commonjs/common/lib/utils/dispatchInputEvent.js +18 -0
- package/dist/commonjs/common/lib/utils/index.d.ts +1 -0
- package/dist/commonjs/common/lib/utils/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/index.js +1 -0
- package/dist/commonjs/text-input/index.d.ts +1 -0
- package/dist/commonjs/text-input/index.d.ts.map +1 -1
- package/dist/commonjs/text-input/index.js +3 -0
- package/dist/commonjs/text-input/lib/InputGroup.d.ts +50 -0
- package/dist/commonjs/text-input/lib/InputGroup.d.ts.map +1 -0
- package/dist/commonjs/text-input/lib/InputGroup.js +134 -0
- package/dist/es6/common/lib/utils/components.d.ts +1 -3
- package/dist/es6/common/lib/utils/components.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/dispatchInputEvent.d.ts +2 -0
- package/dist/es6/common/lib/utils/dispatchInputEvent.d.ts.map +1 -0
- package/dist/es6/common/lib/utils/dispatchInputEvent.js +14 -0
- package/dist/es6/common/lib/utils/index.d.ts +1 -0
- package/dist/es6/common/lib/utils/index.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/index.js +1 -0
- package/dist/es6/text-input/index.d.ts +1 -0
- package/dist/es6/text-input/index.d.ts.map +1 -1
- package/dist/es6/text-input/index.js +1 -0
- package/dist/es6/text-input/lib/InputGroup.d.ts +50 -0
- package/dist/es6/text-input/lib/InputGroup.d.ts.map +1 -0
- package/dist/es6/text-input/lib/InputGroup.js +128 -0
- package/package.json +3 -3
- package/text-input/index.ts +1 -0
- package/text-input/lib/InputGroup.tsx +168 -0
|
@@ -357,7 +357,7 @@ type RemoveNull<T> = {[K in keyof T]: Exclude<T[K], null>};
|
|
|
357
357
|
*/
|
|
358
358
|
type CompoundProps<Props, TElemPropsHook, E> = Props &
|
|
359
359
|
(TElemPropsHook extends (...args: any[]) => infer TProps // try to infer TProps returned from the elemPropsHook function
|
|
360
|
-
? RemoveNull<TProps
|
|
360
|
+
? RemoveNull<Omit<TProps, 'ref'> & {ref: ExtractRef<E>}>
|
|
361
361
|
: {ref: ExtractRef<E>}) &
|
|
362
362
|
(Props extends {children: any}
|
|
363
363
|
? {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function dispatchInputEvent<T extends HTMLElement>(input: T | null, value: string): void {
|
|
2
|
+
// Changing value prop programmatically doesn't fire a synthetic event or trigger a native
|
|
3
|
+
// onChange event. We can not just update .value= in setState because React library overrides
|
|
4
|
+
// input value setter but we can call the function directly on the input as context. This will
|
|
5
|
+
// cause onChange events to fire no matter how value is updated.
|
|
6
|
+
if (input) {
|
|
7
|
+
const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');
|
|
8
|
+
if (nativeInputValue && nativeInputValue.set) {
|
|
9
|
+
nativeInputValue.set.call(input, value);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const event = new Event('input', {bubbles: true});
|
|
13
|
+
|
|
14
|
+
input.dispatchEvent(event);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -200,9 +200,7 @@ declare type RemoveNull<T> = {
|
|
|
200
200
|
* - if there is no detected `ref` in the `Props` interface, a `ref` will be added based on the element type E
|
|
201
201
|
* - if there is no detected `children` in the `Props` interface, `children` will be added based on `ReactNode`
|
|
202
202
|
*/
|
|
203
|
-
declare type CompoundProps<Props, TElemPropsHook, E> = Props & (TElemPropsHook extends (...args: any[]) => infer TProps ? RemoveNull<TProps
|
|
204
|
-
ref: any;
|
|
205
|
-
} ? TProps : TProps & {
|
|
203
|
+
declare type CompoundProps<Props, TElemPropsHook, E> = Props & (TElemPropsHook extends (...args: any[]) => infer TProps ? RemoveNull<Omit<TProps, 'ref'> & {
|
|
206
204
|
ref: ExtractRef<E>;
|
|
207
205
|
}> : {
|
|
208
206
|
ref: ExtractRef<E>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAE/B;;GAEG;AACH,oBAAY,UAAU,GAAG;IACvB,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;CACxB,CAAC;AAGF,aAAK,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,aAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACpC,KAAK,GACL,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC9B,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAClB,KAAK,CAAC,GAAG,CACP,CAAC,SAAS,MAAM,iBAAiB,GAC7B,iBAAiB,CAAC,CAAC,CAAC,GACpB,CAAC,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GACxC,CAAC,SAAS,MAAM,iBAAiB,GAC/B,iBAAiB,CAAC,CAAC,CAAC,GACpB,CAAC,GACH,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;CAAC,CAAC,GACnC,CAAC,SAAS,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAChC,CAAC,GACD,KAAK,GACP,CAAC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AA,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAe9F"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispatchInputEvent = void 0;
|
|
4
|
+
function dispatchInputEvent(input, value) {
|
|
5
|
+
// Changing value prop programmatically doesn't fire a synthetic event or trigger a native
|
|
6
|
+
// onChange event. We can not just update .value= in setState because React library overrides
|
|
7
|
+
// input value setter but we can call the function directly on the input as context. This will
|
|
8
|
+
// cause onChange events to fire no matter how value is updated.
|
|
9
|
+
if (input) {
|
|
10
|
+
const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');
|
|
11
|
+
if (nativeInputValue && nativeInputValue.set) {
|
|
12
|
+
nativeInputValue.set.call(input, value);
|
|
13
|
+
}
|
|
14
|
+
const event = new Event('input', { bubbles: true });
|
|
15
|
+
input.dispatchEvent(event);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.dispatchInputEvent = dispatchInputEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -12,6 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./colorUtils"), exports);
|
|
14
14
|
__exportStar(require("./getTranslateFromOrigin"), exports);
|
|
15
|
+
__exportStar(require("./dispatchInputEvent"), exports);
|
|
15
16
|
__exportStar(require("./changeFocus"), exports);
|
|
16
17
|
__exportStar(require("./makeMq"), exports);
|
|
17
18
|
__exportStar(require("./mergeCallback"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../text-input/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../text-input/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC"}
|
|
@@ -10,5 +10,8 @@ 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.InputGroup = void 0;
|
|
13
14
|
__exportStar(require("./lib/InputIconContainer"), exports);
|
|
14
15
|
__exportStar(require("./lib/TextInput"), exports);
|
|
16
|
+
var InputGroup_1 = require("./lib/InputGroup");
|
|
17
|
+
Object.defineProperty(exports, "InputGroup", { enumerable: true, get: function () { return InputGroup_1.InputGroup; } });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const InputGroupInnerStart: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
3
|
+
export declare const InputGroupInnerEnd: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const InputGroupInput: import("@workday/canvas-kit-react/common").ElementComponent<import("@workday/canvas-kit-react/common").ElementComponent<"input", import("./TextInput").TextInputProps> & {
|
|
5
|
+
ErrorType: typeof import("@workday/canvas-kit-react/common").ErrorType;
|
|
6
|
+
}, Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
7
|
+
/**
|
|
8
|
+
* An `InputGroup` is a container around a {@link TextInput} with optional inner start and end
|
|
9
|
+
* elements. The inner start and end elements are usually icons or icon buttons visually represented
|
|
10
|
+
* inside the input. The `InputGroup` will add padding to the input so the icons/buttons display
|
|
11
|
+
* correctly. This component uses `React.Children.map` and `React.cloneElement` from the
|
|
12
|
+
* [React.Children](https://react.dev/reference/react/Children) API. This means all children must be
|
|
13
|
+
* `InputGroup.*` components. Any other direct children will cause issues. You can add different
|
|
14
|
+
* elements/components inside the {@link InputGroupInnerStart InputGroup.InnerStart} and
|
|
15
|
+
* {@link InputGroupInnerEnd InputGroup.InnerEnd} subcomponents.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <InputGroup>
|
|
19
|
+
* <InputGroup.InnerStart as={SystemIcon} pointerEvents="none" icon={searchIcon} />
|
|
20
|
+
* <InputGroup.Input />
|
|
21
|
+
* <InputGroup.InnerEnd>
|
|
22
|
+
* <TertiaryButton tabIndex={-1} icon={xIcon} size="small" />
|
|
23
|
+
* </InputGroup.InnerEnd>
|
|
24
|
+
* </InputGroup>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const InputGroup: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>> & {
|
|
28
|
+
/**
|
|
29
|
+
* A component to show inside and at the start of the input. The input's padding will be
|
|
30
|
+
* adjusted to not overlap with this element. Use `width` (number of pixels only) to adjust the
|
|
31
|
+
* width offset. The width defaults to 40px which is the correct width for icons or icon
|
|
32
|
+
* buttons.
|
|
33
|
+
*/
|
|
34
|
+
InnerStart: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
35
|
+
/**
|
|
36
|
+
* The input to render. By default, this is a {@link TextInput}. Use the `as` prop to change the
|
|
37
|
+
* component to be rendered.
|
|
38
|
+
*/
|
|
39
|
+
Input: import("@workday/canvas-kit-react/common").ElementComponent<import("@workday/canvas-kit-react/common").ElementComponent<"input", import("./TextInput").TextInputProps> & {
|
|
40
|
+
ErrorType: typeof import("@workday/canvas-kit-react/common").ErrorType;
|
|
41
|
+
}, Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
42
|
+
/**
|
|
43
|
+
* A component to show inside and at the end of the input. The input's padding will be adjusted
|
|
44
|
+
* to not overlap with this element. Use `width` (number of pixels only) to adjust the width
|
|
45
|
+
* offset. The width defaults to 40px which is the correct width for icons or icon buttons
|
|
46
|
+
* within the input.
|
|
47
|
+
*/
|
|
48
|
+
InnerEnd: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=InputGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputGroup.d.ts","sourceRoot":"","sources":["../../../../text-input/lib/InputGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,eAAO,MAAM,oBAAoB,6OAe/B,CAAC;AAEH,eAAO,MAAM,kBAAkB,6OAe7B,CAAC;AAEH,eAAO,MAAM,eAAe;;2KAI1B,CAAC;AAmBH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU;IA8DnB;;;;;OAKG;;IAEH;;;OAGG;;;;IAEH;;;;;OAKG;;CAGL,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.InputGroup = exports.InputGroupInput = exports.InputGroupInnerEnd = exports.InputGroupInnerStart = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
9
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
10
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
11
|
+
const TextInput_1 = require("./TextInput");
|
|
12
|
+
exports.InputGroupInnerStart = common_1.createComponent('div')({
|
|
13
|
+
Component(elemProps, ref, Element) {
|
|
14
|
+
return (react_1.default.createElement(layout_1.Flex, Object.assign({ ref: ref, as: Element, position: "absolute", alignItems: "center", justifyContent: "center", height: "xl", width: "xl" }, elemProps)));
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
exports.InputGroupInnerEnd = common_1.createComponent('div')({
|
|
18
|
+
Component(elemProps, ref, Element) {
|
|
19
|
+
return (react_1.default.createElement(layout_1.Flex, Object.assign({ ref: ref, as: Element, position: "absolute", alignItems: "center", justifyContent: "center", height: "xl", width: "xl" }, elemProps)));
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
exports.InputGroupInput = common_1.createComponent(TextInput_1.TextInput)({
|
|
23
|
+
Component(elemProps, ref, Element) {
|
|
24
|
+
return react_1.default.createElement(layout_1.Flex, Object.assign({ ref: ref, as: Element, width: "100%" }, elemProps));
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// make sure we always use pixels if the input is a number - this is required for `calc`
|
|
28
|
+
const toPx = (input) => {
|
|
29
|
+
return typeof input === 'number' ? `${input}px` : input;
|
|
30
|
+
};
|
|
31
|
+
// wrap an array of widths into something the browser can understand, including `calc` for multiple
|
|
32
|
+
// values
|
|
33
|
+
const wrapInCalc = (values) => {
|
|
34
|
+
if (values.length === 0) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (values.length === 1) {
|
|
38
|
+
return values[0];
|
|
39
|
+
}
|
|
40
|
+
return `calc(${values.map(toPx).join(' + ')})`;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* An `InputGroup` is a container around a {@link TextInput} with optional inner start and end
|
|
44
|
+
* elements. The inner start and end elements are usually icons or icon buttons visually represented
|
|
45
|
+
* inside the input. The `InputGroup` will add padding to the input so the icons/buttons display
|
|
46
|
+
* correctly. This component uses `React.Children.map` and `React.cloneElement` from the
|
|
47
|
+
* [React.Children](https://react.dev/reference/react/Children) API. This means all children must be
|
|
48
|
+
* `InputGroup.*` components. Any other direct children will cause issues. You can add different
|
|
49
|
+
* elements/components inside the {@link InputGroupInnerStart InputGroup.InnerStart} and
|
|
50
|
+
* {@link InputGroupInnerEnd InputGroup.InnerEnd} subcomponents.
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <InputGroup>
|
|
54
|
+
* <InputGroup.InnerStart as={SystemIcon} pointerEvents="none" icon={searchIcon} />
|
|
55
|
+
* <InputGroup.Input />
|
|
56
|
+
* <InputGroup.InnerEnd>
|
|
57
|
+
* <TertiaryButton tabIndex={-1} icon={xIcon} size="small" />
|
|
58
|
+
* </InputGroup.InnerEnd>
|
|
59
|
+
* </InputGroup>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
exports.InputGroup = common_1.createComponent('div')({
|
|
63
|
+
displayName: 'InputGroup',
|
|
64
|
+
Component({ children, ...elemProps }, ref, Element) {
|
|
65
|
+
const isRTL = common_1.useIsRTL();
|
|
66
|
+
const offsetsStart = [];
|
|
67
|
+
const offsetsEnd = [];
|
|
68
|
+
// Collect the widths of the `InnerStart` and `InnerEnd` components into `offsetStart` and
|
|
69
|
+
// `offsetEnd` arrays
|
|
70
|
+
react_1.default.Children.forEach(children, child => {
|
|
71
|
+
if (react_1.default.isValidElement(child) && child.type === exports.InputGroupInnerStart) {
|
|
72
|
+
const width = child.props.width || tokens_1.space.xl;
|
|
73
|
+
offsetsStart.push(width);
|
|
74
|
+
}
|
|
75
|
+
if (react_1.default.isValidElement(child) && child.type === exports.InputGroupInnerEnd) {
|
|
76
|
+
const width = child.props.width || tokens_1.space.xl;
|
|
77
|
+
offsetsEnd.push(width);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// keep track of the index offsets to make sure we calculate the correct position offset
|
|
81
|
+
let indexStart = 0;
|
|
82
|
+
let indexEnd = 0;
|
|
83
|
+
// Loop over all the children and set the correct padding and positions
|
|
84
|
+
const mappedChildren = react_1.default.Children.map(children, child => {
|
|
85
|
+
if (react_1.default.isValidElement(child)) {
|
|
86
|
+
if (child.type === exports.InputGroupInput) {
|
|
87
|
+
return react_1.default.cloneElement(child, {
|
|
88
|
+
paddingInlineStart: wrapInCalc(offsetsStart),
|
|
89
|
+
paddingInlineEnd: wrapInCalc(offsetsEnd),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (child.type === exports.InputGroupInnerStart) {
|
|
93
|
+
const offset = wrapInCalc(offsetsStart.slice(0, indexStart)) || 0;
|
|
94
|
+
indexStart++;
|
|
95
|
+
return react_1.default.cloneElement(child, {
|
|
96
|
+
left: isRTL ? undefined : offset,
|
|
97
|
+
right: isRTL ? offset : undefined,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (child.type === exports.InputGroupInnerEnd) {
|
|
101
|
+
const offset = wrapInCalc(offsetsEnd.slice(indexEnd, -1)) || 0;
|
|
102
|
+
indexEnd++;
|
|
103
|
+
return react_1.default.cloneElement(child, {
|
|
104
|
+
left: isRTL ? offset : undefined,
|
|
105
|
+
right: isRTL ? undefined : offset,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return child;
|
|
110
|
+
});
|
|
111
|
+
return (react_1.default.createElement(layout_1.Flex, Object.assign({ ref: ref, as: Element, position: "relative" }, elemProps), mappedChildren));
|
|
112
|
+
},
|
|
113
|
+
subComponents: {
|
|
114
|
+
/**
|
|
115
|
+
* A component to show inside and at the start of the input. The input's padding will be
|
|
116
|
+
* adjusted to not overlap with this element. Use `width` (number of pixels only) to adjust the
|
|
117
|
+
* width offset. The width defaults to 40px which is the correct width for icons or icon
|
|
118
|
+
* buttons.
|
|
119
|
+
*/
|
|
120
|
+
InnerStart: exports.InputGroupInnerStart,
|
|
121
|
+
/**
|
|
122
|
+
* The input to render. By default, this is a {@link TextInput}. Use the `as` prop to change the
|
|
123
|
+
* component to be rendered.
|
|
124
|
+
*/
|
|
125
|
+
Input: exports.InputGroupInput,
|
|
126
|
+
/**
|
|
127
|
+
* A component to show inside and at the end of the input. The input's padding will be adjusted
|
|
128
|
+
* to not overlap with this element. Use `width` (number of pixels only) to adjust the width
|
|
129
|
+
* offset. The width defaults to 40px which is the correct width for icons or icon buttons
|
|
130
|
+
* within the input.
|
|
131
|
+
*/
|
|
132
|
+
InnerEnd: exports.InputGroupInnerEnd,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
@@ -200,9 +200,7 @@ declare type RemoveNull<T> = {
|
|
|
200
200
|
* - if there is no detected `ref` in the `Props` interface, a `ref` will be added based on the element type E
|
|
201
201
|
* - if there is no detected `children` in the `Props` interface, `children` will be added based on `ReactNode`
|
|
202
202
|
*/
|
|
203
|
-
declare type CompoundProps<Props, TElemPropsHook, E> = Props & (TElemPropsHook extends (...args: any[]) => infer TProps ? RemoveNull<TProps
|
|
204
|
-
ref: any;
|
|
205
|
-
} ? TProps : TProps & {
|
|
203
|
+
declare type CompoundProps<Props, TElemPropsHook, E> = Props & (TElemPropsHook extends (...args: any[]) => infer TProps ? RemoveNull<Omit<TProps, 'ref'> & {
|
|
206
204
|
ref: ExtractRef<E>;
|
|
207
205
|
}> : {
|
|
208
206
|
ref: ExtractRef<E>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAA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AAC,GACzB,YAAY,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AACtC,wBAAgB,YAAY,CAC1B,CAAC,SAAS,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,EACzB,EAAE,SAAS,EAAE,EACb,EAAE,SAAS,EAAE,EACb,EAAE,SAAS,EAAE,EACb,EAAE,SAAS,EAAE,EACb,EAAE,SAAS,EAAE,EAEb,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,EAC1B,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,EAC1B,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,EAC1B,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,EAC1B,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,GACzB,YAAY,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatchInputEvent.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/dispatchInputEvent.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAe9F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function dispatchInputEvent(input, value) {
|
|
2
|
+
// Changing value prop programmatically doesn't fire a synthetic event or trigger a native
|
|
3
|
+
// onChange event. We can not just update .value= in setState because React library overrides
|
|
4
|
+
// input value setter but we can call the function directly on the input as context. This will
|
|
5
|
+
// cause onChange events to fire no matter how value is updated.
|
|
6
|
+
if (input) {
|
|
7
|
+
const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');
|
|
8
|
+
if (nativeInputValue && nativeInputValue.set) {
|
|
9
|
+
nativeInputValue.set.call(input, value);
|
|
10
|
+
}
|
|
11
|
+
const event = new Event('input', { bubbles: true });
|
|
12
|
+
input.dispatchEvent(event);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../text-input/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../text-input/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const InputGroupInnerStart: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
3
|
+
export declare const InputGroupInnerEnd: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const InputGroupInput: import("@workday/canvas-kit-react/common").ElementComponent<import("@workday/canvas-kit-react/common").ElementComponent<"input", import("./TextInput").TextInputProps> & {
|
|
5
|
+
ErrorType: typeof import("@workday/canvas-kit-react/common").ErrorType;
|
|
6
|
+
}, Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
7
|
+
/**
|
|
8
|
+
* An `InputGroup` is a container around a {@link TextInput} with optional inner start and end
|
|
9
|
+
* elements. The inner start and end elements are usually icons or icon buttons visually represented
|
|
10
|
+
* inside the input. The `InputGroup` will add padding to the input so the icons/buttons display
|
|
11
|
+
* correctly. This component uses `React.Children.map` and `React.cloneElement` from the
|
|
12
|
+
* [React.Children](https://react.dev/reference/react/Children) API. This means all children must be
|
|
13
|
+
* `InputGroup.*` components. Any other direct children will cause issues. You can add different
|
|
14
|
+
* elements/components inside the {@link InputGroupInnerStart InputGroup.InnerStart} and
|
|
15
|
+
* {@link InputGroupInnerEnd InputGroup.InnerEnd} subcomponents.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <InputGroup>
|
|
19
|
+
* <InputGroup.InnerStart as={SystemIcon} pointerEvents="none" icon={searchIcon} />
|
|
20
|
+
* <InputGroup.Input />
|
|
21
|
+
* <InputGroup.InnerEnd>
|
|
22
|
+
* <TertiaryButton tabIndex={-1} icon={xIcon} size="small" />
|
|
23
|
+
* </InputGroup.InnerEnd>
|
|
24
|
+
* </InputGroup>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const InputGroup: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>> & {
|
|
28
|
+
/**
|
|
29
|
+
* A component to show inside and at the start of the input. The input's padding will be
|
|
30
|
+
* adjusted to not overlap with this element. Use `width` (number of pixels only) to adjust the
|
|
31
|
+
* width offset. The width defaults to 40px which is the correct width for icons or icon
|
|
32
|
+
* buttons.
|
|
33
|
+
*/
|
|
34
|
+
InnerStart: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
35
|
+
/**
|
|
36
|
+
* The input to render. By default, this is a {@link TextInput}. Use the `as` prop to change the
|
|
37
|
+
* component to be rendered.
|
|
38
|
+
*/
|
|
39
|
+
Input: import("@workday/canvas-kit-react/common").ElementComponent<import("@workday/canvas-kit-react/common").ElementComponent<"input", import("./TextInput").TextInputProps> & {
|
|
40
|
+
ErrorType: typeof import("@workday/canvas-kit-react/common").ErrorType;
|
|
41
|
+
}, Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
42
|
+
/**
|
|
43
|
+
* A component to show inside and at the end of the input. The input's padding will be adjusted
|
|
44
|
+
* to not overlap with this element. Use `width` (number of pixels only) to adjust the width
|
|
45
|
+
* offset. The width defaults to 40px which is the correct width for icons or icon buttons
|
|
46
|
+
* within the input.
|
|
47
|
+
*/
|
|
48
|
+
InnerEnd: import("@workday/canvas-kit-react/common").ElementComponent<"div", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps & React.HTMLAttributes<HTMLDivElement>>;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=InputGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputGroup.d.ts","sourceRoot":"","sources":["../../../../text-input/lib/InputGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,eAAO,MAAM,oBAAoB,6OAe/B,CAAC;AAEH,eAAO,MAAM,kBAAkB,6OAe7B,CAAC;AAEH,eAAO,MAAM,eAAe;;2KAI1B,CAAC;AAmBH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU;IA8DnB;;;;;OAKG;;IAEH;;;OAGG;;;;IAEH;;;;;OAKG;;CAGL,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { space } from '@workday/canvas-kit-react/tokens';
|
|
3
|
+
import { createComponent, useIsRTL } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
5
|
+
import { TextInput } from './TextInput';
|
|
6
|
+
export const InputGroupInnerStart = createComponent('div')({
|
|
7
|
+
Component(elemProps, ref, Element) {
|
|
8
|
+
return (React.createElement(Flex, Object.assign({ ref: ref, as: Element, position: "absolute", alignItems: "center", justifyContent: "center", height: "xl", width: "xl" }, elemProps)));
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export const InputGroupInnerEnd = createComponent('div')({
|
|
12
|
+
Component(elemProps, ref, Element) {
|
|
13
|
+
return (React.createElement(Flex, Object.assign({ ref: ref, as: Element, position: "absolute", alignItems: "center", justifyContent: "center", height: "xl", width: "xl" }, elemProps)));
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export const InputGroupInput = createComponent(TextInput)({
|
|
17
|
+
Component(elemProps, ref, Element) {
|
|
18
|
+
return React.createElement(Flex, Object.assign({ ref: ref, as: Element, width: "100%" }, elemProps));
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
// make sure we always use pixels if the input is a number - this is required for `calc`
|
|
22
|
+
const toPx = (input) => {
|
|
23
|
+
return typeof input === 'number' ? `${input}px` : input;
|
|
24
|
+
};
|
|
25
|
+
// wrap an array of widths into something the browser can understand, including `calc` for multiple
|
|
26
|
+
// values
|
|
27
|
+
const wrapInCalc = (values) => {
|
|
28
|
+
if (values.length === 0) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (values.length === 1) {
|
|
32
|
+
return values[0];
|
|
33
|
+
}
|
|
34
|
+
return `calc(${values.map(toPx).join(' + ')})`;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* An `InputGroup` is a container around a {@link TextInput} with optional inner start and end
|
|
38
|
+
* elements. The inner start and end elements are usually icons or icon buttons visually represented
|
|
39
|
+
* inside the input. The `InputGroup` will add padding to the input so the icons/buttons display
|
|
40
|
+
* correctly. This component uses `React.Children.map` and `React.cloneElement` from the
|
|
41
|
+
* [React.Children](https://react.dev/reference/react/Children) API. This means all children must be
|
|
42
|
+
* `InputGroup.*` components. Any other direct children will cause issues. You can add different
|
|
43
|
+
* elements/components inside the {@link InputGroupInnerStart InputGroup.InnerStart} and
|
|
44
|
+
* {@link InputGroupInnerEnd InputGroup.InnerEnd} subcomponents.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <InputGroup>
|
|
48
|
+
* <InputGroup.InnerStart as={SystemIcon} pointerEvents="none" icon={searchIcon} />
|
|
49
|
+
* <InputGroup.Input />
|
|
50
|
+
* <InputGroup.InnerEnd>
|
|
51
|
+
* <TertiaryButton tabIndex={-1} icon={xIcon} size="small" />
|
|
52
|
+
* </InputGroup.InnerEnd>
|
|
53
|
+
* </InputGroup>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const InputGroup = createComponent('div')({
|
|
57
|
+
displayName: 'InputGroup',
|
|
58
|
+
Component({ children, ...elemProps }, ref, Element) {
|
|
59
|
+
const isRTL = useIsRTL();
|
|
60
|
+
const offsetsStart = [];
|
|
61
|
+
const offsetsEnd = [];
|
|
62
|
+
// Collect the widths of the `InnerStart` and `InnerEnd` components into `offsetStart` and
|
|
63
|
+
// `offsetEnd` arrays
|
|
64
|
+
React.Children.forEach(children, child => {
|
|
65
|
+
if (React.isValidElement(child) && child.type === InputGroupInnerStart) {
|
|
66
|
+
const width = child.props.width || space.xl;
|
|
67
|
+
offsetsStart.push(width);
|
|
68
|
+
}
|
|
69
|
+
if (React.isValidElement(child) && child.type === InputGroupInnerEnd) {
|
|
70
|
+
const width = child.props.width || space.xl;
|
|
71
|
+
offsetsEnd.push(width);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// keep track of the index offsets to make sure we calculate the correct position offset
|
|
75
|
+
let indexStart = 0;
|
|
76
|
+
let indexEnd = 0;
|
|
77
|
+
// Loop over all the children and set the correct padding and positions
|
|
78
|
+
const mappedChildren = React.Children.map(children, child => {
|
|
79
|
+
if (React.isValidElement(child)) {
|
|
80
|
+
if (child.type === InputGroupInput) {
|
|
81
|
+
return React.cloneElement(child, {
|
|
82
|
+
paddingInlineStart: wrapInCalc(offsetsStart),
|
|
83
|
+
paddingInlineEnd: wrapInCalc(offsetsEnd),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (child.type === InputGroupInnerStart) {
|
|
87
|
+
const offset = wrapInCalc(offsetsStart.slice(0, indexStart)) || 0;
|
|
88
|
+
indexStart++;
|
|
89
|
+
return React.cloneElement(child, {
|
|
90
|
+
left: isRTL ? undefined : offset,
|
|
91
|
+
right: isRTL ? offset : undefined,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (child.type === InputGroupInnerEnd) {
|
|
95
|
+
const offset = wrapInCalc(offsetsEnd.slice(indexEnd, -1)) || 0;
|
|
96
|
+
indexEnd++;
|
|
97
|
+
return React.cloneElement(child, {
|
|
98
|
+
left: isRTL ? offset : undefined,
|
|
99
|
+
right: isRTL ? undefined : offset,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return child;
|
|
104
|
+
});
|
|
105
|
+
return (React.createElement(Flex, Object.assign({ ref: ref, as: Element, position: "relative" }, elemProps), mappedChildren));
|
|
106
|
+
},
|
|
107
|
+
subComponents: {
|
|
108
|
+
/**
|
|
109
|
+
* A component to show inside and at the start of the input. The input's padding will be
|
|
110
|
+
* adjusted to not overlap with this element. Use `width` (number of pixels only) to adjust the
|
|
111
|
+
* width offset. The width defaults to 40px which is the correct width for icons or icon
|
|
112
|
+
* buttons.
|
|
113
|
+
*/
|
|
114
|
+
InnerStart: InputGroupInnerStart,
|
|
115
|
+
/**
|
|
116
|
+
* The input to render. By default, this is a {@link TextInput}. Use the `as` prop to change the
|
|
117
|
+
* component to be rendered.
|
|
118
|
+
*/
|
|
119
|
+
Input: InputGroupInput,
|
|
120
|
+
/**
|
|
121
|
+
* A component to show inside and at the end of the input. The input's padding will be adjusted
|
|
122
|
+
* to not overlap with this element. Use `width` (number of pixels only) to adjust the width
|
|
123
|
+
* offset. The width defaults to 40px which is the correct width for icons or icon buttons
|
|
124
|
+
* within the input.
|
|
125
|
+
*/
|
|
126
|
+
InnerEnd: InputGroupInnerEnd,
|
|
127
|
+
},
|
|
128
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.406-next.8+2b77c467",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@emotion/styled": "^11.6.0",
|
|
50
50
|
"@popperjs/core": "^2.5.4",
|
|
51
51
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
52
|
-
"@workday/canvas-kit-popup-stack": "^9.0.0-alpha.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^9.0.0-alpha.406-next.8+2b77c467",
|
|
53
53
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
54
54
|
"@workday/design-assets-types": "^0.2.8",
|
|
55
55
|
"chroma-js": "^2.1.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
67
67
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "2b77c46799e24cfd01d235ec1e2cb5224bcd4df4"
|
|
70
70
|
}
|
package/text-input/index.ts
CHANGED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
4
|
+
import {createComponent, ExtractProps, useIsRTL} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
+
|
|
7
|
+
import {TextInput} from './TextInput';
|
|
8
|
+
|
|
9
|
+
export const InputGroupInnerStart = createComponent('div')({
|
|
10
|
+
Component(elemProps: ExtractProps<typeof Flex>, ref, Element) {
|
|
11
|
+
return (
|
|
12
|
+
<Flex
|
|
13
|
+
ref={ref}
|
|
14
|
+
as={Element}
|
|
15
|
+
position="absolute"
|
|
16
|
+
alignItems="center"
|
|
17
|
+
justifyContent="center"
|
|
18
|
+
height="xl"
|
|
19
|
+
width="xl"
|
|
20
|
+
{...elemProps}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const InputGroupInnerEnd = createComponent('div')({
|
|
27
|
+
Component(elemProps: ExtractProps<typeof Flex>, ref, Element) {
|
|
28
|
+
return (
|
|
29
|
+
<Flex
|
|
30
|
+
ref={ref}
|
|
31
|
+
as={Element}
|
|
32
|
+
position="absolute"
|
|
33
|
+
alignItems="center"
|
|
34
|
+
justifyContent="center"
|
|
35
|
+
height="xl"
|
|
36
|
+
width="xl"
|
|
37
|
+
{...elemProps}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const InputGroupInput = createComponent(TextInput)({
|
|
44
|
+
Component(elemProps: ExtractProps<typeof Flex>, ref, Element) {
|
|
45
|
+
return <Flex ref={ref} as={Element} width="100%" {...elemProps} />;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// make sure we always use pixels if the input is a number - this is required for `calc`
|
|
50
|
+
const toPx = (input: string | number): string => {
|
|
51
|
+
return typeof input === 'number' ? `${input}px` : input;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// wrap an array of widths into something the browser can understand, including `calc` for multiple
|
|
55
|
+
// values
|
|
56
|
+
const wrapInCalc = (values: (string | number)[]): string | number | undefined => {
|
|
57
|
+
if (values.length === 0) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (values.length === 1) {
|
|
61
|
+
return values[0];
|
|
62
|
+
}
|
|
63
|
+
return `calc(${values.map(toPx).join(' + ')})`;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An `InputGroup` is a container around a {@link TextInput} with optional inner start and end
|
|
68
|
+
* elements. The inner start and end elements are usually icons or icon buttons visually represented
|
|
69
|
+
* inside the input. The `InputGroup` will add padding to the input so the icons/buttons display
|
|
70
|
+
* correctly. This component uses `React.Children.map` and `React.cloneElement` from the
|
|
71
|
+
* [React.Children](https://react.dev/reference/react/Children) API. This means all children must be
|
|
72
|
+
* `InputGroup.*` components. Any other direct children will cause issues. You can add different
|
|
73
|
+
* elements/components inside the {@link InputGroupInnerStart InputGroup.InnerStart} and
|
|
74
|
+
* {@link InputGroupInnerEnd InputGroup.InnerEnd} subcomponents.
|
|
75
|
+
*
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <InputGroup>
|
|
78
|
+
* <InputGroup.InnerStart as={SystemIcon} pointerEvents="none" icon={searchIcon} />
|
|
79
|
+
* <InputGroup.Input />
|
|
80
|
+
* <InputGroup.InnerEnd>
|
|
81
|
+
* <TertiaryButton tabIndex={-1} icon={xIcon} size="small" />
|
|
82
|
+
* </InputGroup.InnerEnd>
|
|
83
|
+
* </InputGroup>
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export const InputGroup = createComponent('div')({
|
|
87
|
+
displayName: 'InputGroup',
|
|
88
|
+
Component({children, ...elemProps}: ExtractProps<typeof Flex>, ref, Element) {
|
|
89
|
+
const isRTL = useIsRTL();
|
|
90
|
+
const offsetsStart: (string | number)[] = [];
|
|
91
|
+
const offsetsEnd: (string | number)[] = [];
|
|
92
|
+
|
|
93
|
+
// Collect the widths of the `InnerStart` and `InnerEnd` components into `offsetStart` and
|
|
94
|
+
// `offsetEnd` arrays
|
|
95
|
+
React.Children.forEach(children, child => {
|
|
96
|
+
if (React.isValidElement<any>(child) && child.type === InputGroupInnerStart) {
|
|
97
|
+
const width = child.props.width || space.xl;
|
|
98
|
+
offsetsStart.push(width);
|
|
99
|
+
}
|
|
100
|
+
if (React.isValidElement<any>(child) && child.type === InputGroupInnerEnd) {
|
|
101
|
+
const width = child.props.width || space.xl;
|
|
102
|
+
offsetsEnd.push(width);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// keep track of the index offsets to make sure we calculate the correct position offset
|
|
107
|
+
let indexStart = 0;
|
|
108
|
+
let indexEnd = 0;
|
|
109
|
+
|
|
110
|
+
// Loop over all the children and set the correct padding and positions
|
|
111
|
+
const mappedChildren = React.Children.map(children, child => {
|
|
112
|
+
if (React.isValidElement<any>(child)) {
|
|
113
|
+
if (child.type === InputGroupInput) {
|
|
114
|
+
return React.cloneElement(child, {
|
|
115
|
+
paddingInlineStart: wrapInCalc(offsetsStart),
|
|
116
|
+
paddingInlineEnd: wrapInCalc(offsetsEnd),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (child.type === InputGroupInnerStart) {
|
|
120
|
+
const offset = wrapInCalc(offsetsStart.slice(0, indexStart)) || 0;
|
|
121
|
+
indexStart++;
|
|
122
|
+
|
|
123
|
+
return React.cloneElement(child, {
|
|
124
|
+
left: isRTL ? undefined : offset,
|
|
125
|
+
right: isRTL ? offset : undefined,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (child.type === InputGroupInnerEnd) {
|
|
129
|
+
const offset = wrapInCalc(offsetsEnd.slice(indexEnd, -1)) || 0;
|
|
130
|
+
indexEnd++;
|
|
131
|
+
|
|
132
|
+
return React.cloneElement(child, {
|
|
133
|
+
left: isRTL ? offset : undefined,
|
|
134
|
+
right: isRTL ? undefined : offset,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return child;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Flex ref={ref} as={Element} position="relative" {...elemProps}>
|
|
143
|
+
{mappedChildren}
|
|
144
|
+
</Flex>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
subComponents: {
|
|
148
|
+
/**
|
|
149
|
+
* A component to show inside and at the start of the input. The input's padding will be
|
|
150
|
+
* adjusted to not overlap with this element. Use `width` (number of pixels only) to adjust the
|
|
151
|
+
* width offset. The width defaults to 40px which is the correct width for icons or icon
|
|
152
|
+
* buttons.
|
|
153
|
+
*/
|
|
154
|
+
InnerStart: InputGroupInnerStart,
|
|
155
|
+
/**
|
|
156
|
+
* The input to render. By default, this is a {@link TextInput}. Use the `as` prop to change the
|
|
157
|
+
* component to be rendered.
|
|
158
|
+
*/
|
|
159
|
+
Input: InputGroupInput,
|
|
160
|
+
/**
|
|
161
|
+
* A component to show inside and at the end of the input. The input's padding will be adjusted
|
|
162
|
+
* to not overlap with this element. Use `width` (number of pixels only) to adjust the width
|
|
163
|
+
* offset. The width defaults to 40px which is the correct width for icons or icon buttons
|
|
164
|
+
* within the input.
|
|
165
|
+
*/
|
|
166
|
+
InnerEnd: InputGroupInnerEnd,
|
|
167
|
+
},
|
|
168
|
+
});
|