@workday/canvas-kit-preview-react 7.0.0-alpha.97-next.23 → 8.0.0-alpha.111-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.
@@ -2,5 +2,5 @@ import Select from './lib/Select';
2
2
  export default Select;
3
3
  export { Select };
4
4
  export * from './lib/Select';
5
- export { Option, RenderableOption, RenderOptionFunction } from './lib/SelectBase';
5
+ export { Option, RenderableOption, RenderOptionFunction, RenderSelectedFunction, } from './lib/SelectBase';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../select/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,eAAe,MAAM,CAAC;AACtB,OAAO,EAAC,MAAM,EAAC,CAAC;AAChB,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../select/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,eAAe,MAAM,CAAC;AACtB,OAAO,EAAC,MAAM,EAAC,CAAC;AAChB,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC"}
@@ -17,6 +17,9 @@ export interface NormalizedOption extends Option {
17
17
  id: string;
18
18
  label: string;
19
19
  }
20
+ export interface RenderSelectedFunction {
21
+ (option: NormalizedOption): React.ReactNode;
22
+ }
20
23
  export interface RenderableOption extends NormalizedOption {
21
24
  focused: boolean;
22
25
  selected: boolean;
@@ -47,6 +50,22 @@ export interface CoreSelectBaseProps extends Themeable, GrowthBehavior, Pick<Rea
47
50
  * @default defaultRenderOption
48
51
  */
49
52
  renderOption?: RenderOptionFunction;
53
+ /**
54
+ * The function called to render the selected option.
55
+ *
56
+ * The `option` argument passed to the function is an object which contains the following:
57
+ *
58
+ * * `data: object` (data object carried over from the corresponding option originally passed into the component)
59
+ * * `disabled: boolean`
60
+ * * `id: string`
61
+ * * `label: string`
62
+ * * `value: string`
63
+ *
64
+ * If you omit the `renderSelected` prop, each option will be rendered using a `defaultRenderSelected` function provided by the component.
65
+ *
66
+ * @default defaultRenderSelected
67
+ */
68
+ renderSelected?: RenderSelectedFunction;
50
69
  /**
51
70
  * The value of the Select.
52
71
  */
@@ -118,6 +137,6 @@ export interface SelectBaseProps extends CoreSelectBaseProps, StyledType {
118
137
  }
119
138
  export declare const buttonBorderWidth = 1;
120
139
  export declare const buttonDefaultWidth = 280;
121
- declare const SelectBase: ({ "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired, as, forwardedButtonRef, localButtonRef, disabled, error, focusedOptionIndex, grow, inputRef, menuPlacement, menuRef, menuVisibility, onChange, onKeyDown, onClose, onOptionSelection, options, renderOption, required, shouldMenuAutoFlip, shouldMenuAutoFocus, value, ...elemProps }: SelectBaseProps) => JSX.Element;
140
+ declare const SelectBase: ({ "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired, as, forwardedButtonRef, localButtonRef, disabled, error, focusedOptionIndex, grow, inputRef, menuPlacement, menuRef, menuVisibility, onChange, onKeyDown, onClose, onOptionSelection, options, renderOption, renderSelected, required, shouldMenuAutoFlip, shouldMenuAutoFocus, value, ...elemProps }: SelectBaseProps) => JSX.Element;
122
141
  export default SelectBase;
123
142
  //# sourceMappingURL=SelectBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectBase.d.ts","sourceRoot":"","sources":["../../../../select/lib/SelectBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EAIV,MAAM,kCAAkC,CAAC;AAe1C,OAAO,EAAC,aAA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128
  var defaultRenderOption = function (option) {
129
- return react_1.default.createElement("div", null, option.label);
129
+ return react_1.default.createElement("div", null, defaultRenderSelected(option));
130
+ };
131
+ var defaultRenderSelected = function (option) {
132
+ return option.label;
130
133
  };
131
134
  var SelectBase = function (_a) {
132
- var ariaLabelledBy = _a["aria-labelledby"], ariaRequired = _a["aria-required"], as = _a.as, forwardedButtonRef = _a.forwardedButtonRef, localButtonRef = _a.localButtonRef, disabled = _a.disabled, error = _a.error, _b = _a.focusedOptionIndex, focusedOptionIndex = _b === void 0 ? 0 : _b, grow = _a.grow, inputRef = _a.inputRef, _c = _a.menuPlacement, menuPlacement = _c === void 0 ? 'bottom' : _c, menuRef = _a.menuRef, _d = _a.menuVisibility, menuVisibility = _d === void 0 ? 'closed' : _d, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onClose = _a.onClose, onOptionSelection = _a.onOptionSelection, options = _a.options, _e = _a.renderOption, renderOption = _e === void 0 ? defaultRenderOption : _e, required = _a.required, _f = _a.shouldMenuAutoFlip, shouldMenuAutoFlip = _f === void 0 ? true : _f, _g = _a.shouldMenuAutoFocus, shouldMenuAutoFocus = _g === void 0 ? true : _g, value = _a.value, elemProps = __rest(_a, ['aria-labelledby', 'aria-required', "as", "forwardedButtonRef", "localButtonRef", "disabled", "error", "focusedOptionIndex", "grow", "inputRef", "menuPlacement", "menuRef", "menuVisibility", "onChange", "onKeyDown", "onClose", "onOptionSelection", "options", "renderOption", "required", "shouldMenuAutoFlip", "shouldMenuAutoFocus", "value"]);
135
+ var ariaLabelledBy = _a["aria-labelledby"], ariaRequired = _a["aria-required"], as = _a.as, forwardedButtonRef = _a.forwardedButtonRef, localButtonRef = _a.localButtonRef, disabled = _a.disabled, error = _a.error, _b = _a.focusedOptionIndex, focusedOptionIndex = _b === void 0 ? 0 : _b, grow = _a.grow, inputRef = _a.inputRef, _c = _a.menuPlacement, menuPlacement = _c === void 0 ? 'bottom' : _c, menuRef = _a.menuRef, _d = _a.menuVisibility, menuVisibility = _d === void 0 ? 'closed' : _d, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onClose = _a.onClose, onOptionSelection = _a.onOptionSelection, options = _a.options, _e = _a.renderOption, renderOption = _e === void 0 ? defaultRenderOption : _e, _f = _a.renderSelected, renderSelected = _f === void 0 ? defaultRenderSelected : _f, required = _a.required, _g = _a.shouldMenuAutoFlip, shouldMenuAutoFlip = _g === void 0 ? true : _g, _h = _a.shouldMenuAutoFocus, shouldMenuAutoFocus = _h === void 0 ? true : _h, value = _a.value, elemProps = __rest(_a, ['aria-labelledby', 'aria-required', "as", "forwardedButtonRef", "localButtonRef", "disabled", "error", "focusedOptionIndex", "grow", "inputRef", "menuPlacement", "menuRef", "menuVisibility", "onChange", "onKeyDown", "onClose", "onOptionSelection", "options", "renderOption", "renderSelected", "required", "shouldMenuAutoFlip", "shouldMenuAutoFocus", "value"]);
133
136
  var focusedOptionRef = react_1.default.useRef(null);
134
137
  var menuId = common_1.useUniqueId();
135
138
  var renderOptions = function (renderOption) {
@@ -204,7 +207,6 @@ var SelectBase = function (_a) {
204
207
  // Do a bit of error-checking in case options weren't provided
205
208
  var hasOptions = options.length > 0;
206
209
  var selectedOption = hasOptions ? options[utils_1.getCorrectedIndexByValue(options, value)] : null;
207
- var selectedOptionLabel = selectedOption ? selectedOption.label : '';
208
210
  var selectedOptionValue = selectedOption ? selectedOption.value : '';
209
211
  return (react_1.default.createElement(SelectWrapper, { grow: grow, disabled: disabled },
210
212
  react_1.default.createElement(SelectButton, __assign({ "aria-expanded": menuVisibility !== 'closed' ? 'true' : undefined, "aria-haspopup": "listbox", "aria-controls": menuVisibility !== 'closed' ? menuId : undefined, as: as, disabled: disabled, error: error, grow: grow, menuVisibility: menuVisibility, onKeyDown: onKeyDown,
@@ -213,7 +215,7 @@ var SelectBase = function (_a) {
213
215
  // the menu)
214
216
  onKeyUp: function (e) {
215
217
  e.preventDefault();
216
- }, ref: forwardedButtonRef, type: "button", value: selectedOptionValue }, elemProps), selectedOptionLabel),
218
+ }, ref: forwardedButtonRef, type: "button", value: selectedOptionValue }, elemProps), !!selectedOption && renderSelected(selectedOption)),
217
219
  react_1.default.createElement(SelectInput, { onChange: onChange, ref: inputRef, type: "text", value: selectedOptionValue }),
218
220
  hasOptions && menuVisibility !== 'closed' && (react_1.default.createElement(SelectMenu_1.default, { "aria-activedescendant": options[focusedOptionIndex].id, "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired || required ? true : undefined, buttonRef: localButtonRef, id: menuId, error: error, menuRef: menuRef, onKeyDown: onKeyDown, onClose: onClose, placement: menuPlacement, shouldAutoFlip: shouldMenuAutoFlip, shouldAutoFocus: shouldMenuAutoFocus, visibility: menuVisibility }, renderOptions(renderOption))),
219
221
  react_1.default.createElement(SelectMenuIcon, { className: "menu-icon", icon: canvas_system_icons_web_1.caretDownSmallIcon, color: disabled ? tokens_1.colors.licorice100 : tokens_1.colors.licorice200, colorHover: disabled ? tokens_1.colors.licorice100 : tokens_1.colors.licorice500, size: menuIconSize })));
@@ -2,5 +2,5 @@ import Select from './lib/Select';
2
2
  export default Select;
3
3
  export { Select };
4
4
  export * from './lib/Select';
5
- export { Option, RenderableOption, RenderOptionFunction } from './lib/SelectBase';
5
+ export { Option, RenderableOption, RenderOptionFunction, RenderSelectedFunction, } from './lib/SelectBase';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../select/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,eAAe,MAAM,CAAC;AACtB,OAAO,EAAC,MAAM,EAAC,CAAC;AAChB,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../select/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,eAAe,MAAM,CAAC;AACtB,OAAO,EAAC,MAAM,EAAC,CAAC;AAChB,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC"}
@@ -17,6 +17,9 @@ export interface NormalizedOption extends Option {
17
17
  id: string;
18
18
  label: string;
19
19
  }
20
+ export interface RenderSelectedFunction {
21
+ (option: NormalizedOption): React.ReactNode;
22
+ }
20
23
  export interface RenderableOption extends NormalizedOption {
21
24
  focused: boolean;
22
25
  selected: boolean;
@@ -47,6 +50,22 @@ export interface CoreSelectBaseProps extends Themeable, GrowthBehavior, Pick<Rea
47
50
  * @default defaultRenderOption
48
51
  */
49
52
  renderOption?: RenderOptionFunction;
53
+ /**
54
+ * The function called to render the selected option.
55
+ *
56
+ * The `option` argument passed to the function is an object which contains the following:
57
+ *
58
+ * * `data: object` (data object carried over from the corresponding option originally passed into the component)
59
+ * * `disabled: boolean`
60
+ * * `id: string`
61
+ * * `label: string`
62
+ * * `value: string`
63
+ *
64
+ * If you omit the `renderSelected` prop, each option will be rendered using a `defaultRenderSelected` function provided by the component.
65
+ *
66
+ * @default defaultRenderSelected
67
+ */
68
+ renderSelected?: RenderSelectedFunction;
50
69
  /**
51
70
  * The value of the Select.
52
71
  */
@@ -118,6 +137,6 @@ export interface SelectBaseProps extends CoreSelectBaseProps, StyledType {
118
137
  }
119
138
  export declare const buttonBorderWidth = 1;
120
139
  export declare const buttonDefaultWidth = 280;
121
- declare const SelectBase: ({ "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired, as, forwardedButtonRef, localButtonRef, disabled, error, focusedOptionIndex, grow, inputRef, menuPlacement, menuRef, menuVisibility, onChange, onKeyDown, onClose, onOptionSelection, options, renderOption, required, shouldMenuAutoFlip, shouldMenuAutoFocus, value, ...elemProps }: SelectBaseProps) => JSX.Element;
140
+ declare const SelectBase: ({ "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired, as, forwardedButtonRef, localButtonRef, disabled, error, focusedOptionIndex, grow, inputRef, menuPlacement, menuRef, menuVisibility, onChange, onKeyDown, onClose, onOptionSelection, options, renderOption, renderSelected, required, shouldMenuAutoFlip, shouldMenuAutoFocus, value, ...elemProps }: SelectBaseProps) => JSX.Element;
122
141
  export default SelectBase;
123
142
  //# sourceMappingURL=SelectBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectBase.d.ts","sourceRoot":"","sources":["../../../../select/lib/SelectBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EAIV,MAAM,kCAAkC,CAAC;AAe1C,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAGtD,UAAU,UAAU;IAIlB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAiB,SAAQ,MAAM;IAE9C,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,MAAM,EAAE,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,mBACf,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CAAC,KAAK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CAAC;IACrB;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C;;;;;;;OAOG;IACH,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AA8GtC,QAAA,MAAM,UAAU,8WA0Bb,eAAe,gBAgKjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -101,10 +101,13 @@ var SelectWrapper = styled('div')({
101
101
  });
102
102
  });
103
103
  var defaultRenderOption = function (option) {
104
- return React.createElement("div", null, option.label);
104
+ return React.createElement("div", null, defaultRenderSelected(option));
105
+ };
106
+ var defaultRenderSelected = function (option) {
107
+ return option.label;
105
108
  };
106
109
  var SelectBase = function (_a) {
107
- var ariaLabelledBy = _a["aria-labelledby"], ariaRequired = _a["aria-required"], as = _a.as, forwardedButtonRef = _a.forwardedButtonRef, localButtonRef = _a.localButtonRef, disabled = _a.disabled, error = _a.error, _b = _a.focusedOptionIndex, focusedOptionIndex = _b === void 0 ? 0 : _b, grow = _a.grow, inputRef = _a.inputRef, _c = _a.menuPlacement, menuPlacement = _c === void 0 ? 'bottom' : _c, menuRef = _a.menuRef, _d = _a.menuVisibility, menuVisibility = _d === void 0 ? 'closed' : _d, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onClose = _a.onClose, onOptionSelection = _a.onOptionSelection, options = _a.options, _e = _a.renderOption, renderOption = _e === void 0 ? defaultRenderOption : _e, required = _a.required, _f = _a.shouldMenuAutoFlip, shouldMenuAutoFlip = _f === void 0 ? true : _f, _g = _a.shouldMenuAutoFocus, shouldMenuAutoFocus = _g === void 0 ? true : _g, value = _a.value, elemProps = __rest(_a, ['aria-labelledby', 'aria-required', "as", "forwardedButtonRef", "localButtonRef", "disabled", "error", "focusedOptionIndex", "grow", "inputRef", "menuPlacement", "menuRef", "menuVisibility", "onChange", "onKeyDown", "onClose", "onOptionSelection", "options", "renderOption", "required", "shouldMenuAutoFlip", "shouldMenuAutoFocus", "value"]);
110
+ var ariaLabelledBy = _a["aria-labelledby"], ariaRequired = _a["aria-required"], as = _a.as, forwardedButtonRef = _a.forwardedButtonRef, localButtonRef = _a.localButtonRef, disabled = _a.disabled, error = _a.error, _b = _a.focusedOptionIndex, focusedOptionIndex = _b === void 0 ? 0 : _b, grow = _a.grow, inputRef = _a.inputRef, _c = _a.menuPlacement, menuPlacement = _c === void 0 ? 'bottom' : _c, menuRef = _a.menuRef, _d = _a.menuVisibility, menuVisibility = _d === void 0 ? 'closed' : _d, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onClose = _a.onClose, onOptionSelection = _a.onOptionSelection, options = _a.options, _e = _a.renderOption, renderOption = _e === void 0 ? defaultRenderOption : _e, _f = _a.renderSelected, renderSelected = _f === void 0 ? defaultRenderSelected : _f, required = _a.required, _g = _a.shouldMenuAutoFlip, shouldMenuAutoFlip = _g === void 0 ? true : _g, _h = _a.shouldMenuAutoFocus, shouldMenuAutoFocus = _h === void 0 ? true : _h, value = _a.value, elemProps = __rest(_a, ['aria-labelledby', 'aria-required', "as", "forwardedButtonRef", "localButtonRef", "disabled", "error", "focusedOptionIndex", "grow", "inputRef", "menuPlacement", "menuRef", "menuVisibility", "onChange", "onKeyDown", "onClose", "onOptionSelection", "options", "renderOption", "renderSelected", "required", "shouldMenuAutoFlip", "shouldMenuAutoFocus", "value"]);
108
111
  var focusedOptionRef = React.useRef(null);
109
112
  var menuId = useUniqueId();
110
113
  var renderOptions = function (renderOption) {
@@ -179,7 +182,6 @@ var SelectBase = function (_a) {
179
182
  // Do a bit of error-checking in case options weren't provided
180
183
  var hasOptions = options.length > 0;
181
184
  var selectedOption = hasOptions ? options[getCorrectedIndexByValue(options, value)] : null;
182
- var selectedOptionLabel = selectedOption ? selectedOption.label : '';
183
185
  var selectedOptionValue = selectedOption ? selectedOption.value : '';
184
186
  return (React.createElement(SelectWrapper, { grow: grow, disabled: disabled },
185
187
  React.createElement(SelectButton, __assign({ "aria-expanded": menuVisibility !== 'closed' ? 'true' : undefined, "aria-haspopup": "listbox", "aria-controls": menuVisibility !== 'closed' ? menuId : undefined, as: as, disabled: disabled, error: error, grow: grow, menuVisibility: menuVisibility, onKeyDown: onKeyDown,
@@ -188,7 +190,7 @@ var SelectBase = function (_a) {
188
190
  // the menu)
189
191
  onKeyUp: function (e) {
190
192
  e.preventDefault();
191
- }, ref: forwardedButtonRef, type: "button", value: selectedOptionValue }, elemProps), selectedOptionLabel),
193
+ }, ref: forwardedButtonRef, type: "button", value: selectedOptionValue }, elemProps), !!selectedOption && renderSelected(selectedOption)),
192
194
  React.createElement(SelectInput, { onChange: onChange, ref: inputRef, type: "text", value: selectedOptionValue }),
193
195
  hasOptions && menuVisibility !== 'closed' && (React.createElement(SelectMenu, { "aria-activedescendant": options[focusedOptionIndex].id, "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired || required ? true : undefined, buttonRef: localButtonRef, id: menuId, error: error, menuRef: menuRef, onKeyDown: onKeyDown, onClose: onClose, placement: menuPlacement, shouldAutoFlip: shouldMenuAutoFlip, shouldAutoFocus: shouldMenuAutoFocus, visibility: menuVisibility }, renderOptions(renderOption))),
194
196
  React.createElement(SelectMenuIcon, { className: "menu-icon", icon: caretDownSmallIcon, color: disabled ? colors.licorice100 : colors.licorice200, colorHover: disabled ? colors.licorice100 : colors.licorice500, size: menuIconSize })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-preview-react",
3
- "version": "7.0.0-alpha.97-next.23+36224fdd",
3
+ "version": "8.0.0-alpha.111-next.0+2f9c1930",
4
4
  "description": "Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -45,15 +45,15 @@
45
45
  "dependencies": {
46
46
  "@emotion/react": "^11.7.1",
47
47
  "@emotion/styled": "^11.6.0",
48
- "@workday/canvas-kit-react": "^7.0.0-alpha.97-next.23+36224fdd",
48
+ "@workday/canvas-kit-react": "^8.0.0-alpha.111-next.0+2f9c1930",
49
49
  "@workday/canvas-system-icons-web": "^3.0.0",
50
50
  "@workday/design-assets-types": "^0.2.4"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@workday/canvas-accent-icons-web": "^3.0.0",
54
- "@workday/canvas-kit-labs-react": "^7.0.0-alpha.97-next.23+36224fdd",
54
+ "@workday/canvas-kit-labs-react": "^8.0.0-alpha.111-next.0+2f9c1930",
55
55
  "formik": "^2.2.9",
56
56
  "yup": "^0.31.1"
57
57
  },
58
- "gitHead": "36224fddf0e1c2382b1cbbeb1a2a2d356bfd22a3"
58
+ "gitHead": "2f9c193032b814210ceff5a30bbcc5dc2dd1a37c"
59
59
  }
package/select/index.ts CHANGED
@@ -4,4 +4,9 @@ export default Select;
4
4
  export {Select};
5
5
  export * from './lib/Select';
6
6
 
7
- export {Option, RenderableOption, RenderOptionFunction} from './lib/SelectBase';
7
+ export {
8
+ Option,
9
+ RenderableOption,
10
+ RenderOptionFunction,
11
+ RenderSelectedFunction,
12
+ } from './lib/SelectBase';
@@ -49,6 +49,10 @@ export interface NormalizedOption extends Option {
49
49
  label: string;
50
50
  }
51
51
 
52
+ export interface RenderSelectedFunction {
53
+ (option: NormalizedOption): React.ReactNode;
54
+ }
55
+
52
56
  export interface RenderableOption extends NormalizedOption {
53
57
  focused: boolean;
54
58
  selected: boolean;
@@ -86,6 +90,22 @@ export interface CoreSelectBaseProps
86
90
  * @default defaultRenderOption
87
91
  */
88
92
  renderOption?: RenderOptionFunction;
93
+ /**
94
+ * The function called to render the selected option.
95
+ *
96
+ * The `option` argument passed to the function is an object which contains the following:
97
+ *
98
+ * * `data: object` (data object carried over from the corresponding option originally passed into the component)
99
+ * * `disabled: boolean`
100
+ * * `id: string`
101
+ * * `label: string`
102
+ * * `value: string`
103
+ *
104
+ * If you omit the `renderSelected` prop, each option will be rendered using a `defaultRenderSelected` function provided by the component.
105
+ *
106
+ * @default defaultRenderSelected
107
+ */
108
+ renderSelected?: RenderSelectedFunction;
89
109
  /**
90
110
  * The value of the Select.
91
111
  */
@@ -261,7 +281,11 @@ const SelectWrapper = styled('div')<Pick<SelectBaseProps, 'grow' | 'disabled'>>(
261
281
  );
262
282
 
263
283
  const defaultRenderOption: RenderOptionFunction = option => {
264
- return <div>{option.label}</div>;
284
+ return <div>{defaultRenderSelected(option)}</div>;
285
+ };
286
+
287
+ const defaultRenderSelected: RenderSelectedFunction = option => {
288
+ return option.label;
265
289
  };
266
290
 
267
291
  const SelectBase = ({
@@ -284,6 +308,7 @@ const SelectBase = ({
284
308
  onOptionSelection,
285
309
  options,
286
310
  renderOption = defaultRenderOption,
311
+ renderSelected = defaultRenderSelected,
287
312
  required,
288
313
  shouldMenuAutoFlip = true,
289
314
  shouldMenuAutoFocus = true,
@@ -393,7 +418,6 @@ const SelectBase = ({
393
418
  // Do a bit of error-checking in case options weren't provided
394
419
  const hasOptions = options.length > 0;
395
420
  const selectedOption = hasOptions ? options[getCorrectedIndexByValue(options, value)] : null;
396
- const selectedOptionLabel = selectedOption ? selectedOption.label : '';
397
421
  const selectedOptionValue = selectedOption ? selectedOption.value : '';
398
422
 
399
423
  return (
@@ -419,7 +443,7 @@ const SelectBase = ({
419
443
  value={selectedOptionValue}
420
444
  {...elemProps}
421
445
  >
422
- {selectedOptionLabel}
446
+ {!!selectedOption && renderSelected(selectedOption)}
423
447
  </SelectButton>
424
448
  <SelectInput onChange={onChange} ref={inputRef} type="text" value={selectedOptionValue} />
425
449
  {hasOptions && menuVisibility !== 'closed' && (