idea-react 3.0.0-beta.0 → 3.0.0-beta.1

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 (107) hide show
  1. package/AGENTS.md +11 -2
  2. package/ReadMe.md +62 -49
  3. package/dist/DatePickerPlugin-CpGuQRsi.js +1 -0
  4. package/dist/DatePickerPlugin-DB3nnslN.mjs +1 -0
  5. package/dist/index.d.mts +1116 -442
  6. package/dist/index.d.ts +1116 -442
  7. package/dist/index.js +16 -16
  8. package/dist/index.mjs +15 -15
  9. package/dist/rolldown-runtime-5iZMYShA.js +1 -0
  10. package/dist/style.css +69 -66
  11. package/package.json +1 -1
  12. package/source/Accordion.tsx +137 -0
  13. package/source/Alert.tsx +138 -0
  14. package/source/Avatar.tsx +7 -1
  15. package/source/Badge.tsx +2 -0
  16. package/source/Breadcrumb.tsx +36 -0
  17. package/source/Button.tsx +40 -5
  18. package/source/ButtonGroup.tsx +10 -1
  19. package/source/Card.tsx +65 -4
  20. package/source/Carousel/index.tsx +391 -0
  21. package/source/Carousel/model.ts +113 -0
  22. package/source/Carousel/scroll.ts +79 -0
  23. package/source/Collapse.tsx +178 -0
  24. package/source/Drawer.tsx +127 -30
  25. package/source/{CodeBlock.tsx → Extension/CodeBlock/index.tsx} +23 -5
  26. package/source/Extension/CodeBlock/style.module.css +3 -0
  27. package/source/{Dialog.tsx → Extension/Dialog.tsx} +10 -6
  28. package/source/{EditorHTML.tsx → Extension/EditorHTML.tsx} +1 -1
  29. package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.module.less +1 -3
  30. package/source/{Icon.tsx → Extension/Icon.tsx} +1 -7
  31. package/source/{Loading.tsx → Extension/Loading.tsx} +8 -3
  32. package/source/{MonthCalendar.tsx → Extension/MonthCalendar.tsx} +3 -3
  33. package/source/{Nameplate.tsx → Extension/Nameplate.tsx} +1 -1
  34. package/source/Extension/OverlayBox.tsx +280 -0
  35. package/source/{PageNav.tsx → Extension/PageNav.tsx} +27 -9
  36. package/source/{ScrollNav → Extension/ScrollNav}/index.tsx +1 -1
  37. package/source/Extension/Select.tsx +127 -0
  38. package/source/{ShareBox.tsx → Extension/ShareBox.tsx} +1 -1
  39. package/source/{SpinnerButton.tsx → Extension/SpinnerButton.tsx} +2 -2
  40. package/source/{TableSpinner.tsx → Extension/TableSpinner.tsx} +1 -1
  41. package/source/{Timeline → Extension/Timeline}/index.tsx +1 -1
  42. package/source/{UserRank → Extension/UserRank}/index.tsx +4 -4
  43. package/source/Extension/index.ts +27 -0
  44. package/source/Form/Adorn.tsx +32 -11
  45. package/source/Form/Checkbox.tsx +11 -6
  46. package/source/Form/ChipInput.tsx +125 -0
  47. package/source/Form/Chips.tsx +42 -24
  48. package/source/Form/Combobox.tsx +337 -72
  49. package/source/Form/Control.tsx +50 -15
  50. package/source/Form/DatePicker.tsx +231 -40
  51. package/source/Form/DatePickerPlugin.ts +37 -0
  52. package/source/Form/Feedback.tsx +10 -4
  53. package/source/Form/FloatingLabel.tsx +24 -7
  54. package/source/Form/InputGroup.tsx +155 -5
  55. package/source/Form/OTP.tsx +138 -45
  56. package/source/Form/PasswordStrength.tsx +43 -17
  57. package/source/Form/Plugin.tsx +53 -0
  58. package/source/Form/Primitives.tsx +51 -9
  59. package/source/Form/Radio.tsx +20 -28
  60. package/source/Form/Range.tsx +103 -52
  61. package/source/Form/Switch.tsx +30 -7
  62. package/source/Form/index.ts +1 -0
  63. package/source/Grid.tsx +4 -0
  64. package/source/ListGroup.tsx +28 -15
  65. package/source/Menu.tsx +226 -17
  66. package/source/NativeDialog/index.tsx +109 -5
  67. package/source/Nav.tsx +18 -2
  68. package/source/NavOverflow/index.tsx +307 -0
  69. package/source/NavOverflow/model.ts +21 -0
  70. package/source/Navbar.tsx +18 -3
  71. package/source/Overlay.ts +163 -1
  72. package/source/Pagination.tsx +92 -0
  73. package/source/Placeholder.tsx +66 -0
  74. package/source/Popover.tsx +7 -2
  75. package/source/Progress/index.tsx +76 -0
  76. package/source/Progress/style.module.css +15 -0
  77. package/source/ScrollSpy/index.tsx +365 -0
  78. package/source/ScrollSpy/model.ts +17 -0
  79. package/source/Spinner.tsx +10 -0
  80. package/source/Stepper.tsx +85 -0
  81. package/source/Tab.tsx +248 -0
  82. package/source/Toast.tsx +46 -14
  83. package/source/ToggleButton.tsx +21 -7
  84. package/source/Toggler.tsx +108 -0
  85. package/source/Tooltip.tsx +6 -1
  86. package/source/index.ts +15 -27
  87. package/source/OverlayBox.tsx +0 -208
  88. package/source/Select.tsx +0 -95
  89. /package/source/{ClickBoundary.tsx → Extension/ClickBoundary.tsx} +0 -0
  90. /package/source/{Countdown.tsx → Extension/Countdown.tsx} +0 -0
  91. /package/source/{Editor.tsx → Extension/Editor.tsx} +0 -0
  92. /package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.tsx +0 -0
  93. /package/source/{LiveTSX.tsx → Extension/LiveTSX.tsx} +0 -0
  94. /package/source/{ScrollNav → Extension/ScrollNav}/Scroller.tsx +0 -0
  95. /package/source/{ScrollNav → Extension/ScrollNav}/index.module.less +0 -0
  96. /package/source/{TextTruncate → Extension/TextTruncate}/Content.tsx +0 -0
  97. /package/source/{TextTruncate → Extension/TextTruncate}/index.tsx +0 -0
  98. /package/source/{Time.tsx → Extension/Time.tsx} +0 -0
  99. /package/source/{TimeDistance.tsx → Extension/TimeDistance.tsx} +0 -0
  100. /package/source/{Timeline → Extension/Timeline}/index.module.less +0 -0
  101. /package/source/{TypeEcho → Extension/TypeEcho}/Content.tsx +0 -0
  102. /package/source/{TypeEcho → Extension/TypeEcho}/index.tsx +0 -0
  103. /package/source/{UserRank → Extension/UserRank}/Address.tsx +0 -0
  104. /package/source/{UserRank → Extension/UserRank}/index.module.less +0 -0
  105. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.module.less +0 -0
  106. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.tsx +0 -0
  107. /package/source/{ZodiacBar.tsx → Extension/ZodiacBar.tsx} +0 -0
