@db-ux/react-core-components 2.0.0-0-6589a60 → 2.0.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.
Files changed (112) hide show
  1. package/dist/components/accordion/accordion.d.ts +1 -1
  2. package/dist/components/accordion/accordion.js +8 -9
  3. package/dist/components/accordion/model.d.ts +2 -2
  4. package/dist/components/accordion-item/accordion-item.d.ts +3 -3
  5. package/dist/components/accordion-item/accordion-item.js +27 -3
  6. package/dist/components/accordion-item/model.d.ts +5 -5
  7. package/dist/components/badge/badge.d.ts +1 -1
  8. package/dist/components/badge/model.d.ts +2 -2
  9. package/dist/components/brand/brand.d.ts +1 -1
  10. package/dist/components/button/button.d.ts +1 -1
  11. package/dist/components/button/button.js +2 -2
  12. package/dist/components/button/model.d.ts +11 -7
  13. package/dist/components/card/card.d.ts +1 -1
  14. package/dist/components/checkbox/checkbox.d.ts +1 -1
  15. package/dist/components/checkbox/checkbox.js +34 -25
  16. package/dist/components/checkbox/model.d.ts +3 -3
  17. package/dist/components/custom-select/custom-select.d.ts +3 -0
  18. package/dist/components/custom-select/custom-select.js +553 -0
  19. package/dist/components/custom-select/index.d.ts +1 -0
  20. package/dist/components/custom-select/index.js +1 -0
  21. package/dist/components/custom-select/model.d.ts +193 -0
  22. package/dist/components/custom-select/model.js +1 -0
  23. package/dist/components/custom-select-dropdown/custom-select-dropdown.d.ts +3 -0
  24. package/dist/components/custom-select-dropdown/custom-select-dropdown.js +12 -0
  25. package/dist/components/custom-select-dropdown/index.d.ts +1 -0
  26. package/dist/components/custom-select-dropdown/index.js +1 -0
  27. package/dist/components/custom-select-dropdown/model.d.ts +15 -0
  28. package/dist/components/custom-select-dropdown/model.js +1 -0
  29. package/dist/components/custom-select-form-field/custom-select-form-field.d.ts +3 -0
  30. package/dist/components/custom-select-form-field/custom-select-form-field.js +11 -0
  31. package/dist/components/custom-select-form-field/index.d.ts +1 -0
  32. package/dist/components/custom-select-form-field/index.js +1 -0
  33. package/dist/components/custom-select-form-field/model.d.ts +5 -0
  34. package/dist/components/custom-select-form-field/model.js +1 -0
  35. package/dist/components/custom-select-list/custom-select-list.d.ts +3 -0
  36. package/dist/components/custom-select-list/custom-select-list.js +12 -0
  37. package/dist/components/custom-select-list/index.d.ts +1 -0
  38. package/dist/components/custom-select-list/index.js +1 -0
  39. package/dist/components/custom-select-list/model.d.ts +8 -0
  40. package/dist/components/custom-select-list/model.js +1 -0
  41. package/dist/components/custom-select-list-item/custom-select-list-item.d.ts +6 -0
  42. package/dist/components/custom-select-list-item/custom-select-list-item.js +37 -0
  43. package/dist/components/custom-select-list-item/index.d.ts +1 -0
  44. package/dist/components/custom-select-list-item/index.js +1 -0
  45. package/dist/components/custom-select-list-item/model.d.ts +29 -0
  46. package/dist/components/custom-select-list-item/model.js +1 -0
  47. package/dist/components/divider/divider.d.ts +1 -1
  48. package/dist/components/drawer/drawer.d.ts +1 -1
  49. package/dist/components/drawer/drawer.js +6 -7
  50. package/dist/components/drawer/model.d.ts +2 -2
  51. package/dist/components/header/header.d.ts +1 -1
  52. package/dist/components/header/header.js +8 -7
  53. package/dist/components/header/model.d.ts +2 -2
  54. package/dist/components/icon/icon.d.ts +1 -1
  55. package/dist/components/infotext/infotext.d.ts +1 -1
  56. package/dist/components/input/input.d.ts +1 -1
  57. package/dist/components/input/input.js +43 -34
  58. package/dist/components/input/model.d.ts +3 -3
  59. package/dist/components/link/link.d.ts +1 -1
  60. package/dist/components/link/link.js +1 -1
  61. package/dist/components/navigation/navigation.d.ts +1 -1
  62. package/dist/components/navigation-item/model.d.ts +2 -3
  63. package/dist/components/navigation-item/navigation-item.d.ts +1 -1
  64. package/dist/components/navigation-item/navigation-item.js +14 -17
  65. package/dist/components/notification/model.d.ts +3 -3
  66. package/dist/components/notification/notification.d.ts +1 -1
  67. package/dist/components/notification/notification.js +3 -3
  68. package/dist/components/page/model.d.ts +1 -1
  69. package/dist/components/page/page.d.ts +1 -1
  70. package/dist/components/page/page.js +1 -1
  71. package/dist/components/popover/model.d.ts +1 -1
  72. package/dist/components/popover/popover.d.ts +1 -1
  73. package/dist/components/popover/popover.js +1 -1
  74. package/dist/components/radio/radio.d.ts +1 -1
  75. package/dist/components/radio/radio.js +2 -11
  76. package/dist/components/section/section.d.ts +1 -1
  77. package/dist/components/select/model.d.ts +5 -5
  78. package/dist/components/select/select.d.ts +1 -1
  79. package/dist/components/select/select.js +47 -40
  80. package/dist/components/stack/model.d.ts +1 -1
  81. package/dist/components/stack/stack.d.ts +1 -1
  82. package/dist/components/switch/model.d.ts +2 -2
  83. package/dist/components/switch/switch.d.ts +1 -1
  84. package/dist/components/switch/switch.js +3 -12
  85. package/dist/components/tab-item/model.d.ts +6 -6
  86. package/dist/components/tab-item/tab-item.d.ts +1 -1
  87. package/dist/components/tab-item/tab-item.js +26 -9
  88. package/dist/components/tab-list/tab-list.d.ts +1 -1
  89. package/dist/components/tab-panel/tab-panel.d.ts +1 -1
  90. package/dist/components/tabs/model.d.ts +11 -3
  91. package/dist/components/tabs/tabs.d.ts +1 -1
  92. package/dist/components/tabs/tabs.js +16 -15
  93. package/dist/components/tag/model.d.ts +11 -7
  94. package/dist/components/tag/tag.d.ts +1 -1
  95. package/dist/components/tag/tag.js +6 -5
  96. package/dist/components/textarea/model.d.ts +4 -4
  97. package/dist/components/textarea/textarea.d.ts +1 -1
  98. package/dist/components/textarea/textarea.js +39 -31
  99. package/dist/components/tooltip/model.d.ts +1 -1
  100. package/dist/components/tooltip/tooltip.d.ts +1 -1
  101. package/dist/index.d.ts +5 -0
  102. package/dist/index.js +5 -0
  103. package/dist/shared/constants.d.ts +5 -0
  104. package/dist/shared/constants.js +6 -1
  105. package/dist/shared/model.d.ts +83 -41
  106. package/dist/shared/model.js +3 -2
  107. package/dist/utils/document-click-listener.d.ts +8 -0
  108. package/dist/utils/document-click-listener.js +29 -0
  109. package/dist/utils/index.d.ts +6 -27
  110. package/dist/utils/index.js +22 -20
  111. package/dist/utils/react.d.ts +4 -4
  112. package/package.json +4 -3