package/source/Tab.tsx ADDED
@@ -0,0 +1,248 @@
1
+ 'use client';
2
+
3
+ import classNames from 'classnames';
4
+ import { action, observable } from 'mobx';
5
+ import { observer } from 'mobx-react';
6
+ import {
7
+ Children,
8
+ cloneElement,
9
+ Component,
10
+ ComponentPropsWithRef,
11
+ createRef,
12
+ FC,
13
+ isValidElement,
14
+ KeyboardEvent,
15
+ MouseEvent,
16
+ ReactNode
17
+ } from 'react';
18
+
19
+ export interface TabProps extends ComponentPropsWithRef<'div'> {
20
+ eventKey: string;
21
+ label: ReactNode;
22
+ disabled?: boolean;
23
+ }
24
+
25
+ export const Tab: FC<TabProps> = ({
26
+ eventKey: _eventKey,
27
+ label: _label,
28
+ disabled: _disabled,
29
+ ...props
30
+ }) => <div {...props} />;
31
+
32
+ Tab.displayName = 'Tab';
33
+
34
+ export interface TabsProps extends Omit<ComponentPropsWithRef<'div'>, 'onChange'> {
35
+ activeKey?: string;
36
+ defaultActiveKey?: string;
37
+ fade?: boolean;
38
+ id: string;
39
+ onChange?: (key: string) => unknown;
40
+ orientation?: 'horizontal' | 'vertical';
41
+ variant?: 'tabs' | 'pills' | 'underline' | 'list-group';
42
+ }
43
+
44
+ @observer
45
+ export class Tabs extends Component<TabsProps> {
46
+ static displayName = 'Tabs';
47
+
48
+ get tabs() {
49
+ return Children.toArray(this.props.children)
50
+ .filter(child => typeof child !== 'string' || child.trim())
51
+ .map(child => {
52
+ // Server component boundaries may wrap Tab in a lazy client reference.
53
+ if (
54
+ !isValidElement<TabProps>(child) ||
55
+ typeof child.props.eventKey !== 'string' ||
56
+ !('label' in child.props)
57
+ )
58
+ throw new TypeError('Tabs children must be Tab elements.');
59
+
60
+ return child;
61
+ });
62
+ }
63
+
64
+ root = createRef<HTMLDivElement>();
65
+
66
+ @observable accessor selectedKey =
67
+ this.props.defaultActiveKey ??
68
+ this.tabs.find(({ props }) => !props.disabled)?.props.eventKey ??
69
+ this.tabs[0]?.props.eventKey ??
70
+ '';
71
+
72
+ get activeKey() {
73
+ const key = this.props.activeKey ?? this.selectedKey;
74
+
75
+ return this.tabs.some(({ props }) => props.eventKey === key && !props.disabled)
76
+ ? key
77
+ : (this.tabs.find(({ props }) => !props.disabled)?.props.eventKey ?? '');
78
+ }
79
+
80
+ handleClick = (event: MouseEvent<HTMLDivElement>) => {
81
+ this.props.onClick?.(event);
82
+ if (event.defaultPrevented) return;
83
+
84
+ const button = (event.target as Element).closest<HTMLButtonElement>('[data-tab-index]');
85
+ const tab = button && this.tabs[Number(button.dataset.tabIndex)]?.props;
86
+ if (!tab || tab.disabled) return;
87
+
88
+ this.activate(tab.eventKey);
89
+ };
90
+
91
+ handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
92
+ this.props.onKeyDown?.(event);
93
+
94
+ if (event.defaultPrevented) return;
95
+
96
+ const button = (event.target as Element).closest<HTMLButtonElement>('[data-tab-index]');
97
+ const index = Number(button?.dataset.tabIndex);
98
+ const tabs = this.tabs;
99
+ if (!button || Number.isNaN(index)) return;
100
+
101
+ const horizontal = this.props.orientation !== 'vertical';
102
+ const previous = horizontal ? event.key === 'ArrowLeft' : event.key === 'ArrowUp';
103
+ const next = horizontal ? event.key === 'ArrowRight' : event.key === 'ArrowDown';
104
+ const enabled = tabs
105
+ .map(({ props }, tabIndex) => (props.disabled ? -1 : tabIndex))
106
+ .filter(tabIndex => tabIndex >= 0);
107
+ const currentPosition = enabled.indexOf(index);
108
+ const destination =
109
+ event.key === 'Home'
110
+ ? enabled[0]
111
+ : event.key === 'End'
112
+ ? enabled.at(-1)
113
+ : previous
114
+ ? enabled[(currentPosition - 1 + enabled.length) % enabled.length]
115
+ : next
116
+ ? enabled[(currentPosition + 1) % enabled.length]
117
+ : undefined;
118
+ if (destination === undefined) return;
119
+
120
+ event.preventDefault();
121
+ const tab = tabs[destination];
122
+
123
+ this.activate(tab.props.eventKey);
124
+ this.root.current
125
+ ?.querySelector<HTMLButtonElement>(`[data-tab-index="${destination}"]`)
126
+ ?.focus();
127
+ };
128
+
129
+ @action
130
+ activate = (key: string) => {
131
+ this.props.onChange?.(key);
132
+
133
+ if (this.props.activeKey === undefined) this.selectedKey = key;
134
+ };
135
+
136
+ tabId = (key: string) => `${this.props.id}-tab-${encodeURIComponent(key)}`;
137
+
138
+ panelId = (key: string) => `${this.props.id}-panel-${encodeURIComponent(key)}`;
139
+
140
+ renderTabs = () => {
141
+ const { orientation = 'horizontal', variant = 'tabs' } = this.props;
142
+ const listGroup = variant === 'list-group';
143
+
144
+ return (
145
+ <div
146
+ className={classNames(
147
+ listGroup ? 'list-group' : 'nav',
148
+ !listGroup && `nav-${variant}`,
149
+ orientation === 'vertical' &&
150
+ (listGroup
151
+ ? 'flex-column'
152
+ : variant === 'pills'
153
+ ? 'nav-pills-vertical'
154
+ : 'flex-column')
155
+ )}
156
+ role="tablist"
157
+ aria-label={this.props['aria-label'] ?? 'Tabs'}
158
+ aria-orientation={orientation}
159
+ >
160
+ {this.tabs.map(({ props: tab }, index) => {
161
+ const active = tab.eventKey === this.activeKey;
162
+
163
+ return (
164
+ <button
165
+ key={tab.eventKey}
166
+ id={this.tabId(tab.eventKey)}
167
+ type="button"
168
+ role="tab"
169
+ data-tab-index={index}
170
+ aria-controls={this.panelId(tab.eventKey)}
171
+ aria-selected={active}
172
+ aria-disabled={tab.disabled || undefined}
173
+ tabIndex={active ? 0 : -1}
174
+ disabled={tab.disabled}
175
+ className={classNames(
176
+ listGroup ? 'list-group-item list-group-item-action' : 'nav-link',
177
+ { active },
178
+ tab.disabled && 'disabled'
179
+ )}
180
+ >
181
+ {tab.label}
182
+ </button>
183
+ );
184
+ })}
185
+ </div>
186
+ );
187
+ };
188
+
189
+ renderPanels = () => {
190
+ const { fade = true } = this.props;
191
+
192
+ return (
193
+ <div className="tab-content">
194
+ {this.tabs.map(tab => {
195
+ const { eventKey, className } = tab.props;
196
+ const active = eventKey === this.activeKey;
197
+
198
+ return cloneElement(tab, {
199
+ key: eventKey,
200
+ id: this.panelId(eventKey),
201
+ role: 'tabpanel',
202
+ 'aria-labelledby': this.tabId(eventKey),
203
+ 'aria-hidden': !active,
204
+ tabIndex: tab.props.tabIndex ?? 0,
205
+ className: classNames(
206
+ 'tab-pane',
207
+ { active, show: active && fade },
208
+ !fade && 'tab-pane-instant',
209
+ className
210
+ ),
211
+ hidden: !active
212
+ });
213
+ })}
214
+ </div>
215
+ );
216
+ };
217
+
218
+ render() {
219
+ const {
220
+ activeKey: _activeKey,
221
+ className,
222
+ defaultActiveKey: _defaultActiveKey,
223
+ fade: _fade,
224
+ onChange: _onChange,
225
+ onClick: _onClick,
226
+ onKeyDown: _onKeyDown,
227
+ id: _id,
228
+ orientation: _orientation,
229
+ children: _children,
230
+ variant: _variant,
231
+ ...props
232
+ } = this.props;
233
+
234
+ return (
235
+ <div
236
+ {...props}
237
+ ref={this.root}
238
+ id={this.props.id}
239
+ className={className}
240
+ onClick={this.handleClick}
241
+ onKeyDown={this.handleKeyDown}
242
+ >
243
+ {this.renderTabs()}
244
+ {this.renderPanels()}
245
+ </div>
246
+ );
247
+ }
248
+ }
package/source/Toast.tsx CHANGED
@@ -7,6 +7,7 @@ import { ComponentPropsWithRef, FC, MouseEvent, ReactNode } from 'react';
7
7
  import { Timestamp, uniqueID } from 'web-utility';
8
8
 
9
9
  import type { ComponentTheme } from './Button';
10
+ import { CloseButton } from './CloseButton';
10
11
 
11
12
  export type ToastPosition =
12
13
  | 'top-start'
@@ -31,11 +32,13 @@ const TOAST_POSITION_CLASSES: Record<ToastPosition, string> = {
31
32
  'bottom-end': 'bottom-0 end-0'
32
33
  };
33
34
 
34
- export interface ToastMessage {
35
+ export interface ToastMessage extends Pick<
36
+ ToastItemProps,
37
+ 'theme' | 'translucent' | 'instant' | 'role'
38
+ > {
35
39
  id?: string;
36
40
  title?: ReactNode;
37
41
  body: ReactNode;
38
- theme?: ComponentTheme;
39
42
  delay?: number;
40
43
  }
41
44
 
@@ -77,12 +80,28 @@ export const ToastContainer: FC<ToastContainerProps> = ({
77
80
 
78
81
  export interface ToastItemProps extends ComponentPropsWithRef<'div'> {
79
82
  theme?: ComponentTheme;
83
+ show?: boolean;
84
+ translucent?: boolean;
85
+ instant?: boolean;
80
86
  }
81
87
 
82
- export const ToastItem: FC<ToastItemProps> = ({ theme, role = 'status', className, ...props }) => (
88
+ export const ToastItem: FC<ToastItemProps> = ({
89
+ theme,
90
+ show = true,
91
+ translucent,
92
+ instant,
93
+ role = 'status',
94
+ className,
95
+ ...props
96
+ }) => (
83
97
  <div
84
98
  {...props}
85
- className={classNames('toast show', theme && `theme-${theme}`, className)}
99
+ className={classNames(
100
+ 'toast',
101
+ { show, 'toast-translucent': translucent, 'toast-instant': instant },
102
+ theme && `theme-${theme}`,
103
+ className
104
+ )}
86
105
  role={role}
87
106
  />
88
107
  );
@@ -105,22 +124,33 @@ export class Toast {
105
124
  </ToastContainer>
106
125
  ));
107
126
 
108
- renderMessage = ({ id, openedAt, title, body, theme, delay = 3000 }: ToastEntry) => {
127
+ renderMessage = ({
128
+ id,
129
+ openedAt,
130
+ title,
131
+ body,
132
+ theme,
133
+ translucent,
134
+ instant,
135
+ role,
136
+ delay = 3000
137
+ }: ToastEntry) => {
109
138
  const showHeader = !!title || delay === 0;
110
139
  const elapsed = this.TimeScalar.distanceOf<Timestamp>(Date.now(), openedAt).toShortString();
111
140
 
112
141
  return (
113
- <ToastItem key={id} theme={theme}>
142
+ <ToastItem
143
+ key={id}
144
+ theme={theme}
145
+ translucent={translucent}
146
+ instant={instant}
147
+ role={role}
148
+ >
114
149
  {showHeader && (
115
150
  <ToastHeader>
116
151
  <strong className="me-auto">{title}</strong>
117
152
  <small>{elapsed}</small>
118
- <button
119
- type="button"
120
- className="btn-close"
121
- aria-label="Close"
122
- data-toast-dismiss={id}
123
- />
153
+ <CloseButton data-toast-dismiss={id} />
124
154
  </ToastHeader>
125
155
  )}
126
156
  <ToastBody>{body}</ToastBody>
@@ -141,7 +171,9 @@ export class Toast {
141
171
 
142
172
  @action
143
173
  open(message: ToastMessage) {
144
- const id = uniqueID();
174
+ const id = message.id ?? uniqueID();
175
+ this.close(id);
176
+
145
177
  const openedAt = Date.now();
146
178
  const { promise, resolve } = Promise.withResolvers<ToastEntry>();
147
179
  const timer =
@@ -149,7 +181,7 @@ export class Toast {
149
181
  ? undefined
150
182
  : setTimeout(() => this.close(id), message.delay ?? 3000);
151
183
 
152
- const item: ToastEntry = { id, ...message, openedAt, resolve, timer };
184
+ const item: ToastEntry = { ...message, id, openedAt, resolve, timer };
153
185
 
154
186
  this.messages = [...this.messages, item];
155
187
 
@@ -12,6 +12,13 @@ export interface ToggleButtonProps extends Omit<ComponentPropsWithRef<'label'>,
12
12
  checked?: boolean;
13
13
  defaultChecked?: boolean;
14
14
  disabled?: boolean;
15
+ required?: boolean;
16
+ size?: 'xs' | 'sm' | 'lg';
17
+ inputProps?: Omit<
18
+ ComponentPropsWithRef<'input'>,
19
+ 'type' | 'name' | 'value' | 'checked' | 'defaultChecked' | 'disabled' | 'required'
20
+ >;
21
+ onChange?: ComponentPropsWithRef<'input'>['onChange'];
15
22
  }
16
23
 
17
24
  export const ToggleButton: FC<ToggleButtonProps> = ({
@@ -23,22 +30,29 @@ export const ToggleButton: FC<ToggleButtonProps> = ({
23
30
  checked,
24
31
  defaultChecked,
25
32
  disabled,
33
+ required,
34
+ size,
35
+ inputProps,
36
+ onChange,
26
37
  className,
27
38
  children,
28
39
  ...props
29
40
  }) => (
30
41
  <label
31
42
  {...props}
32
- className={classNames('btn-check', `btn-${variant}`, theme && `theme-${theme}`, className)}
43
+ className={classNames(
44
+ 'btn-check',
45
+ `btn-${variant}`,
46
+ theme && `theme-${theme}`,
47
+ size && `btn-${size}`,
48
+ className
49
+ )}
33
50
  >
34
51
  <input
35
- type={type}
36
- name={name}
37
- value={value}
38
- checked={checked}
39
- defaultChecked={defaultChecked}
40
- disabled={disabled}
52
+ {...inputProps}
53
+ {...{ type, name, value, checked, defaultChecked, disabled, required }}
41
54
  autoComplete="off"
55
+ onChange={onChange}
42
56
  />
43
57
  {children}
44
58
  </label>
@@ -0,0 +1,108 @@
1
+ 'use client';
2
+
3
+ import classNames from 'classnames';
4
+ import { ButtonHTMLAttributes, Component, KeyboardEvent, MouseEvent } from 'react';
5
+
6
+ import { Button, ComponentTheme } from './Button';
7
+
8
+ export interface TogglerProps extends Omit<ButtonHTMLAttributes<HTMLElement>, 'value'> {
9
+ as?: 'button' | 'div' | 'span';
10
+ target?: string;
11
+ attribute?: string;
12
+ value?: string | number | boolean | null;
13
+ theme?: ComponentTheme;
14
+ variant?: 'solid' | 'outline' | 'subtle' | 'text' | 'link';
15
+ onToggled?: (targets: HTMLElement[]) => unknown;
16
+ }
17
+
18
+ export class Toggler extends Component<TogglerProps> {
19
+ static displayName = 'Toggler';
20
+
21
+ handleClick = (event: MouseEvent<HTMLElement>) => {
22
+ this.props.onClick?.(event);
23
+
24
+ if (event.defaultPrevented || this.props.disabled) return;
25
+
26
+ const { target, attribute = 'class', value, onToggled } = this.props;
27
+ const targets = target
28
+ ? [...document.querySelectorAll<HTMLElement>(target)]
29
+ : [event.currentTarget];
30
+ const changes = targets.map(element => ({
31
+ element,
32
+ attribute: element.dataset.bsAttribute ?? attribute,
33
+ value: element.dataset.bsValue ?? value
34
+ }));
35
+
36
+ if (changes.some(({ attribute }) => attribute.toLowerCase() === 'id'))
37
+ throw new TypeError('Toggler cannot change the id attribute');
38
+
39
+ for (const { element, attribute, value } of changes) {
40
+ if (value == null) continue;
41
+
42
+ const text = String(value);
43
+ const before = new window.CustomEvent('toggle.bs.toggler', { cancelable: true });
44
+
45
+ if (!element.dispatchEvent(before)) continue;
46
+
47
+ if (attribute === 'class') {
48
+ for (const name of text.split(/\s+/).filter(Boolean))
49
+ element.classList.toggle(name);
50
+ } else if (element.getAttribute(attribute) === text) element.removeAttribute(attribute);
51
+ else element.setAttribute(attribute, text);
52
+
53
+ element.dispatchEvent(new window.CustomEvent('toggled.bs.toggler'));
54
+ }
55
+ onToggled?.(targets);
56
+ };
57
+
58
+ handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {
59
+ this.props.onKeyDown?.(event);
60
+
61
+ if (
62
+ !event.defaultPrevented &&
63
+ !this.props.disabled &&
64
+ (event.key === 'Enter' || event.key === ' ')
65
+ ) {
66
+ event.preventDefault();
67
+ event.currentTarget.click();
68
+ }
69
+ };
70
+
71
+ render() {
72
+ const {
73
+ as: Tag = 'button',
74
+ target: _target,
75
+ attribute: _attribute,
76
+ value: _value,
77
+ onToggled: _onToggled,
78
+ theme,
79
+ variant,
80
+ disabled,
81
+ ...props
82
+ } = this.props;
83
+
84
+ return Tag === 'button' ? (
85
+ <Button
86
+ {...props}
87
+ theme={theme}
88
+ variant={variant}
89
+ disabled={disabled}
90
+ onClick={this.handleClick}
91
+ />
92
+ ) : (
93
+ <Tag
94
+ {...props}
95
+ className={classNames(
96
+ theme && `theme-${theme}`,
97
+ variant && `btn-${variant}`,
98
+ props.className
99
+ )}
100
+ role={props.role ?? 'button'}
101
+ tabIndex={disabled ? -1 : (props.tabIndex ?? 0)}
102
+ aria-disabled={disabled || undefined}
103
+ onClick={this.handleClick}
104
+ onKeyDown={this.handleKeyDown}
105
+ />
106
+ );
107
+ }
108
+ }
@@ -11,6 +11,7 @@ export const Tooltip: FC<TooltipProps> = ({
11
11
  role = 'tooltip',
12
12
  className,
13
13
  children,
14
+ arrowStyle,
14
15
  ...props
15
16
  }) => (
16
17
  <div
@@ -22,9 +23,13 @@ export const Tooltip: FC<TooltipProps> = ({
22
23
  className
23
24
  )}
24
25
  role={role}
26
+ hidden={!show}
25
27
  data-bs-placement={placement}
26
28
  >
27
- <div className={classNames('tooltip-arrow', OVERLAY_ARROW_POSITIONS[placement])} />
29
+ <div
30
+ style={arrowStyle}
31
+ className={classNames('tooltip-arrow', OVERLAY_ARROW_POSITIONS[placement])}
32
+ />
28
33
  <div className="tooltip-inner">{children}</div>
29
34
  </div>
30
35
  );
package/source/index.ts CHANGED
@@ -1,50 +1,38 @@
1
+ export * from './Accordion';
2
+ export * from './Alert';
1
3
  export * from './animate';
2
4
  export * from './Avatar';
3
5
  export * from './Badge';
6
+ export * from './Breadcrumb';
4
7
  export * from './Button';
5
8
  export * from './ButtonGroup';
6
9
  export * from './Card';
7
- export * from './ClickBoundary';
10
+ export * from './Carousel';
8
11
  export * from './CloseButton';
9
- export * from './CodeBlock';
12
+ export * from './Collapse';
10
13
  export * from './color';
11
- export * from './Countdown';
12
- export * from './Dialog';
13
14
  export * from './Drawer';
14
- export * from './Editor';
15
- export * from './EditorHTML';
15
+ export * from './Extension';
16
16
  export * from './Form';
17
17
  export * from './Grid';
18
- export * from './HorizontalMarquee';
19
- export * from './Icon';
20
18
  export * from './Image';
21
19
  export * from './ListGroup';
22
- export * from './LiveTSX';
23
- export * from './Loading';
24
20
  export * from './Menu';
25
- export * from './MonthCalendar';
26
- export * from './Nameplate';
27
21
  export * from './NativeDialog';
28
22
  export * from './Nav';
29
23
  export * from './Navbar';
30
- export * from './OverlayBox';
31
- export * from './PageNav';
24
+ export * from './NavOverflow';
25
+ export * from './Overlay';
26
+ export * from './Pagination';
27
+ export * from './Placeholder';
32
28
  export * from './Popover';
33
- export * from './ScrollNav';
34
- export * from './Select';
35
- export * from './ShareBox';
29
+ export * from './Progress';
30
+ export * from './ScrollSpy';
36
31
  export * from './Spinner';
37
- export * from './SpinnerButton';
32
+ export * from './Stepper';
33
+ export * from './Tab';
38
34
  export * from './Table';
39
- export * from './TableSpinner';
40
- export * from './TextTruncate';
41
- export * from './Time';
42
- export * from './TimeDistance';
43
- export * from './Timeline';
44
35
  export * from './Toast';
45
36
  export * from './ToggleButton';
37
+ export * from './Toggler';
46
38
  export * from './Tooltip';
47
- export * from './TypeEcho';
48
- export * from './UserRank';
49
- export * from './VerticalMarquee';
50
- export * from './ZodiacBar';