@@ -1,4 +1,4 @@
1
- import { ChangeEventProps, ChangeEventState, FocusEventProps, FocusEventState, FormMessageProps, FormProps, FormState, FormTextProps, GlobalProps, GlobalState, InputEventProps, InputEventState } from '../../shared/model';
1
+ import { ChangeEventProps, ChangeEventState, FocusEventProps, FocusEventState, FormMessageProps, FormProps, FormState, FormTextProps, FromValidState, GlobalProps, GlobalState, InputEventProps, InputEventState } from '../../shared/model';
2
2
  export declare const TextareaResizeList: readonly ["none", "both", "horizontal", "vertical"];
3
3
  export type TextareaResizeType = (typeof TextareaResizeList)[number];
4
4
  export declare const TextareaWrapList: readonly ["hard", "soft", "off"];
@@ -7,7 +7,7 @@ export type DBTextareaDefaultProps = {
7
7
  /**
8
8
  * The visible width of the text control, in average character widths. If it is specified, it must be a positive integer
9
9
  */
10
- cols?: number;
10
+ cols?: number | string;
11
11
  /**
12
12
  * In most browsers, textareas are resizable — you'll notice the drag handle in the right-hand corner, you can control it with this
13
13
  */
@@ -15,7 +15,7 @@ export type DBTextareaDefaultProps = {
15
15
  /**
16
16
  * The number of visible text lines for the control. If it is specified, it must be a positive integer
17
17
  */
18
- rows?: number;
18
+ rows?: number | string;
19
19
  /**
20
20
  * Specifies whether the textarea is subject to spell checking by the underlying browser/OS
21
21
  */
@@ -27,4 +27,4 @@ export type DBTextareaDefaultProps = {
27
27
  };
28
28
  export type DBTextareaProps = DBTextareaDefaultProps & ChangeEventProps<HTMLTextAreaElement> & InputEventProps<HTMLTextAreaElement> & FocusEventProps<HTMLTextAreaElement> & FormProps & GlobalProps & FormTextProps & FormMessageProps;
29
29
  export type DBTextareaDefaultState = {};
30
- export type DBTextareaState = DBTextareaDefaultState & ChangeEventState<HTMLTextAreaElement> & InputEventState<HTMLTextAreaElement> & FocusEventState<HTMLTextAreaElement> & FormState & GlobalState;
30
+ export type DBTextareaState = DBTextareaDefaultState & ChangeEventState<HTMLTextAreaElement> & InputEventState<HTMLTextAreaElement> & FocusEventState<HTMLTextAreaElement> & FormState & GlobalState & FromValidState;
@@ -1,3 +1,3 @@
1
1
  import * as React from "react";
2
- declare const DBTextarea: React.ForwardRefExoticComponent<Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").FormProps | keyof import("../../shared/model").FormMessageProps | keyof import("../../shared/model").FormTextProps | keyof import("./model").DBTextareaDefaultProps | keyof import("../../shared/model").ChangeEventProps<HTMLTextAreaElement> | keyof import("../../shared/model").InputEventProps<HTMLTextAreaElement> | keyof import("../../shared/model").FocusEventProps<HTMLTextAreaElement>> & import("./model").DBTextareaDefaultProps & import("../../shared/model").ChangeEventProps<HTMLTextAreaElement> & import("../../shared/model").InputEventProps<HTMLTextAreaElement> & import("../../shared/model").FocusEventProps<HTMLTextAreaElement> & import("../../shared/model").FormProps & import("../../shared/model").GlobalProps & import("../../shared/model").FormTextProps & import("../../shared/model").FormMessageProps & React.RefAttributes<HTMLTextAreaElement>>;
2
+ declare const DBTextarea: React.ForwardRefExoticComponent<Omit<React.TextareaHTMLAttributes<any>, "required" | "value" | keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").CustomFormProps | keyof import("../../shared/model").BaseFormProps | "showLabel" | keyof import("../../shared/model").FormMessageProps | keyof import("../../shared/model").FormTextProps | keyof import("./model").DBTextareaDefaultProps | keyof import("../../shared/model").ChangeEventProps<HTMLTextAreaElement> | keyof import("../../shared/model").InputEventProps<HTMLTextAreaElement> | keyof import("../../shared/model").FocusEventProps<HTMLTextAreaElement>> & import("./model").DBTextareaDefaultProps & import("../../shared/model").ChangeEventProps<HTMLTextAreaElement> & import("../../shared/model").InputEventProps<HTMLTextAreaElement> & import("../../shared/model").FocusEventProps<HTMLTextAreaElement> & import("../../shared/model").CustomFormProps & import("../../shared/model").BaseFormProps & import("../../shared/model").RequiredProps & import("../../shared/model").ShowLabelProps & import("../../shared/model").ValueProps & import("../../shared/model").GlobalProps & import("../../shared/model").FormTextProps & import("../../shared/model").FormMessageProps & React.RefAttributes<any>>;
3
3
  export default DBTextarea;
@@ -3,48 +3,42 @@ import * as React from "react";
3
3
  import { filterPassingProps, getRootProps } from "../../utils/react";
4
4
  import { useState, useRef, useEffect, forwardRef } from "react";
5
5
  import DBInfotext from "../infotext/infotext";
6
- import { cls, delay, getHideProp, hasVoiceOver, stringPropVisible, uuid, } from "../../utils";
6
+ import { cls, delay, getBoolean, getHideProp, getNumber, hasVoiceOver, stringPropVisible, uuid, } from "../../utils";
7
7
  import { DEFAULT_INVALID_MESSAGE, DEFAULT_INVALID_MESSAGE_ID_SUFFIX, DEFAULT_LABEL, DEFAULT_MESSAGE_ID_SUFFIX, DEFAULT_PLACEHOLDER, DEFAULT_ROWS, DEFAULT_VALID_MESSAGE, DEFAULT_VALID_MESSAGE_ID_SUFFIX, } from "../../shared/constants";
8
8
  function DBTextareaFn(props, component) {
9
- var _a, _b, _c, _d, _e, _f, _g;
9
+ var _a, _b;
10
10
  const _ref = component || useRef(component);
11
11
  const [_id, set_id] = useState(() => undefined);
12
12
  const [_messageId, set_messageId] = useState(() => undefined);
13
13
  const [_validMessageId, set_validMessageId] = useState(() => undefined);
14
14
  const [_invalidMessageId, set_invalidMessageId] = useState(() => undefined);
15
+ const [_invalidMessage, set_invalidMessage] = useState(() => undefined);
15
16
  const [_descByIds, set_descByIds] = useState(() => "");
16
17
  const [_value, set_value] = useState(() => "");
17
18
  const [_voiceOverFallback, set_voiceOverFallback] = useState(() => "");
18
- function handleInput(event) {
19
- if (props.onInput) {
20
- props.onInput(event);
21
- }
22
- if (props.input) {
23
- props.input(event);
24
- }
19
+ function hasValidState() {
20
+ var _a;
21
+ return !!((_a = props.validMessage) !== null && _a !== void 0 ? _a : props.validation === "valid");
25
22
  }
26
- function handleChange(event) {
27
- var _a, _b, _c, _d, _e, _f;
28
- if (props.onChange) {
29
- props.onChange(event);
30
- }
31
- if (props.change) {
32
- props.change(event);
33
- }
23
+ function handleValidation() {
24
+ var _a, _b, _c, _d;
34
25
  /* For a11y reasons we need to map the correct message with the textarea */
35
26
  if (!((_a = _ref.current) === null || _a === void 0 ? void 0 : _a.validity.valid) || props.validation === "invalid") {
36
27
  set_descByIds(_invalidMessageId);
28
+ set_invalidMessage(props.invalidMessage ||
29
+ ((_b = _ref.current) === null || _b === void 0 ? void 0 : _b.validationMessage) ||
30
+ DEFAULT_INVALID_MESSAGE);
37
31
  if (hasVoiceOver()) {
38
- set_voiceOverFallback((_d = (_b = props.invalidMessage) !== null && _b !== void 0 ? _b : (_c = _ref.current) === null || _c === void 0 ? void 0 : _c.validationMessage) !== null && _d !== void 0 ? _d : DEFAULT_INVALID_MESSAGE);
32
+ set_voiceOverFallback(_invalidMessage);
39
33
  delay(() => set_voiceOverFallback(""), 1000);
40
34
  }
41
35
  }
42
- else if (props.validation === "valid" ||
43
- (((_e = _ref.current) === null || _e === void 0 ? void 0 : _e.validity.valid) &&
44
- (props.required || props.minLength || props.maxLength))) {
36
+ else if (hasValidState() &&
37
+ ((_c = _ref.current) === null || _c === void 0 ? void 0 : _c.validity.valid) &&
38
+ (props.required || props.minLength || props.maxLength)) {
45
39
  set_descByIds(_validMessageId);
46
40
  if (hasVoiceOver()) {
47
- set_voiceOverFallback((_f = props.validMessage) !== null && _f !== void 0 ? _f : DEFAULT_VALID_MESSAGE);
41
+ set_voiceOverFallback((_d = props.validMessage) !== null && _d !== void 0 ? _d : DEFAULT_VALID_MESSAGE);
48
42
  delay(() => set_voiceOverFallback(""), 1000);
49
43
  }
50
44
  }
@@ -55,21 +49,27 @@ function DBTextareaFn(props, component) {
55
49
  set_descByIds("");
56
50
  }
57
51
  }
52
+ function handleInput(event) {
53
+ if (props.onInput) {
54
+ props.onInput(event);
55
+ }
56
+ handleValidation();
57
+ }
58
+ function handleChange(event) {
59
+ if (props.onChange) {
60
+ props.onChange(event);
61
+ }
62
+ handleValidation();
63
+ }
58
64
  function handleBlur(event) {
59
65
  if (props.onBlur) {
60
66
  props.onBlur(event);
61
67
  }
62
- if (props.blur) {
63
- props.blur(event);
64
- }
65
68
  }
66
69
  function handleFocus(event) {
67
70
  if (props.onFocus) {
68
71
  props.onFocus(event);
69
72
  }
70
- if (props.focus) {
71
- props.focus(event);
72
- }
73
73
  }
74
74
  useEffect(() => {
75
75
  var _a;
@@ -78,7 +78,14 @@ function DBTextareaFn(props, component) {
78
78
  set_messageId(mId + DEFAULT_MESSAGE_ID_SUFFIX);
79
79
  set_validMessageId(mId + DEFAULT_VALID_MESSAGE_ID_SUFFIX);
80
80
  set_invalidMessageId(mId + DEFAULT_INVALID_MESSAGE_ID_SUFFIX);
81
+ set_invalidMessage(props.invalidMessage || DEFAULT_INVALID_MESSAGE);
81
82
  }, []);
83
+ useEffect(() => {
84
+ var _a;
85
+ set_invalidMessage(props.invalidMessage ||
86
+ ((_a = _ref.current) === null || _a === void 0 ? void 0 : _a.validationMessage) ||
87
+ DEFAULT_INVALID_MESSAGE);
88
+ }, [_ref.current, props.invalidMessage]);
82
89
  useEffect(() => {
83
90
  if (_id) {
84
91
  const messageId = _id + DEFAULT_MESSAGE_ID_SUFFIX;
@@ -95,10 +102,11 @@ function DBTextareaFn(props, component) {
95
102
  }, [props.value]);
96
103
  return (React.createElement("div", Object.assign({}, getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { className: cls("db-textarea", props.className), "data-variant": props.variant, "data-hide-label": getHideProp(props.showLabel) }),
97
104
  React.createElement("label", { htmlFor: _id }, (_a = props.label) !== null && _a !== void 0 ? _a : DEFAULT_LABEL),
98
- React.createElement("textarea", Object.assign({ "aria-invalid": props.validation === "invalid", "data-custom-validity": props.validation, ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { id: _id, "data-resize": props.resize, disabled: props.disabled, required: props.required, readOnly: props.readOnly, form: props.form, maxLength: props.maxLength, minLength: props.minLength, name: props.name, wrap: props.wrap, spellCheck: props.spellCheck, autoComplete: props.autocomplete, onInput: (event) => handleInput(event), onChange: (event) => handleChange(event), onBlur: (event) => handleBlur(event), onFocus: (event) => handleFocus(event), value: props.value, "aria-describedby": _descByIds, placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : DEFAULT_PLACEHOLDER, rows: (_c = props.rows) !== null && _c !== void 0 ? _c : DEFAULT_ROWS, cols: props.cols })),
105
+ React.createElement("textarea", Object.assign({ "aria-invalid": props.validation === "invalid", "data-custom-validity": props.validation, ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { id: _id, "data-resize": props.resize, disabled: getBoolean(props.disabled, "disabled"), required: getBoolean(props.required, "required"), readOnly: getBoolean(props.readOnly, "readOnly") ||
106
+ getBoolean(props.readonly, "readonly"), form: props.form, maxLength: getNumber(props.maxLength, props.maxlength), minLength: getNumber(props.minLength, props.minlength), name: props.name, wrap: props.wrap, spellCheck: props.spellCheck, autoComplete: props.autocomplete, onInput: (event) => handleInput(event), onChange: (event) => handleChange(event), onBlur: (event) => handleBlur(event), onFocus: (event) => handleFocus(event), value: props.value, "aria-describedby": _descByIds, placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : DEFAULT_PLACEHOLDER, rows: getNumber(props.rows, DEFAULT_ROWS), cols: getNumber(props.cols) })),
99
107
  stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
100
- React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, (_d = props.validMessage) !== null && _d !== void 0 ? _d : DEFAULT_VALID_MESSAGE),
101
- React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, (_g = (_e = props.invalidMessage) !== null && _e !== void 0 ? _e : (_f = _ref.current) === null || _f === void 0 ? void 0 : _f.validationMessage) !== null && _g !== void 0 ? _g : DEFAULT_INVALID_MESSAGE),
108
+ hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
109
+ React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
102
110
  React.createElement("span", { "data-visually-hidden": "true", role: "status" }, _voiceOverFallback)));
103
111
  }
104
112
  const DBTextarea = forwardRef(DBTextareaFn);
@@ -1,6 +1,6 @@
1
1
  import { ClickEventState, EmphasisProps, GlobalProps, GlobalState, InitializedState, PlacementProps, PopoverProps, PopoverState } from '../../shared/model';
2
2
  export type DBTooltipDefaultProps = {
3
- showArrow?: boolean;
3
+ showArrow?: boolean | string;
4
4
  };
5
5
  export type DBTooltipProps = DBTooltipDefaultProps & GlobalProps & EmphasisProps & PlacementProps & PopoverProps;
6
6
  export type DBTooltipDefaultState = {};
@@ -1,3 +1,3 @@
1
1
  import * as React from "react";
2
- declare const DBTooltip: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement>, keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").PopoverProps | "placement" | "emphasis" | "showArrow"> & import("./model").DBTooltipDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").EmphasisProps & import("../../shared/model").PlacementProps & import("../../shared/model").PopoverProps & React.RefAttributes<HTMLDivElement>>;
2
+ declare const DBTooltip: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").PopoverProps | "placement" | "emphasis" | "showArrow"> & import("./model").DBTooltipDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").EmphasisProps & import("../../shared/model").PlacementProps & import("../../shared/model").PopoverProps & React.RefAttributes<any>>;
3
3
  export default DBTooltip;
package/dist/index.d.ts CHANGED
@@ -34,3 +34,8 @@ export * from './shared/model';
34
34
  export * from './utils/index';
35
35
  export * from './utils/navigation';
36
36
  export * from './components/stack';
37
+ export * from './components/custom-select';
38
+ export * from './components/custom-select-form-field';
39
+ export * from './components/custom-select-dropdown';
40
+ export * from './components/custom-select-list';
41
+ export * from './components/custom-select-list-item';
package/dist/index.js CHANGED
@@ -34,3 +34,8 @@ export * from './shared/model';
34
34
  export * from './utils/index';
35
35
  export * from './utils/navigation';
36
36
  export * from './components/stack';
37
+ export * from './components/custom-select';
38
+ export * from './components/custom-select-form-field';
39
+ export * from './components/custom-select-dropdown';
40
+ export * from './components/custom-select-list';
41
+ export * from './components/custom-select-list-item';
@@ -1,6 +1,9 @@
1
1
  export declare const DEFAULT_ID: string;
2
2
  export declare const DEFAULT_LABEL: string;
3
3
  export declare const DEFAULT_PLACEHOLDER: string;
4
+ export declare const DEFAULT_MESSAGE: string;
5
+ export declare const DEFAULT_LABEL_ID_SUFFIX: string;
6
+ export declare const DEFAULT_SELECT_ID_SUFFIX: string;
4
7
  export declare const DEFAULT_MESSAGE_ID_SUFFIX: string;
5
8
  export declare const DEFAULT_VALID_MESSAGE_ID_SUFFIX: string;
6
9
  export declare const DEFAULT_INVALID_MESSAGE_ID_SUFFIX: string;
@@ -8,7 +11,9 @@ export declare const DEFAULT_PLACEHOLDER_ID_SUFFIX: string;
8
11
  export declare const DEFAULT_DATALIST_ID_SUFFIX: string;
9
12
  export declare const DEFAULT_VALID_MESSAGE: string;
10
13
  export declare const DEFAULT_INVALID_MESSAGE: string;
14
+ export declare const DEFAULT_REMOVE: string;
11
15
  export declare const DEFAULT_BACK: string;
16
+ export declare const DEFAULT_SELECTED: string;
12
17
  export declare const DEFAULT_BURGER_MENU: string;
13
18
  export declare const DEFAULT_ICON: string;
14
19
  export declare const DEFAULT_ROWS: number;
@@ -1,6 +1,9 @@
1
1
  export const DEFAULT_ID = 'OVERWRITE_DEFAULT_ID';
2
2
  export const DEFAULT_LABEL = 'LABEL SHOULD BE SET';
3
3
  export const DEFAULT_PLACEHOLDER = ' ';
4
+ export const DEFAULT_MESSAGE = 'MESSAGE SHOULD BE SET';
5
+ export const DEFAULT_LABEL_ID_SUFFIX = '-label';
6
+ export const DEFAULT_SELECT_ID_SUFFIX = '-select';
4
7
  export const DEFAULT_MESSAGE_ID_SUFFIX = '-message';
5
8
  export const DEFAULT_VALID_MESSAGE_ID_SUFFIX = '-valid-message';
6
9
  export const DEFAULT_INVALID_MESSAGE_ID_SUFFIX = '-invalid-message';
@@ -8,11 +11,13 @@ export const DEFAULT_PLACEHOLDER_ID_SUFFIX = '-placeholder';
8
11
  export const DEFAULT_DATALIST_ID_SUFFIX = '-datalist';
9
12
  export const DEFAULT_VALID_MESSAGE = 'TODO: Add a validMessage';
10
13
  export const DEFAULT_INVALID_MESSAGE = 'TODO: Add an invalidMessage';
14
+ export const DEFAULT_REMOVE = 'Remove';
11
15
  export const DEFAULT_BACK = 'Back';
16
+ export const DEFAULT_SELECTED = 'Selected';
12
17
  export const DEFAULT_BURGER_MENU = 'BurgerMenu';
13
18
  export const DEFAULT_ICON = 'brand';
14
19
  export const DEFAULT_ROWS = 4;
15
- export const DEFAULT_CLOSE_BUTTON = 'Close Button';
20
+ export const DEFAULT_CLOSE_BUTTON = 'Close';
16
21
  export const DENSITY_CONST = 'density';
17
22
  export const COLOR_CONST = 'color';
18
23
  export var DENSITY;
@@ -24,7 +24,7 @@ export type GlobalProps = {
24
24
  /**
25
25
  * Before using please check for the [accessibility concerns](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus#accessibility_concerns)
26
26
  */
27
- autofocus?: boolean;
27
+ autofocus?: boolean | string;
28
28
  };
29
29
  export type GlobalState = {
30
30
  _id?: string;
@@ -48,7 +48,7 @@ export type ShowIconProps = {
48
48
  * Enables or disables the visibility of the icon. The default value depends on the component.
49
49
  * For many components this property is optional to reflect Figma properties.
50
50
  */
51
- showIcon?: boolean;
51
+ showIcon?: boolean | string;
52
52
  };
53
53
  export type IconAfterProps = {
54
54
  /**
@@ -72,7 +72,11 @@ export type MarginProps = {
72
72
  */
73
73
  margin?: MarginType;
74
74
  };
75
- export declare const PlacementList: readonly ["left", "right", "top", "bottom", "left-start", "left-end", "right-start", "right-end", "top-start", "top-end", "bottom-start", "bottom-end"];
75
+ export declare const PlacementHorizontalList: readonly ["left", "right", "left-start", "left-end", "right-start", "right-end"];
76
+ export type PlacementHorizontalType = (typeof PlacementHorizontalList)[number];
77
+ export declare const PlacementVerticalList: readonly ["top", "bottom", "top-start", "top-end", "bottom-start", "bottom-end"];
78
+ export type PlacementVerticalType = (typeof PlacementVerticalList)[number];
79
+ export declare const PlacementList: readonly ["left", "right", "left-start", "left-end", "right-start", "right-end", "top", "bottom", "top-start", "top-end", "bottom-start", "bottom-end"];
76
80
  export type PlacementType = (typeof PlacementList)[number];
77
81
  export type PlacementProps = {
78
82
  /**
@@ -87,7 +91,7 @@ export type GapProps = {
87
91
  /**
88
92
  * If the absolute element should have a gap between the parent element.
89
93
  */
90
- gap?: boolean;
94
+ gap?: boolean | string;
91
95
  };
92
96
  export declare const GapSpacingList: readonly ["none", "3x-large", "2x-large", "x-large", "large", "medium", "small", "x-small", "2x-small", "3x-small"];
93
97
  export type GapSpacingType = (typeof GapSpacingList)[number];
@@ -101,7 +105,7 @@ export type OverflowProps = {
101
105
  /**
102
106
  * The overflow attribute sets a max-width and longer text will be dotted.
103
107
  */
104
- overflow?: boolean;
108
+ overflow?: boolean | string;
105
109
  };
106
110
  export declare const OrientationList: readonly ["horizontal", "vertical"];
107
111
  export type OrientationType = (typeof OrientationList)[number];
@@ -139,7 +143,7 @@ export type PopoverProps = {
139
143
  /**
140
144
  * Disable animation
141
145
  */
142
- animation?: boolean;
146
+ animation?: boolean | string;
143
147
  /**
144
148
  * Use fixed with for default max-width
145
149
  */
@@ -148,6 +152,16 @@ export type PopoverProps = {
148
152
  export type PopoverState = {
149
153
  handleAutoPlacement: () => void;
150
154
  };
155
+ export type NameProps = {
156
+ /**
157
+ * The name attribute gives the name of the element to group it.
158
+ */
159
+ name?: string;
160
+ };
161
+ export type NameState = {
162
+ _name?: string;
163
+ handleNameAttribute: () => void;
164
+ };
151
165
  export type ContentSlotProps = {
152
166
  /**
153
167
  * Default slot which is used to pass in additional content.
@@ -170,29 +184,31 @@ export type EmphasisProps = {
170
184
  */
171
185
  emphasis?: EmphasisType;
172
186
  };
173
- export declare const TagEmphasisList: readonly ["weak", "strong", "origin"];
174
- export type TagEmphasisType = (typeof TagEmphasisList)[number];
175
- export type TagEmphasisProps = {
187
+ export declare const ValidationList: readonly ["invalid", "valid", "no-validation"];
188
+ export type ValidationType = (typeof ValidationList)[number];
189
+ export type RequiredProps = {
176
190
  /**
177
- * The emphasis attribute divides in between a weak, strong or origin appearance.
191
+ * When the required attribute specified, the user will be required to fill the form element before submitting the form.
178
192
  */
179
- emphasis?: TagEmphasisType;
193
+ required?: boolean | string;
180
194
  };
181
- export declare const ValidationList: readonly ["invalid", "valid", "no-validation"];
182
- export type ValidationType = (typeof ValidationList)[number];
183
- export type FormProps = {
195
+ export type ShowLabelProps = {
184
196
  /**
185
- * Marks an input element as invalid (red) / valid (green) / no-validation (grey). Overwrites the :user-valid selector.
197
+ * Enables/disables the visibility of the label
186
198
  */
187
- validation?: ValidationType;
199
+ showLabel?: boolean | string;
200
+ };
201
+ export type ValueProps = {
188
202
  /**
189
- * The disabled attribute can be set to keep a user from clicking on the form element.
203
+ * The value property is to receive results from the native form element.
190
204
  */
191
- disabled?: boolean;
205
+ value?: any;
206
+ };
207
+ export type BaseFormProps = {
192
208
  /**
193
- * Associates the control with a form element
209
+ * The disabled attribute can be set to keep a user from clicking on the form element.
194
210
  */
195
- form?: string;
211
+ disabled?: boolean | string;
196
212
  /**
197
213
  * The label attribute specifies the caption of the form element.
198
214
  */
@@ -201,32 +217,47 @@ export type FormProps = {
201
217
  * The name attribute gives the name of the form control, as used in form submission and in the form element's elements object.
202
218
  */
203
219
  name?: string;
220
+ };
221
+ export type CustomFormProps = {
204
222
  /**
205
- * When the required attribute specified, the user will be required to fill the form element before submitting the form.
223
+ * Overwrites auto handling for aria-describedby.
206
224
  */
207
- required?: boolean;
225
+ ariaDescribedBy?: string;
208
226
  /**
209
- * Enables/disables the visibility of the label
227
+ * Associates the control with a form element
210
228
  */
211
- showLabel?: boolean;
229
+ form?: string;
212
230
  /**
213
- * The value property is to receive results from the native form element.
231
+ * Marks an input element as invalid (red) / valid (green) / no-validation (grey). Overwrites the :user-valid selector.
214
232
  */
215
- value?: any;
233
+ validation?: ValidationType;
216
234
  };
235
+ export type FormProps = CustomFormProps & BaseFormProps & RequiredProps & ShowLabelProps & ValueProps;
217
236
  export type FormTextProps = {
218
237
  /**
219
238
  * Maximum length (number of characters) of value
220
239
  */
221
- maxLength?: number;
240
+ maxLength?: number | string;
222
241
  /**
223
242
  * Minimum length (number of characters) of value
224
243
  */
225
- minLength?: number;
244
+ minLength?: number | string;
245
+ /**
246
+ * Maximum length (number of characters) of value
247
+ */
248
+ maxlength?: number | string;
249
+ /**
250
+ * Minimum length (number of characters) of value
251
+ */
252
+ minlength?: number | string;
253
+ /**
254
+ * The disabled attribute can be set to keep a user from edit on the form element
255
+ */
256
+ readOnly?: boolean | string;
226
257
  /**
227
258
  * The disabled attribute can be set to keep a user from edit on the form element
228
259
  */
229
- readOnly?: boolean;
260
+ readonly?: boolean | string;
230
261
  };
231
262
  export type FormSizeProps = {
232
263
  /**
@@ -238,7 +269,7 @@ export type FormCheckProps = {
238
269
  /**
239
270
  * Define the radio or checkbox elements checked state
240
271
  */
241
- checked?: boolean;
272
+ checked?: boolean | string;
242
273
  };
243
274
  export declare const LabelVariantList: readonly ["above", "floating"];
244
275
  export type LabelVariantType = (typeof LabelVariantList)[number];
@@ -276,7 +307,12 @@ export type FormMessageProps = {
276
307
  /**
277
308
  * Enables or disables the visibility of the message.
278
309
  */
279
- showMessage?: boolean;
310
+ showMessage?: boolean | string;
311
+ };
312
+ export type FromValidState = {
313
+ hasValidState: () => boolean;
314
+ handleValidation: () => void;
315
+ _invalidMessage?: string;
280
316
  };
281
317
  export type FormState = {
282
318
  _messageId?: string;
@@ -284,6 +320,7 @@ export type FormState = {
284
320
  _invalidMessageId?: string;
285
321
  _descByIds?: string;
286
322
  _value?: string;
323
+ _invalidMessage?: string;
287
324
  /**
288
325
  * https://www.davidmacd.com/blog/test-aria-describedby-errormessage-aria-live.html
289
326
  * Currently VoiceOver isn't supporting changes from aria-describedby.
@@ -308,7 +345,7 @@ export type LinkProps = {
308
345
  /**
309
346
  * Disables the link.
310
347
  */
311
- disabled?: boolean;
348
+ disabled?: boolean | string;
312
349
  /**
313
350
  * The [URL that the hyperlink points to](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href).
314
351
  */
@@ -340,7 +377,7 @@ export type LinkProps = {
340
377
  /**
341
378
  * Sets aria role based on [`aria-selected`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected).
342
379
  */
343
- selected?: boolean;
380
+ selected?: boolean | string;
344
381
  };
345
382
  export type TextProps = {
346
383
  /**
@@ -356,19 +393,24 @@ export type ClickEventProps<T> = {
356
393
  onClick?: (event: ClickEvent<T>) => void;
357
394
  };
358
395
  export type ClickEventState<T> = {
359
- handleClick: (event: ClickEvent<T>) => void;
396
+ handleClick: (event: ClickEvent<T> | any) => void;
360
397
  };
361
398
  export type ToggleEventProps = {
362
- onToggle?: (open: boolean) => void;
399
+ toggle?: (open: boolean | any) => void;
400
+ onToggle?: (open: boolean | any) => void;
363
401
  };
364
402
  export type ToggleEventState<T> = {
365
- toggle: (event?: ClickEvent<T>) => void;
403
+ handleToggle: (event?: ClickEvent<T> | any) => void;
366
404
  };
367
405
  export type CloseEventProps = {
368
406
  /**
369
407
  * Function to handle button click (close).
370
408
  */
371
409
  onClose?: (event?: any) => void;
410
+ /**
411
+ * Function to handle button click (close).
412
+ */
413
+ close?: (event?: any) => void;
372
414
  };
373
415
  export type CloseEventState = {
374
416
  handleClose: (event: any) => void;
@@ -385,7 +427,7 @@ export type ActiveProps = {
385
427
  /**
386
428
  * If the tab is checked/active.
387
429
  */
388
- active?: boolean;
430
+ active?: boolean | string;
389
431
  };
390
432
  export type InputEvent<T> = React.FormEvent<T>;
391
433
  export type InputEventProps<T> = {
@@ -393,7 +435,7 @@ export type InputEventProps<T> = {
393
435
  onInput?: (event: InputEvent<T>) => void;
394
436
  };
395
437
  export type InputEventState<T> = {
396
- handleInput: (event: InputEvent<T>) => void;
438
+ handleInput: (event: InputEvent<T> | any) => void;
397
439
  };
398
440
  export type ChangeEvent<T> = React.ChangeEvent<T>;
399
441
  export type ChangeEventProps<T> = {
@@ -401,7 +443,7 @@ export type ChangeEventProps<T> = {
401
443
  onChange?: (event: ChangeEvent<T>) => void;
402
444
  };
403
445
  export type ChangeEventState<T> = {
404
- handleChange: (event: ChangeEvent<T>) => void;
446
+ handleChange: (event: ChangeEvent<T> | any) => void;
405
447
  };
406
448
  export type InteractionEvent<T> = React.FocusEvent<T>;
407
449
  export type FocusEventProps<T> = {
@@ -411,8 +453,8 @@ export type FocusEventProps<T> = {
411
453
  onFocus?: (event: InteractionEvent<T>) => void;
412
454
  };
413
455
  export type FocusEventState<T> = {
414
- handleBlur: (event: InteractionEvent<T>) => void;
415
- handleFocus: (event: InteractionEvent<T>) => void;
456
+ handleBlur: (event: InteractionEvent<T> | any) => void;
457
+ handleFocus: (event: InteractionEvent<T> | any) => void;
416
458
  };
417
459
  export type InnerCloseButtonProps = {
418
460
  /**
@@ -1,7 +1,9 @@
1
1
  export const SemanticList = ['adaptive', 'neutral', 'critical', 'informational', 'warning', 'successful'];
2
2
  export const SpacingList = ['medium', 'small', 'large', 'none'];
3
3
  export const MarginList = ['medium', 'small', 'large', 'none'];
4
- export const PlacementList = ['left', 'right', 'top', 'bottom', 'left-start', 'left-end', 'right-start', 'right-end', 'top-start', 'top-end', 'bottom-start', 'bottom-end'];
4
+ export const PlacementHorizontalList = ['left', 'right', 'left-start', 'left-end', 'right-start', 'right-end'];
5
+ export const PlacementVerticalList = ['top', 'bottom', 'top-start', 'top-end', 'bottom-start', 'bottom-end'];
6
+ export const PlacementList = [...PlacementHorizontalList, ...PlacementVerticalList];
5
7
  export const GapSpacingList = ['none', '3x-large', '2x-large', 'x-large', 'large', 'medium', 'small', 'x-small', '2x-small', '3x-small'];
6
8
  export const OrientationList = ['horizontal', 'vertical'];
7
9
  export const WidthList = ['full', 'auto'];
@@ -10,7 +12,6 @@ export const PopoverDelayList = ['none', 'slow', 'fast'];
10
12
  export const PopoverWidthList = ['auto', 'fixed'];
11
13
  export const SizeList = ['small', 'medium'];
12
14
  export const EmphasisList = ['weak', 'strong'];
13
- export const TagEmphasisList = [...EmphasisList, 'origin'];
14
15
  export const ValidationList = ['invalid', 'valid', 'no-validation'];
15
16
  export const LabelVariantList = ['above', 'floating'];
16
17
  export const AutoCompleteList = ['off', 'on', 'name', 'honorific-prefix', 'given-name', 'additional-name', 'family-name', 'honorific-suffix', 'nickname', 'email', 'username', 'new-password', 'current-password', 'one-time-code', 'organization-title', 'organization', 'street-address', 'shipping', 'billing', 'address-line1', 'address-line2', 'address-line3', 'address-level4', 'address-level3', 'address-level2', 'address-level1', 'country', 'country-name', 'postal-code', 'cc-name', 'cc-given-name', 'cc-additional-name', 'cc-family-name', 'cc-number', 'cc-exp', 'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type', 'transaction-currency', 'transaction-amount', 'language', 'bday', 'bday-day', 'bday-month', 'bday-year', 'sex', 'tel', 'tel-country-code', 'tel-national', 'tel-area-code', 'tel-local', 'tel-extension', 'impp', 'url', 'photo', 'webauthn'];
@@ -0,0 +1,8 @@
1
+ export declare class DocumentClickListener {
2
+ private static callbacks;
3
+ private static _instance;
4
+ private static runCallbacks;
5
+ constructor();
6
+ addCallback(callback: (event: any) => void): string;
7
+ removeCallback(id: string): void;
8
+ }
@@ -0,0 +1,29 @@
1
+ import { uuid } from './index';
2
+ export class DocumentClickListener {
3
+ static runCallbacks(event) {
4
+ Object.values(DocumentClickListener.callbacks).forEach(callback => {
5
+ if (typeof callback === 'function') {
6
+ callback(event);
7
+ }
8
+ });
9
+ }
10
+ constructor() {
11
+ if (DocumentClickListener._instance) {
12
+ return DocumentClickListener._instance;
13
+ }
14
+ DocumentClickListener._instance = this;
15
+ if (document) {
16
+ document.addEventListener('click', event => DocumentClickListener.runCallbacks(event));
17
+ }
18
+ }
19
+ addCallback(callback) {
20
+ const callbackID = uuid();
21
+ DocumentClickListener.callbacks[callbackID] = callback;
22
+ return callbackID;
23
+ }
24
+ removeCallback(id) {
25
+ delete DocumentClickListener.callbacks[id];
26
+ }
27
+ }
28
+ DocumentClickListener.callbacks = {};
29
+ DocumentClickListener._instance = null;
@@ -28,30 +28,9 @@ export declare const delay: (fn: () => void, ms: number) => Promise<unknown>;
28
28
  * if it is used in a framework like angular e.g.: [disabled]="myDisabledProp"
29
29
  * @param originBool Some boolean to convert to string
30
30
  */
31
- export declare const getBooleanAsString: (originBool?: boolean) => any;
32
- export declare const getHideProp: (show?: boolean) => any;
33
- export declare const stringPropVisible: (givenString?: string, showString?: boolean) => string | boolean;
34
- declare const _default: {
35
- cls: (...args: ClassNameArg[]) => string;
36
- addAttributeToChildren: (element: Element, attribute: {
37
- key: string;
38
- value: string;
39
- }) => void;
40
- uuid: () => string;
41
- visibleInVX: (el: Element) => boolean;
42
- visibleInVY: (el: Element) => boolean;
43
- isInView: (el: Element) => {
44
- outTop: boolean;
45
- outBottom: boolean;
46
- outLeft: boolean;
47
- outRight: boolean;
48
- };
49
- handleDataOutside: (el: Element) => DBDataOutsidePair;
50
- isArrayOfStrings: (value: unknown) => value is string[];
51
- hasVoiceOver: () => boolean;
52
- delay: (fn: () => void, ms: number) => Promise<unknown>;
53
- getBooleanAsString: (originBool?: boolean) => any;
54
- getHideProp: (show?: boolean) => any;
55
- stringPropVisible: (givenString?: string, showString?: boolean) => string | boolean;
56
- };
57
- export default _default;
31
+ export declare const getBooleanAsString: (originBool?: boolean | string) => any;
32
+ export declare const getBoolean: (originBool?: boolean | string, propertyName?: string) => boolean | undefined;
33
+ export declare const getNumber: (originNumber?: number | string, alternativeNumber?: number | string) => number | undefined;
34
+ export declare const getHideProp: (show?: boolean | string) => any;
35
+ export declare const stringPropVisible: (givenString?: string, showString?: boolean | string) => boolean;
36
+ export declare const getSearchInput: (element: HTMLElement) => HTMLInputElement | null;