@doist/reactist 10.0.0-beta.7 → 11.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.
- package/dist/reactist.cjs.development.js +253 -411
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/_virtual/_rollupPluginBabelHelpers.js +34 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/es/components/deprecated-button/deprecated-button.js +2 -1
- package/es/components/deprecated-button/deprecated-button.js.map +1 -1
- package/es/components/deprecated-modal/deprecated-modal.js +1 -1
- package/es/components/deprecated-modal/deprecated-modal.js.map +1 -1
- package/es/components/dropdown/dropdown.js +3 -1
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/key-capturer/key-capturer.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +2 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/menu/menu.js +32 -12
- package/es/components/menu/menu.js.map +1 -1
- package/es/components/notification/notification.js +8 -3
- package/es/components/notification/notification.js.map +1 -1
- package/es/components/popover/popover.js.map +1 -1
- package/es/components/popover/positioning-utils.js.map +1 -1
- package/es/components/progress-bar/progress-bar.js +8 -2
- package/es/components/progress-bar/progress-bar.js.map +1 -1
- package/es/components/select/select.js +3 -1
- package/es/components/select/select.js.map +1 -1
- package/es/components/time/time-utils.js.map +1 -1
- package/es/components/time/time.js.map +1 -1
- package/es/components/tooltip/tooltip.js +3 -1
- package/es/components/tooltip/tooltip.js.map +1 -1
- package/es/index.js +0 -4
- package/es/index.js.map +1 -1
- package/es/new-components/base-button/base-button.js +3 -1
- package/es/new-components/base-button/base-button.js.map +1 -1
- package/es/new-components/base-button/base-button.module.css.js +1 -1
- package/es/new-components/box/box.js +5 -3
- package/es/new-components/box/box.js.map +1 -1
- package/es/new-components/box/box.module.css.js +1 -1
- package/es/new-components/box/width.module.css.js +4 -0
- package/es/new-components/box/width.module.css.js.map +1 -0
- package/es/new-components/button/button.js +2 -1
- package/es/new-components/button/button.js.map +1 -1
- package/es/new-components/button-link/button-link.js +2 -1
- package/es/new-components/button-link/button-link.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +27 -10
- package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.module.css.js +1 -1
- package/es/new-components/checkbox-field/checkbox-icon.js +2 -1
- package/es/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/es/new-components/columns/columns.js +4 -2
- package/es/new-components/columns/columns.js.map +1 -1
- package/es/new-components/divider/divider.js +5 -3
- package/es/new-components/divider/divider.js.map +1 -1
- package/es/new-components/divider/divider.module.css.js +1 -1
- package/es/new-components/heading/heading.js +2 -1
- package/es/new-components/heading/heading.js.map +1 -1
- package/es/new-components/hidden/hidden.js +2 -1
- package/es/new-components/hidden/hidden.js.map +1 -1
- package/es/new-components/icons/alert-icon.js +2 -1
- package/es/new-components/icons/alert-icon.js.map +1 -1
- package/es/new-components/inline/inline.js +2 -1
- package/es/new-components/inline/inline.js.map +1 -1
- package/es/new-components/loading/loading.js +6 -2
- package/es/new-components/loading/loading.js.map +1 -1
- package/es/new-components/modal/modal.js +32 -9
- package/es/new-components/modal/modal.js.map +1 -1
- package/es/new-components/modal/modal.module.css.js +1 -1
- package/es/new-components/password-field/password-field.js +2 -1
- package/es/new-components/password-field/password-field.js.map +1 -1
- package/es/new-components/select-field/select-field.js +2 -1
- package/es/new-components/select-field/select-field.js.map +1 -1
- package/es/new-components/select-field/select-field.module.css.js +1 -1
- package/es/new-components/stack/stack.js +5 -4
- package/es/new-components/stack/stack.js.map +1 -1
- package/es/new-components/switch-field/switch-field.js +28 -5
- package/es/new-components/switch-field/switch-field.js.map +1 -1
- package/es/new-components/switch-field/switch-field.module.css.js +1 -1
- package/es/new-components/tabs/tabs.js +10 -5
- package/es/new-components/tabs/tabs.js.map +1 -1
- package/es/new-components/tabs/tabs.module.css.js +1 -1
- package/es/new-components/text/text.js +2 -1
- package/es/new-components/text/text.js.map +1 -1
- package/es/new-components/text-area/text-area.js +3 -1
- package/es/new-components/text-area/text-area.js.map +1 -1
- package/es/new-components/text-area/text-area.module.css.js +1 -1
- package/es/new-components/text-field/text-field.js +2 -1
- package/es/new-components/text-field/text-field.js.map +1 -1
- package/es/new-components/text-field/text-field.module.css.js +1 -1
- package/es/new-components/text-link/text-link.js +2 -1
- package/es/new-components/text-link/text-link.js.map +1 -1
- package/lib/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/lib/components/deprecated-button/deprecated-button.js +1 -1
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.js +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.js.map +1 -1
- package/lib/components/dropdown/dropdown.js +1 -1
- package/lib/components/dropdown/dropdown.js.map +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/lib/components/menu/menu.js +1 -1
- package/lib/components/menu/menu.js.map +1 -1
- package/lib/components/notification/notification.d.ts +4 -2
- package/lib/components/notification/notification.js +1 -1
- package/lib/components/notification/notification.js.map +1 -1
- package/lib/components/progress-bar/progress-bar.d.ts +3 -1
- package/lib/components/progress-bar/progress-bar.js +1 -1
- package/lib/components/progress-bar/progress-bar.js.map +1 -1
- package/lib/components/select/select.js +1 -1
- package/lib/components/select/select.js.map +1 -1
- package/lib/components/tooltip/tooltip.js +1 -1
- package/lib/components/tooltip/tooltip.js.map +1 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +1 -1
- package/lib/new-components/base-button/base-button.js +1 -1
- package/lib/new-components/base-button/base-button.js.map +1 -1
- package/lib/new-components/base-button/base-button.module.css.js +1 -1
- package/lib/new-components/box/box.d.ts +10 -9
- package/lib/new-components/box/box.js +1 -1
- package/lib/new-components/box/box.js.map +1 -1
- package/lib/new-components/box/box.module.css.js +1 -1
- package/lib/new-components/box/width.module.css.js +2 -0
- package/lib/new-components/box/width.module.css.js.map +1 -0
- package/lib/new-components/button/button.js +1 -1
- package/lib/new-components/button/button.js.map +1 -1
- package/lib/new-components/button-link/button-link.js +1 -1
- package/lib/new-components/button-link/button-link.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.d.ts +15 -2
- package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.module.css.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/lib/new-components/columns/columns.js +1 -1
- package/lib/new-components/columns/columns.js.map +1 -1
- package/lib/new-components/common-types.d.ts +1 -0
- package/lib/new-components/divider/divider.d.ts +2 -2
- package/lib/new-components/divider/divider.js +1 -1
- package/lib/new-components/divider/divider.js.map +1 -1
- package/lib/new-components/divider/divider.module.css.js +1 -1
- package/lib/new-components/heading/heading.js +1 -1
- package/lib/new-components/heading/heading.js.map +1 -1
- package/lib/new-components/hidden/hidden.js +1 -1
- package/lib/new-components/hidden/hidden.js.map +1 -1
- package/lib/new-components/icons/alert-icon.js +1 -1
- package/lib/new-components/icons/alert-icon.js.map +1 -1
- package/lib/new-components/inline/inline.js +1 -1
- package/lib/new-components/inline/inline.js.map +1 -1
- package/lib/new-components/loading/loading.d.ts +8 -7
- package/lib/new-components/loading/loading.js +1 -1
- package/lib/new-components/loading/loading.js.map +1 -1
- package/lib/new-components/modal/modal.d.ts +7 -3
- package/lib/new-components/modal/modal.js +1 -1
- package/lib/new-components/modal/modal.js.map +1 -1
- package/lib/new-components/modal/modal.module.css.js +1 -1
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/password-field/password-field.js.map +1 -1
- package/lib/new-components/select-field/select-field.js +1 -1
- package/lib/new-components/select-field/select-field.js.map +1 -1
- package/lib/new-components/select-field/select-field.module.css.js +1 -1
- package/lib/new-components/stack/stack.d.ts +3 -4
- package/lib/new-components/stack/stack.js +1 -1
- package/lib/new-components/stack/stack.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.d.ts +9 -2
- package/lib/new-components/switch-field/switch-field.js +1 -1
- package/lib/new-components/switch-field/switch-field.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.module.css.js +1 -1
- package/lib/new-components/tabs/tabs.js +1 -1
- package/lib/new-components/tabs/tabs.js.map +1 -1
- package/lib/new-components/tabs/tabs.module.css.js +1 -1
- package/lib/new-components/text/text.js +1 -1
- package/lib/new-components/text/text.js.map +1 -1
- package/lib/new-components/text-area/text-area.js +1 -1
- package/lib/new-components/text-area/text-area.js.map +1 -1
- package/lib/new-components/text-area/text-area.module.css.js +1 -1
- package/lib/new-components/text-field/text-field.js +1 -1
- package/lib/new-components/text-field/text-field.js.map +1 -1
- package/lib/new-components/text-field/text-field.module.css.js +1 -1
- package/lib/new-components/text-link/text-link.js +1 -1
- package/lib/new-components/text-link/text-link.js.map +1 -1
- package/package.json +15 -12
- package/styles/alert.css +2 -1
- package/styles/base-button.css +4 -3
- package/styles/base-button.module.css.css +1 -1
- package/styles/base-field.css +3 -2
- package/styles/box.css +3 -2
- package/styles/box.module.css.css +1 -1
- package/styles/checkbox-field.css +3 -3
- package/styles/checkbox-field.module.css.css +1 -1
- package/styles/color-picker.css +1 -1
- package/styles/columns.css +2 -1
- package/styles/deprecated-button.css +1 -1
- package/styles/deprecated-loading.css +1 -1
- package/styles/deprecated-modal.css +1 -1
- package/styles/divider.css +3 -2
- package/styles/divider.module.css.css +1 -1
- package/styles/dropdown.css +1 -1
- package/styles/heading.css +2 -1
- package/styles/hidden-visually.css +2 -1
- package/styles/hidden.css +2 -1
- package/styles/inline.css +2 -1
- package/styles/loading.css +3 -2
- package/styles/modal.css +6 -5
- package/styles/modal.module.css.css +1 -1
- package/styles/notice.css +2 -1
- package/styles/password-field.css +4 -3
- package/styles/progress-bar.css +5 -0
- package/styles/reactist.css +16 -19
- package/styles/select-field.css +4 -3
- package/styles/select-field.module.css.css +1 -1
- package/styles/spinner.module.css.css +1 -1
- package/styles/stack.css +3 -2
- package/styles/switch-field.css +4 -3
- package/styles/switch-field.module.css.css +1 -1
- package/styles/tabs.css +3 -2
- package/styles/tabs.module.css.css +1 -1
- package/styles/text-area.css +4 -3
- package/styles/text-area.module.css.css +1 -1
- package/styles/text-field.css +4 -3
- package/styles/text-field.module.css.css +1 -1
- package/styles/text-link.css +2 -1
- package/styles/text.css +2 -1
- package/styles/width.module.css.css +1 -0
- package/es/components/error-message/error-message.js +0 -90
- package/es/components/error-message/error-message.js.map +0 -1
- package/es/components/error-message/index.js +0 -6
- package/es/components/error-message/index.js.map +0 -1
- package/es/components/icon/icon.js +0 -96
- package/es/components/icon/icon.js.map +0 -1
- package/es/components/icon/index.js +0 -6
- package/es/components/icon/index.js.map +0 -1
- package/es/components/icons/ThinQuestionMarkIcon.svg.js +0 -24
- package/es/components/icons/ThinQuestionMarkIcon.svg.js.map +0 -1
- package/es/components/icons/ThreeDotsIcon.svg.js +0 -40
- package/es/components/icons/ThreeDotsIcon.svg.js.map +0 -1
- package/es/components/range-input/index.js +0 -6
- package/es/components/range-input/index.js.map +0 -1
- package/es/components/range-input/range-input.js +0 -55
- package/es/components/range-input/range-input.js.map +0 -1
- package/es/components/tip/index.js +0 -6
- package/es/components/tip/index.js.map +0 -1
- package/es/components/tip/tip.js +0 -30
- package/es/components/tip/tip.js.map +0 -1
- package/lib/components/error-message/error-message.d.ts +0 -23
- package/lib/components/error-message/error-message.js +0 -2
- package/lib/components/error-message/error-message.js.map +0 -1
- package/lib/components/error-message/error-message.test.d.ts +0 -1
- package/lib/components/error-message/index.d.ts +0 -2
- package/lib/components/error-message/index.js +0 -2
- package/lib/components/error-message/index.js.map +0 -1
- package/lib/components/icon/icon.d.ts +0 -31
- package/lib/components/icon/icon.js +0 -2
- package/lib/components/icon/icon.js.map +0 -1
- package/lib/components/icon/icon.test.d.ts +0 -1
- package/lib/components/icon/index.d.ts +0 -2
- package/lib/components/icon/index.js +0 -2
- package/lib/components/icon/index.js.map +0 -1
- package/lib/components/icons/ThinQuestionMarkIcon.svg.js +0 -2
- package/lib/components/icons/ThinQuestionMarkIcon.svg.js.map +0 -1
- package/lib/components/icons/ThreeDotsIcon.svg.js +0 -2
- package/lib/components/icons/ThreeDotsIcon.svg.js.map +0 -1
- package/lib/components/range-input/index.d.ts +0 -2
- package/lib/components/range-input/index.js +0 -2
- package/lib/components/range-input/index.js.map +0 -1
- package/lib/components/range-input/range-input.d.ts +0 -25
- package/lib/components/range-input/range-input.js +0 -2
- package/lib/components/range-input/range-input.js.map +0 -1
- package/lib/components/range-input/range-input.test.d.ts +0 -1
- package/lib/components/tip/index.d.ts +0 -2
- package/lib/components/tip/index.js +0 -2
- package/lib/components/tip/index.js.map +0 -1
- package/lib/components/tip/tip.d.ts +0 -20
- package/lib/components/tip/tip.js +0 -2
- package/lib/components/tip/tip.js.map +0 -1
- package/lib/components/tip/tip.test.d.ts +0 -1
- package/styles/error-message.css +0 -1
- package/styles/icon.css +0 -2
- package/styles/range-input.css +0 -1
- package/styles/tip.css +0 -4
|
@@ -3,6 +3,8 @@ import React__default from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import CloseIcon from '../icons/CloseIcon.svg.js';
|
|
5
5
|
|
|
6
|
+
var _excluded = ["id", "icon", "title", "subtitle", "children", "customCloseButton", "onClick", "onClose", "closeAltText", "className", "aria-live"];
|
|
7
|
+
|
|
6
8
|
function Notification(_ref) {
|
|
7
9
|
var id = _ref.id,
|
|
8
10
|
icon = _ref.icon,
|
|
@@ -15,7 +17,9 @@ function Notification(_ref) {
|
|
|
15
17
|
_ref$closeAltText = _ref.closeAltText,
|
|
16
18
|
closeAltText = _ref$closeAltText === void 0 ? 'Close' : _ref$closeAltText,
|
|
17
19
|
className = _ref.className,
|
|
18
|
-
|
|
20
|
+
_ref$ariaLive = _ref['aria-live'],
|
|
21
|
+
ariaLive = _ref$ariaLive === void 0 ? 'polite' : _ref$ariaLive,
|
|
22
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
23
|
|
|
20
24
|
var titleId = title ? id + "-title" : null;
|
|
21
25
|
var titleIdAttribute = titleId ? {
|
|
@@ -49,11 +53,12 @@ function Notification(_ref) {
|
|
|
49
53
|
}, icon !== null && icon !== void 0 ? icon : null, notificationContent);
|
|
50
54
|
return /*#__PURE__*/React__default.createElement("div", Object.assign({
|
|
51
55
|
id: id,
|
|
52
|
-
role: "
|
|
56
|
+
role: "alert",
|
|
53
57
|
className: classNames('reactist-notification', className, {
|
|
54
58
|
'reactist-notification--with-button': Boolean(onClick),
|
|
55
59
|
'reactist-notification--with-close-button': Boolean(onClose)
|
|
56
|
-
})
|
|
60
|
+
}),
|
|
61
|
+
"aria-live": ariaLive
|
|
57
62
|
}, ariaLabelledBy, ariaDescribedBy, rest), onClick ? /*#__PURE__*/React__default.createElement("button", {
|
|
58
63
|
className: "reactist-notification__button",
|
|
59
64
|
onClick: onClick
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sources":["../../../src/components/notification/notification.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\nimport CloseIcon from '../icons/CloseIcon.svg'\nimport './notification.less'\n\ntype NotificationProps = {\n id: string\n icon?: React.ReactNode\n title?: React.ReactNode\n subtitle?: React.ReactNode\n children?: React.ReactNode\n customCloseButton?: React.ReactNode\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n onClose?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n closeAltText?: string\n className?: string\n} & JSX.IntrinsicElements['div']
|
|
1
|
+
{"version":3,"file":"notification.js","sources":["../../../src/components/notification/notification.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\nimport CloseIcon from '../icons/CloseIcon.svg'\nimport './notification.less'\n\ntype NotificationProps = {\n id: string\n icon?: React.ReactNode\n title?: React.ReactNode\n subtitle?: React.ReactNode\n children?: React.ReactNode\n customCloseButton?: React.ReactNode\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n onClose?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n closeAltText?: string\n className?: string\n /** Indicates that the notification will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */\n 'aria-live'?: 'off' | 'polite' | 'assertive'\n} & Omit<JSX.IntrinsicElements['div'], 'aria-live'>\n\nfunction Notification({\n id,\n icon,\n title,\n subtitle,\n children,\n customCloseButton,\n onClick,\n onClose,\n closeAltText = 'Close',\n className,\n 'aria-live': ariaLive = 'polite',\n ...rest\n}: NotificationProps) {\n const titleId = title ? `${id}-title` : null\n const titleIdAttribute = titleId ? { id: titleId } : null\n const subtitleId = subtitle ? `${id}-subtitle` : null\n const subtitleIdAttribute = subtitleId ? { id: subtitleId } : null\n const contentId = children ? `${id}-content` : null\n const contentIdAttribute = children ? { id: `${id}-content` } : null\n const ariaLabelledBy = contentId\n ? { 'aria-labelledby': contentId }\n : titleId\n ? { 'aria-labelledby': titleId }\n : null\n const ariaDescribedBy = subtitleId && !children ? { 'aria-describedby': subtitleId } : null\n\n const notificationContent = (\n <div className=\"reactist-notification__content\" {...contentIdAttribute}>\n {children ?? (\n <>\n {title ? (\n <h3 className=\"reactist-notification__title\" {...titleIdAttribute}>\n {title}\n </h3>\n ) : null}\n {subtitle ? (\n <p className=\"reactist-notification__subtitle\" {...subtitleIdAttribute}>\n {subtitle}\n </p>\n ) : null}\n </>\n )}\n </div>\n )\n const notificationBody = (\n <div className=\"reactist-notification__icon-content-group\">\n {icon ?? null}\n {notificationContent}\n </div>\n )\n\n return (\n <div\n id={id}\n role=\"alert\"\n className={classNames('reactist-notification', className, {\n 'reactist-notification--with-button': Boolean(onClick),\n 'reactist-notification--with-close-button': Boolean(onClose),\n })}\n aria-live={ariaLive}\n {...ariaLabelledBy}\n {...ariaDescribedBy}\n {...rest}\n >\n {onClick ? (\n <button className=\"reactist-notification__button\" onClick={onClick}>\n {notificationBody}\n </button>\n ) : (\n notificationBody\n )}\n\n {onClose ? (\n <button\n className=\"reactist-notification__close-button\"\n onClick={onClose}\n aria-label={closeAltText}\n >\n {customCloseButton ?? <CloseIcon />}\n </button>\n ) : null}\n </div>\n )\n}\n\nexport { Notification }\n"],"names":["Notification","id","icon","title","subtitle","children","customCloseButton","onClick","onClose","closeAltText","className","ariaLive","rest","titleId","titleIdAttribute","subtitleId","subtitleIdAttribute","contentId","contentIdAttribute","ariaLabelledBy","ariaDescribedBy","notificationContent","React","notificationBody","role","classNames","Boolean","CloseIcon"],"mappings":";;;;;;;AAoBA,SAASA,YAAT;MACIC,UAAAA;MACAC,YAAAA;MACAC,aAAAA;MACAC,gBAAAA;MACAC,gBAAAA;MACAC,yBAAAA;MACAC,eAAAA;MACAC,eAAAA;+BACAC;MAAAA,8CAAe;MACfC,iBAAAA;2BACA;MAAaC,sCAAW;MACrBC;;AAEH,MAAMC,OAAO,GAAGV,KAAK,GAAMF,EAAN,cAAmB,IAAxC;AACA,MAAMa,gBAAgB,GAAGD,OAAO,GAAG;AAAEZ,IAAAA,EAAE,EAAEY;AAAN,GAAH,GAAqB,IAArD;AACA,MAAME,UAAU,GAAGX,QAAQ,GAAMH,EAAN,iBAAsB,IAAjD;AACA,MAAMe,mBAAmB,GAAGD,UAAU,GAAG;AAAEd,IAAAA,EAAE,EAAEc;AAAN,GAAH,GAAwB,IAA9D;AACA,MAAME,SAAS,GAAGZ,QAAQ,GAAMJ,EAAN,gBAAqB,IAA/C;AACA,MAAMiB,kBAAkB,GAAGb,QAAQ,GAAG;AAAEJ,IAAAA,EAAE,EAAKA,EAAL;AAAJ,GAAH,GAA6B,IAAhE;AACA,MAAMkB,cAAc,GAAGF,SAAS,GAC1B;AAAE,uBAAmBA;AAArB,GAD0B,GAE1BJ,OAAO,GACP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AACK,SAAD,MAAA,CAL1B,CADI,GAQJ,IA5BR,CADJ;AAgCH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { hasEnoughSpace, calculatePosition, RelativePosition } from './positioning-utils'\n\nimport './popover.less'\n\n/**\n * Position of the popover. Defaults to `auto`.\n * `auto` tries to position the tooltip to the top,\n * if there's not enough space it tries to position the tooltip clockwise (right, bottom, left).\n * Setting a distinct value like `right` will always position the popover right, regardless of available space.\n * Specifying `horizontal` will only try to position the tooltip left and right in that order.\n * Specifying `vertical` will only try to position the tooltip top and bottom in that order.\n */\ntype Position = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'auto'\n\ntype Props = {\n visible?: boolean\n /** ref of the popover in case you need to manipulate it. */\n popoverRef?: React.Ref<HTMLElement>\n /** ref of the wrapper in case you need to manipulate it. */\n wrapperRef?: React.Ref<HTMLElement>\n /** Function to be called when the mouse enters the trigger. */\n onMouseEnter?: React.MouseEventHandler\n /** Function to be called when the mouse leaves the trigger. */\n onMouseLeave?: React.MouseEventHandler\n onClick?: React.MouseEventHandler\n /** Additional css class that is applied to the wrapper element. */\n wrapperClassName?: string\n /** Additional css class that is applied to the popover element. */\n popoverClassName?: string\n /** Additional css class that is applied to style the arrow. Not applied when `withArrow` is false. */\n arrowClassName?: string\n /** Content prop of the popover. */\n content?: (() => React.ReactNode) | React.ReactNode\n trigger?: React.ReactNode\n position: Position\n withArrow?: boolean\n /**\n * Whether vague positioning is allowed. When set to true the popover prefers to be fully visible over being correctly centered.\n */\n allowVaguePositioning?: boolean\n /** Gap between the popover wrapper and the arrow. */\n gapSize: number\n}\n\nclass Popover extends React.Component<Props> {\n public static displayName: string\n public static defaultProps: Props\n\n componentDidMount() {\n if (this.props.visible) {\n this._updatePopoverPosition()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.wrapper && this.props.visible) {\n const positionChanged = prevProps.position !== this.props.position\n const vaguePositioningChanged =\n prevProps.allowVaguePositioning !== this.props.allowVaguePositioning\n const visibilityChanged = prevProps.visible !== this.props.visible\n const arrowChanged = prevProps.withArrow !== this.props.withArrow\n const gapSizeChanged = prevProps.gapSize !== this.props.gapSize\n const contentChanged = prevProps.content !== this.props.content\n if (\n positionChanged ||\n vaguePositioningChanged ||\n visibilityChanged ||\n arrowChanged ||\n gapSizeChanged ||\n contentChanged\n ) {\n this._updatePopoverPosition()\n }\n }\n }\n\n popover!: HTMLElement\n wrapper!: HTMLElement\n\n _updatePopoverPosition = () => {\n const { position, allowVaguePositioning, gapSize } = this.props\n const wrapperRect = this.wrapper.getBoundingClientRect()\n const popoverRect = this.popover.getBoundingClientRect()\n\n // Instead of using the documentElement find the nearest absolutely positioned element\n const documentEl = document.documentElement\n let node = this.wrapper\n let foundParent = false\n while (!foundParent) {\n const styles = getComputedStyle(node)\n const position = styles.getPropertyValue('position')\n if (position === 'absolute' || node === documentEl || !node.parentElement) {\n foundParent = true\n } else {\n node = node.parentElement\n }\n }\n const nodeRect = node.getBoundingClientRect()\n const windowDimensions = {\n height: nodeRect.height,\n width: nodeRect.width,\n }\n\n const popoverDimensions = {\n height: popoverRect.height,\n width: popoverRect.width,\n }\n const wrapperDimensions = {\n height: wrapperRect.height,\n width: wrapperRect.width,\n }\n const wrapperPositionRelative = {\n x: wrapperRect.left - nodeRect.left,\n y: wrapperRect.top - nodeRect.top,\n }\n const wrapperPositionAbsolute = {\n x: wrapperRect.left,\n y: wrapperRect.top,\n }\n\n const positionsToTry: RelativePosition[] =\n position === 'auto'\n ? ['top', 'right', 'bottom', 'left', 'top']\n : position === 'vertical'\n ? ['top', 'bottom']\n : position === 'horizontal'\n ? ['left', 'right']\n : [position]\n\n for (let index = 0; index < positionsToTry.length; index++) {\n const currentPosition = positionsToTry[index]\n const enoughSpaceAtPosition = hasEnoughSpace(\n windowDimensions,\n popoverDimensions,\n wrapperDimensions,\n wrapperPositionRelative,\n currentPosition,\n gapSize,\n )\n\n if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {\n const popoverPosition = calculatePosition(\n currentPosition,\n wrapperDimensions,\n wrapperPositionAbsolute,\n popoverDimensions,\n gapSize,\n )\n this.popover.style.top = `${popoverPosition.y}px`\n this.popover.style.left = `${popoverPosition.x}px`\n\n /**\n * Correct placement if vague positioning is allowed.\n * When it's not allowed we \"cut off\" popovers and display them\n * out of the viewport to maintain their centered position.\n */\n if (allowVaguePositioning) {\n // correct horizontally\n if (popoverPosition.x < 0) {\n this.popover.style.left = `${2 * gapSize}px`\n }\n // correct vertically\n if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {\n this.popover.style.top = `${\n windowDimensions.height - popoverDimensions.height - 2 * gapSize\n }px`\n }\n }\n\n if (currentPosition !== position) {\n this.popover.className = this._getClassNameForPosition(currentPosition)\n }\n break\n }\n }\n }\n\n _getClassNameForPosition = (position: Position) => {\n const { visible, withArrow, arrowClassName } = this.props\n const className = classNames('reactist_popover', { visible })\n\n if (visible && withArrow) {\n return classNames(className, arrowClassName, {\n arrow_top: position === 'bottom',\n arrow_right: position === 'left',\n arrow_bottom: position === 'auto' || position === 'top',\n arrow_left: position === 'right',\n })\n }\n return className\n }\n\n _updatePopoverRef = (popover: HTMLElement) => {\n this.popover = popover\n if (typeof this.props.popoverRef === 'function') {\n this.props.popoverRef(popover)\n }\n }\n\n _updateWrapperRef = (wrapper: HTMLElement) => {\n this.wrapper = wrapper\n if (typeof this.props.wrapperRef === 'function') {\n this.props.wrapperRef(wrapper)\n }\n }\n\n render() {\n const {\n position,\n wrapperClassName,\n popoverClassName,\n onMouseEnter,\n onMouseLeave,\n onClick,\n trigger,\n content,\n } = this.props\n const popoverClass = position ? this._getClassNameForPosition(position) : ''\n const popoverContentClass = classNames('reactist_popover__content', popoverClassName)\n const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName)\n const triggerElement = React.Children.only<React.ReactElement>(\n trigger as React.ReactElement,\n )\n\n function handleTriggerClick(event: React.SyntheticEvent) {\n // @ts-expect-error This is temporary while we revisit the Popover interface\n if (onClick) onClick(event)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (typeof triggerElement.props.onClick === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n triggerElement.props.onClick(event)\n }\n }\n\n return (\n <span\n className={wrapperClass}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={this._updateWrapperRef}\n >\n {React.cloneElement(triggerElement, { onClick: handleTriggerClick })}\n <span className={popoverClass} ref={this._updatePopoverRef}>\n {this.props.visible ? (\n <span className={popoverContentClass}>\n {typeof content === 'function' ? content() : content}\n </span>\n ) : null}\n </span>\n </span>\n )\n }\n}\nPopover.displayName = 'Popover'\nPopover.defaultProps = {\n position: 'auto',\n gapSize: 5, // default size of the arrow (see `tooltip.less`)\n}\n\nexport { Popover }\n"],"names":["Popover","props","position","allowVaguePositioning","gapSize","wrapperRect","wrapper","getBoundingClientRect","popoverRect","popover","documentEl","document","documentElement","node","foundParent","styles","getComputedStyle","getPropertyValue","parentElement","nodeRect","windowDimensions","height","width","popoverDimensions","wrapperDimensions","wrapperPositionRelative","x","left","y","top","wrapperPositionAbsolute","positionsToTry","index","length","currentPosition","enoughSpaceAtPosition","hasEnoughSpace","popoverPosition","calculatePosition","style","className","_getClassNameForPosition","visible","withArrow","arrowClassName","classNames","arrow_top","arrow_right","arrow_bottom","arrow_left","popoverRef","wrapperRef","componentDidMount","_updatePopoverPosition","componentDidUpdate","prevProps","positionChanged","vaguePositioningChanged","visibilityChanged","arrowChanged","gapSizeChanged","contentChanged","content","render","wrapperClassName","popoverClassName","onMouseEnter","onMouseLeave","onClick","trigger","popoverClass","popoverContentClass","wrapperClass","triggerElement","React","Children","only","handleTriggerClick","event","ref","_updateWrapperRef","cloneElement","_updatePopoverRef","Component","displayName","defaultProps"],"mappings":";;;;;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AACnBnF,EAAAA,QAAQ,EAAE,MADS;AAEnBE,EAAAA,OAAO,EAAE;AAFU,CAAvB;;;;"}
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { hasEnoughSpace, calculatePosition, RelativePosition } from './positioning-utils'\n\nimport './popover.less'\n\n/**\n * Position of the popover. Defaults to `auto`.\n * `auto` tries to position the tooltip to the top,\n * if there's not enough space it tries to position the tooltip clockwise (right, bottom, left).\n * Setting a distinct value like `right` will always position the popover right, regardless of available space.\n * Specifying `horizontal` will only try to position the tooltip left and right in that order.\n * Specifying `vertical` will only try to position the tooltip top and bottom in that order.\n */\ntype Position = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'auto'\n\ntype Props = {\n visible?: boolean\n /** ref of the popover in case you need to manipulate it. */\n popoverRef?: React.Ref<HTMLElement>\n /** ref of the wrapper in case you need to manipulate it. */\n wrapperRef?: React.Ref<HTMLElement>\n /** Function to be called when the mouse enters the trigger. */\n onMouseEnter?: React.MouseEventHandler\n /** Function to be called when the mouse leaves the trigger. */\n onMouseLeave?: React.MouseEventHandler\n onClick?: React.MouseEventHandler\n /** Additional css class that is applied to the wrapper element. */\n wrapperClassName?: string\n /** Additional css class that is applied to the popover element. */\n popoverClassName?: string\n /** Additional css class that is applied to style the arrow. Not applied when `withArrow` is false. */\n arrowClassName?: string\n /** Content prop of the popover. */\n content?: (() => React.ReactNode) | React.ReactNode\n trigger?: React.ReactNode\n position: Position\n withArrow?: boolean\n /**\n * Whether vague positioning is allowed. When set to true the popover prefers to be fully visible over being correctly centered.\n */\n allowVaguePositioning?: boolean\n /** Gap between the popover wrapper and the arrow. */\n gapSize: number\n}\n\nclass Popover extends React.Component<Props> {\n public static displayName: string\n public static defaultProps: Props\n\n componentDidMount() {\n if (this.props.visible) {\n this._updatePopoverPosition()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.wrapper && this.props.visible) {\n const positionChanged = prevProps.position !== this.props.position\n const vaguePositioningChanged =\n prevProps.allowVaguePositioning !== this.props.allowVaguePositioning\n const visibilityChanged = prevProps.visible !== this.props.visible\n const arrowChanged = prevProps.withArrow !== this.props.withArrow\n const gapSizeChanged = prevProps.gapSize !== this.props.gapSize\n const contentChanged = prevProps.content !== this.props.content\n if (\n positionChanged ||\n vaguePositioningChanged ||\n visibilityChanged ||\n arrowChanged ||\n gapSizeChanged ||\n contentChanged\n ) {\n this._updatePopoverPosition()\n }\n }\n }\n\n popover!: HTMLElement\n wrapper!: HTMLElement\n\n _updatePopoverPosition = () => {\n const { position, allowVaguePositioning, gapSize } = this.props\n const wrapperRect = this.wrapper.getBoundingClientRect()\n const popoverRect = this.popover.getBoundingClientRect()\n\n // Instead of using the documentElement find the nearest absolutely positioned element\n const documentEl = document.documentElement\n let node = this.wrapper\n let foundParent = false\n while (!foundParent) {\n const styles = getComputedStyle(node)\n const position = styles.getPropertyValue('position')\n if (position === 'absolute' || node === documentEl || !node.parentElement) {\n foundParent = true\n } else {\n node = node.parentElement\n }\n }\n const nodeRect = node.getBoundingClientRect()\n const windowDimensions = {\n height: nodeRect.height,\n width: nodeRect.width,\n }\n\n const popoverDimensions = {\n height: popoverRect.height,\n width: popoverRect.width,\n }\n const wrapperDimensions = {\n height: wrapperRect.height,\n width: wrapperRect.width,\n }\n const wrapperPositionRelative = {\n x: wrapperRect.left - nodeRect.left,\n y: wrapperRect.top - nodeRect.top,\n }\n const wrapperPositionAbsolute = {\n x: wrapperRect.left,\n y: wrapperRect.top,\n }\n\n const positionsToTry: RelativePosition[] =\n position === 'auto'\n ? ['top', 'right', 'bottom', 'left', 'top']\n : position === 'vertical'\n ? ['top', 'bottom']\n : position === 'horizontal'\n ? ['left', 'right']\n : [position]\n\n for (let index = 0; index < positionsToTry.length; index++) {\n const currentPosition = positionsToTry[index]\n const enoughSpaceAtPosition = hasEnoughSpace(\n windowDimensions,\n popoverDimensions,\n wrapperDimensions,\n wrapperPositionRelative,\n currentPosition,\n gapSize,\n )\n\n if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {\n const popoverPosition = calculatePosition(\n currentPosition,\n wrapperDimensions,\n wrapperPositionAbsolute,\n popoverDimensions,\n gapSize,\n )\n this.popover.style.top = `${popoverPosition.y}px`\n this.popover.style.left = `${popoverPosition.x}px`\n\n /**\n * Correct placement if vague positioning is allowed.\n * When it's not allowed we \"cut off\" popovers and display them\n * out of the viewport to maintain their centered position.\n */\n if (allowVaguePositioning) {\n // correct horizontally\n if (popoverPosition.x < 0) {\n this.popover.style.left = `${2 * gapSize}px`\n }\n // correct vertically\n if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {\n this.popover.style.top = `${\n windowDimensions.height - popoverDimensions.height - 2 * gapSize\n }px`\n }\n }\n\n if (currentPosition !== position) {\n this.popover.className = this._getClassNameForPosition(currentPosition)\n }\n break\n }\n }\n }\n\n _getClassNameForPosition = (position: Position) => {\n const { visible, withArrow, arrowClassName } = this.props\n const className = classNames('reactist_popover', { visible })\n\n if (visible && withArrow) {\n return classNames(className, arrowClassName, {\n arrow_top: position === 'bottom',\n arrow_right: position === 'left',\n arrow_bottom: position === 'auto' || position === 'top',\n arrow_left: position === 'right',\n })\n }\n return className\n }\n\n _updatePopoverRef = (popover: HTMLElement) => {\n this.popover = popover\n if (typeof this.props.popoverRef === 'function') {\n this.props.popoverRef(popover)\n }\n }\n\n _updateWrapperRef = (wrapper: HTMLElement) => {\n this.wrapper = wrapper\n if (typeof this.props.wrapperRef === 'function') {\n this.props.wrapperRef(wrapper)\n }\n }\n\n render() {\n const {\n position,\n wrapperClassName,\n popoverClassName,\n onMouseEnter,\n onMouseLeave,\n onClick,\n trigger,\n content,\n } = this.props\n const popoverClass = position ? this._getClassNameForPosition(position) : ''\n const popoverContentClass = classNames('reactist_popover__content', popoverClassName)\n const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName)\n const triggerElement = React.Children.only<React.ReactElement>(\n trigger as React.ReactElement,\n )\n\n function handleTriggerClick(event: React.SyntheticEvent) {\n // @ts-expect-error This is temporary while we revisit the Popover interface\n if (onClick) onClick(event)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (typeof triggerElement.props.onClick === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n triggerElement.props.onClick(event)\n }\n }\n\n return (\n <span\n className={wrapperClass}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={this._updateWrapperRef}\n >\n {React.cloneElement(triggerElement, { onClick: handleTriggerClick })}\n <span className={popoverClass} ref={this._updatePopoverRef}>\n {this.props.visible ? (\n <span className={popoverContentClass}>\n {typeof content === 'function' ? content() : content}\n </span>\n ) : null}\n </span>\n </span>\n )\n }\n}\nPopover.displayName = 'Popover'\nPopover.defaultProps = {\n position: 'auto',\n gapSize: 5, // default size of the arrow (see `tooltip.less`)\n}\n\nexport { Popover }\n"],"names":["Popover","props","position","allowVaguePositioning","gapSize","wrapperRect","wrapper","getBoundingClientRect","popoverRect","popover","documentEl","document","documentElement","node","foundParent","styles","getComputedStyle","getPropertyValue","parentElement","nodeRect","windowDimensions","height","width","popoverDimensions","wrapperDimensions","wrapperPositionRelative","x","left","y","top","wrapperPositionAbsolute","positionsToTry","index","length","currentPosition","enoughSpaceAtPosition","hasEnoughSpace","popoverPosition","calculatePosition","style","className","_getClassNameForPosition","visible","withArrow","arrowClassName","classNames","arrow_top","arrow_right","arrow_bottom","arrow_left","popoverRef","wrapperRef","componentDidMount","_updatePopoverPosition","componentDidUpdate","prevProps","positionChanged","vaguePositioningChanged","visibilityChanged","arrowChanged","gapSizeChanged","contentChanged","content","render","wrapperClassName","popoverClassName","onMouseEnter","onMouseLeave","onClick","trigger","popoverClass","popoverContentClass","wrapperClass","triggerElement","React","Children","only","handleTriggerClick","event","ref","_updateWrapperRef","cloneElement","_updatePopoverRef","Component","displayName","defaultProps"],"mappings":";;;;;IA+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E,KAAKG;KAAzC,EACK,KAAKjF,KAAL,CAAWyC,OAAX,gBACGgC,4BAAA,OAAA;AAAMlC,MAAAA,SAAS,EAAE+B;KAAjB,EACK,OAAOT,OAAP,KAAmB,UAAnB,GAAgCA,OAAO,EAAvC,GAA4CA,OADjD,CADH,GAIG,IALR,CAPJ,CADJ;AAiBH;;;EA/MiBY,cAAK,CAACS;;AAiN5BnF,OAAO,CAACoF,WAAR,GAAsB,SAAtB;AACApF,OAAO,CAACqF,YAAR,GAAuB;AACnBnF,EAAAA,QAAQ,EAAE,MADS;AAEnBE,EAAAA,OAAO,EAAE;AAFU,CAAvB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positioning-utils.js","sources":["../../../src/components/popover/positioning-utils.ts"],"sourcesContent":["type Dimensions = { width: number; height: number }\ntype AbsolutePosition = { x: number; y: number }\ntype RelativePosition = 'top' | 'right' | 'bottom' | 'left'\n\ntype HasEnoughSpaceFn = (\n windowDimensions: Dimensions,\n elementDimensions: Dimensions,\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n position: RelativePosition,\n gap: number,\n) => boolean\n\nconst hasEnoughSpace: HasEnoughSpaceFn = (\n windowDimensions,\n elementDimensions,\n wrapperDimensions,\n wrapperPosition,\n position,\n gap = 0,\n) => {\n const { height: windowHeight, width: windowWidth } = windowDimensions\n const { height: elementHeight, width: elementWidth } = elementDimensions\n const { height: wrapperHeight, width: wrapperWidth } = wrapperDimensions\n const { x: wrapperX, y: wrapperY } = wrapperPosition\n\n const verticalPosition = _calculateVerticalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const horizontalPosition = _calculateHorizontalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const canPlaceVertically =\n verticalPosition >= 0 && verticalPosition + elementWidth <= windowWidth\n const canPlaceHorizontally =\n horizontalPosition >= 0 && horizontalPosition + elementHeight <= windowHeight\n\n if (position === 'top') {\n return canPlaceVertically && wrapperY - elementHeight - gap >= 0\n } else if (position === 'right') {\n return canPlaceHorizontally && wrapperX + wrapperWidth + elementWidth + gap <= windowWidth\n } else if (position === 'left') {\n return canPlaceHorizontally && wrapperX - elementWidth - gap >= 0\n } else if (position === 'bottom') {\n return canPlaceVertically && wrapperY + wrapperHeight + elementHeight + gap <= windowHeight\n }\n return false\n}\n\ntype VerticalHorizontalPositionFn = (\n wrapperPosition: AbsolutePosition,\n wrapperDimensions: Dimensions,\n elementDimensions: Dimensions,\n) => number\n\nconst _calculateVerticalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.x + (wrapperDimensions.width - elementDimensions.width) / 2\n}\n\nconst _calculateHorizontalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.y + (wrapperDimensions.height - elementDimensions.height) / 2\n}\n\ntype CenterPositionFn = (\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculateTopCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y - elementDimensions.height - gap\n return { x, y }\n}\n\nconst calculateBottomCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y + wrapperDimensions.height + gap\n return { x, y }\n}\n\nconst calculateRightCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x + wrapperDimensions.width + gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\nconst calculateLeftCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x - elementDimensions.width - gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\ntype PositionFn = (\n position: 'top' | 'right' | 'bottom' | 'left',\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculatePosition: PositionFn = (\n position,\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n if (position === 'top') {\n return calculateTopCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'right') {\n return calculateRightCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'bottom') {\n return calculateBottomCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'left') {\n return calculateLeftCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n }\n return wrapperPosition\n}\n\nexport {\n hasEnoughSpace,\n calculatePosition,\n calculateTopCenterPosition,\n calculateBottomCenterPosition,\n calculateRightCenterPosition,\n calculateLeftCenterPosition,\n RelativePosition,\n}\n"],"names":["hasEnoughSpace","windowDimensions","elementDimensions","wrapperDimensions","wrapperPosition","position","gap","windowHeight","height","windowWidth","width","elementHeight","elementWidth","wrapperHeight","wrapperWidth","wrapperX","x","wrapperY","y","verticalPosition","_calculateVerticalPosition","horizontalPosition","_calculateHorizontalPosition","canPlaceVertically","canPlaceHorizontally","calculateTopCenterPosition","calculateBottomCenterPosition","calculateRightCenterPosition","calculateLeftCenterPosition","calculatePosition"],"mappings":"IAaMA,cAAc,GAAqB,SAAnCA,cAAmC,CACrCC,gBADqC,EAErCC,iBAFqC,EAGrCC,iBAHqC,EAIrCC,eAJqC,EAKrCC,QALqC,EAMrCC,GANqC;MAMrCA;AAAAA,IAAAA,MAAM;;;
|
|
1
|
+
{"version":3,"file":"positioning-utils.js","sources":["../../../src/components/popover/positioning-utils.ts"],"sourcesContent":["type Dimensions = { width: number; height: number }\ntype AbsolutePosition = { x: number; y: number }\ntype RelativePosition = 'top' | 'right' | 'bottom' | 'left'\n\ntype HasEnoughSpaceFn = (\n windowDimensions: Dimensions,\n elementDimensions: Dimensions,\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n position: RelativePosition,\n gap: number,\n) => boolean\n\nconst hasEnoughSpace: HasEnoughSpaceFn = (\n windowDimensions,\n elementDimensions,\n wrapperDimensions,\n wrapperPosition,\n position,\n gap = 0,\n) => {\n const { height: windowHeight, width: windowWidth } = windowDimensions\n const { height: elementHeight, width: elementWidth } = elementDimensions\n const { height: wrapperHeight, width: wrapperWidth } = wrapperDimensions\n const { x: wrapperX, y: wrapperY } = wrapperPosition\n\n const verticalPosition = _calculateVerticalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const horizontalPosition = _calculateHorizontalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const canPlaceVertically =\n verticalPosition >= 0 && verticalPosition + elementWidth <= windowWidth\n const canPlaceHorizontally =\n horizontalPosition >= 0 && horizontalPosition + elementHeight <= windowHeight\n\n if (position === 'top') {\n return canPlaceVertically && wrapperY - elementHeight - gap >= 0\n } else if (position === 'right') {\n return canPlaceHorizontally && wrapperX + wrapperWidth + elementWidth + gap <= windowWidth\n } else if (position === 'left') {\n return canPlaceHorizontally && wrapperX - elementWidth - gap >= 0\n } else if (position === 'bottom') {\n return canPlaceVertically && wrapperY + wrapperHeight + elementHeight + gap <= windowHeight\n }\n return false\n}\n\ntype VerticalHorizontalPositionFn = (\n wrapperPosition: AbsolutePosition,\n wrapperDimensions: Dimensions,\n elementDimensions: Dimensions,\n) => number\n\nconst _calculateVerticalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.x + (wrapperDimensions.width - elementDimensions.width) / 2\n}\n\nconst _calculateHorizontalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.y + (wrapperDimensions.height - elementDimensions.height) / 2\n}\n\ntype CenterPositionFn = (\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculateTopCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y - elementDimensions.height - gap\n return { x, y }\n}\n\nconst calculateBottomCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y + wrapperDimensions.height + gap\n return { x, y }\n}\n\nconst calculateRightCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x + wrapperDimensions.width + gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\nconst calculateLeftCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x - elementDimensions.width - gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\ntype PositionFn = (\n position: 'top' | 'right' | 'bottom' | 'left',\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculatePosition: PositionFn = (\n position,\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n if (position === 'top') {\n return calculateTopCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'right') {\n return calculateRightCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'bottom') {\n return calculateBottomCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'left') {\n return calculateLeftCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n }\n return wrapperPosition\n}\n\nexport {\n hasEnoughSpace,\n calculatePosition,\n calculateTopCenterPosition,\n calculateBottomCenterPosition,\n calculateRightCenterPosition,\n calculateLeftCenterPosition,\n RelativePosition,\n}\n"],"names":["hasEnoughSpace","windowDimensions","elementDimensions","wrapperDimensions","wrapperPosition","position","gap","windowHeight","height","windowWidth","width","elementHeight","elementWidth","wrapperHeight","wrapperWidth","wrapperX","x","wrapperY","y","verticalPosition","_calculateVerticalPosition","horizontalPosition","_calculateHorizontalPosition","canPlaceVertically","canPlaceHorizontally","calculateTopCenterPosition","calculateBottomCenterPosition","calculateRightCenterPosition","calculateLeftCenterPosition","calculatePosition"],"mappings":"IAaMA,cAAc,GAAqB,SAAnCA,cAAmC,CACrCC,gBADqC,EAErCC,iBAFqC,EAGrCC,iBAHqC,EAIrCC,eAJqC,EAKrCC,QALqC,EAMrCC,GANqC;MAMrCA;AAAAA,IAAAA,MAAM;;;AAEN,MAAgBC,YAAhB,GAAqDN,gBAArD,CAAQO,MAAR;AAAA,MAAqCC,WAArC,GAAqDR,gBAArD,CAA8BS,KAA9B;AACA,MAAgBC,aAAhB,GAAuDT,iBAAvD,CAAQM,MAAR;AAAA,MAAsCI,YAAtC,GAAuDV,iBAAvD,CAA+BQ,KAA/B;AACA,MAAgBG,aAAhB,GAAuDV,iBAAvD,CAAQK,MAAR;AAAA,MAAsCM,YAAtC,GAAuDX,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CF,iBAHgC,EAIhCI,GAJgC,CAApC;AAMH,GAPM,MAOA,IAAID,QAAQ,KAAK,MAAjB,EAAyB;AAC5B,WAAOuB,2BAA2B,CAC9BzB,iBAD8B,EAE9BC,eAF8B,EAG9BF,iBAH8B,EAI9BI,GAJ8B,CAAlC;AAMH;;AACD,SAAOF,eAAP;AACH;;;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
+
import { HiddenVisually } from '../../new-components/hidden-visually/hidden-visually.js';
|
|
3
4
|
|
|
4
5
|
function ProgressBar(_ref) {
|
|
5
6
|
var _ref$fillPercentage = _ref.fillPercentage,
|
|
6
7
|
fillPercentage = _ref$fillPercentage === void 0 ? 0 : _ref$fillPercentage,
|
|
7
|
-
className = _ref.className
|
|
8
|
+
className = _ref.className,
|
|
9
|
+
ariaValuetext = _ref['aria-valuetext'];
|
|
8
10
|
var finalClassName = classNames('reactist_progress_bar', className);
|
|
9
11
|
var width = fillPercentage < 0 ? 0 : fillPercentage > 100 ? 100 : fillPercentage;
|
|
10
12
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -14,7 +16,11 @@ function ProgressBar(_ref) {
|
|
|
14
16
|
style: {
|
|
15
17
|
width: width + "%"
|
|
16
18
|
}
|
|
17
|
-
})
|
|
19
|
+
}), /*#__PURE__*/React__default.createElement(HiddenVisually, null, /*#__PURE__*/React__default.createElement("progress", {
|
|
20
|
+
value: width,
|
|
21
|
+
max: 100,
|
|
22
|
+
"aria-valuetext": ariaValuetext !== null && ariaValuetext !== void 0 ? ariaValuetext : undefined
|
|
23
|
+
})));
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
ProgressBar.displayName = 'ProgressBar';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-bar.js","sources":["../../../src/components/progress-bar/progress-bar.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './progress-bar.less'\n\ntype Props = {\n /** Additional css class applied to the progress bar. */\n className?: string\n /** How much of the progress bar should be filled. Number between 0 and 100 inclusive. */\n fillPercentage?: number\n}\nfunction ProgressBar({ fillPercentage = 0, className }: Props) {\n const finalClassName = classNames('reactist_progress_bar', className)\n const width = fillPercentage < 0 ? 0 : fillPercentage > 100 ? 100 : fillPercentage\n return (\n <div className={finalClassName}>\n <div className=\"inner\" style={{ width: `${width}%` }} />\n </div>\n )\n}\nProgressBar.displayName = 'ProgressBar'\n\nexport { ProgressBar }\n"],"names":["ProgressBar","fillPercentage","className","finalClassName","classNames","width","React","style","displayName"],"mappings":"
|
|
1
|
+
{"version":3,"file":"progress-bar.js","sources":["../../../src/components/progress-bar/progress-bar.tsx"],"sourcesContent":["import React from 'react'\nimport { HiddenVisually } from '../../new-components/hidden-visually'\nimport classNames from 'classnames'\n\nimport './progress-bar.less'\n\ntype Props = {\n /** Additional css class applied to the progress bar. */\n className?: string\n /** How much of the progress bar should be filled. Number between 0 and 100 inclusive. */\n fillPercentage?: number\n /** Defines the human readable text alternative for assitive technologies. */\n 'aria-valuetext'?: string\n}\nfunction ProgressBar({ fillPercentage = 0, className, 'aria-valuetext': ariaValuetext }: Props) {\n const finalClassName = classNames('reactist_progress_bar', className)\n const width = fillPercentage < 0 ? 0 : fillPercentage > 100 ? 100 : fillPercentage\n return (\n <div className={finalClassName}>\n <div className=\"inner\" style={{ width: `${width}%` }} />\n <HiddenVisually>\n <progress value={width} max={100} aria-valuetext={ariaValuetext ?? undefined} />\n </HiddenVisually>\n </div>\n )\n}\nProgressBar.displayName = 'ProgressBar'\n\nexport { ProgressBar }\n"],"names":["ProgressBar","fillPercentage","className","ariaValuetext","finalClassName","classNames","width","React","style","HiddenVisually","value","max","undefined","displayName"],"mappings":";;;;AAcA,SAASA,WAAT;iCAAuBC;MAAAA,kDAAiB;MAAGC,iBAAAA;MAA6BC,qBAAlB;AAClD,MAAMC,cAAc,GAAGC,UAAU,CAAC,uBAAD,EAA0BH,SAA1B,CAAjC;AACA,MAAMI,KAAK,GAAGL,cAAc,GAAG,CAAjB,GAAqB,CAArB,GAAyBA,cAAc,GAAG,GAAjB,GAAuB,GAAvB,GAA6BA,cAApE;AACA,sBACIM,4BAAA,MAAA;AAAKL,IAAAA,SAAS,EAAEE;GAAhB,eACIG,4BAAA,MAAA;AAAKL,IAAAA,SAAS,EAAC;AAAQM,IAAAA,KAAK,EAAE;AAAEF,MAAAA,KAAK,EAAKA,KAAL;AAAP;GAA9B,CADJ,eAEIC,4BAAA,CAACE,cAAD,MAAA,eACIF,4BAAA,WAAA;AAAUG,IAAAA,KAAK,EAAEJ;AAAOK,IAAAA,GAAG,EAAE;sBAAqBR,0BAAAA,2BAAAA,gBAAiBS;GAAnE,CADJ,CAFJ,CADJ;AAQH;;AACDZ,WAAW,CAACa,WAAZ,GAA0B,aAA1B;;;;"}
|
|
@@ -2,6 +2,8 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '.
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
+
var _excluded = ["value", "options", "onChange", "disabled", "className", "defaultValue"];
|
|
6
|
+
|
|
5
7
|
function Select(_ref) {
|
|
6
8
|
var value = _ref.value,
|
|
7
9
|
_ref$options = _ref.options,
|
|
@@ -12,7 +14,7 @@ function Select(_ref) {
|
|
|
12
14
|
_ref$className = _ref.className,
|
|
13
15
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
14
16
|
defaultValue = _ref.defaultValue,
|
|
15
|
-
otherProps = _objectWithoutPropertiesLoose(_ref,
|
|
17
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16
18
|
|
|
17
19
|
var selectClassName = classNames('reactist_select', {
|
|
18
20
|
disabled: disabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options?.map((option) => (\n <option\n key={option.key || option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.text}\n </option>\n ))}\n </select>\n )\n}\nSelect.displayName = 'Select'\nSelect.defaultProps = {\n options: [],\n disabled: false,\n}\n\nexport { Select }\n"],"names":["Select","value","options","onChange","disabled","className","defaultValue","otherProps","selectClassName","classNames","React","event","target","undefined","map","option","key","text","displayName","defaultProps"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options?.map((option) => (\n <option\n key={option.key || option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.text}\n </option>\n ))}\n </select>\n )\n}\nSelect.displayName = 'Select'\nSelect.defaultProps = {\n options: [],\n disabled: false,\n}\n\nexport { Select }\n"],"names":["Select","value","options","onChange","disabled","className","defaultValue","otherProps","selectClassName","classNames","React","event","target","undefined","map","option","key","text","displayName","defaultProps"],"mappings":";;;;;;AA6BA,SAASA,MAAT;MACIC,aAAAA;0BACAC;MAAAA,oCAAU;MACVC,iBAAAA;2BACAC;MAAAA,sCAAW;4BACXC;MAAAA,wCAAY;MACZC,oBAAAA;MACGC;;AAEH,MAAMC,eAAe,GAAGC,UAAU,CAAC,iBAAD,EAAoB;AAAEL,IAAAA,QAAQ,EAARA;AAAF,GAApB,EAAkCC,SAAlC,CAAlC;AACA,sBACIK,4BAAA,SAAA;AACIL,IAAAA,SAAS,EAAEG;AACXP,IAAAA,KAAK,EAAEA;AACPE,IAAAA,QAAQ,EAAE,kBAACQ,KAAD;AAAA,aAAYR,SAAQ,GAAGA,SAAQ,CAACQ,KAAK,CAACC,MAAN,CAAaX,KAAd,CAAX,GAAkCY,SAAtD;AAAA;AACVT,IAAAA,QAAQ,EAAEA;AACVE,IAAAA,YAAY,EAAEA;KACVC,WANR,EAQKL,OARL,aAQKA,OARL,uBAQKA,OAAO,CAAEY,GAAT,CAAa,UAACC,MAAD;AAAA,wBACVL,4BAAA,SAAA;AACIM,MAAAA,GAAG,EAAED,MAAM,CAACC,GAAP,IAAcD,MAAM,CAACd;AAC1BA,MAAAA,KAAK,EAAEc,MAAM,CAACd;AACdG,MAAAA,QAAQ,EAAEW,MAAM,CAACX;KAHrB,EAKKW,MAAM,CAACE,IALZ,CADU;AAAA,GAAb,CARL,CADJ;AAoBH;;AACDjB,MAAM,CAACkB,WAAP,GAAqB,QAArB;AACAlB,MAAM,CAACmB,YAAP,GAAsB;AAClBjB,EAAAA,OAAO,EAAE,EADS;AAElBE,EAAAA,QAAQ,EAAE;AAFQ,CAAtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-utils.js","sources":["../../../src/components/time/time-utils.ts"],"sourcesContent":["import dayjs from 'dayjs'\n/**\n * There's a problem with our setup where the default export from\n * localizedFormat (and likely every other dayjs plugin) isn't properly\n * recognized. The proposed workarounds (importing with `.js` ending, or adding\n * `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type\n * checking. After spending some time on this it was decided that further\n * investigations are not worth it, the code works and the eslint ignore is fine.\n * ref: https://github.com/iamkun/dayjs/issues/593\n * ref: https://day.js.org/docs/en/installation/typescript\n */\n// eslint-disable-next-line import/default\nimport LocalizedFormat from 'dayjs/plugin/localizedFormat'\n\ndayjs.extend(LocalizedFormat)\n\ntype TimeConfig = {\n locale?: string\n longFormat?: string\n shortFormatCurrentYear?: string\n shortFormatPastYear?: string\n daysSuffix?: string\n hoursSuffix?: string\n minutesSuffix?: string\n momentsAgo?: string\n}\n\nconst TimeUtils = {\n SHORT_FORMAT_CURRENT_YEAR: 'L',\n SHORT_FORMAT_PAST_YEAR: 'LL',\n LONG_FORMAT: 'LL, LT',\n\n timeAgo(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n daysSuffix = 'd',\n hoursSuffix = 'h',\n minutesSuffix = 'm',\n momentsAgo = 'moments ago',\n } = config\n const now = dayjs()\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n const diffMinutes = now.diff(date, 'minute')\n const diffHours = now.diff(date, 'hour')\n const diffDays = now.diff(date, 'day')\n\n if (diffDays > 1) {\n if (date.isSame(now, 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n } else if (diffDays === 1) {\n return `${diffDays}${daysSuffix}`\n } else if (diffHours > 0 && diffHours <= 23) {\n return `${diffHours}${hoursSuffix}`\n } else if (diffMinutes > 0 && diffMinutes <= 59) {\n return `${diffMinutes}${minutesSuffix}`\n } else {\n return momentsAgo\n }\n },\n\n formatTime(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n if (date.isSame(dayjs(), 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n },\n\n formatTimeLong(timestamp: number, config: TimeConfig = {}) {\n const { locale = 'en', longFormat = this.LONG_FORMAT } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n return date.format(longFormat)\n },\n}\n\nexport { TimeUtils, TimeConfig }\n"],"names":["dayjs","extend","LocalizedFormat","TimeUtils","SHORT_FORMAT_CURRENT_YEAR","SHORT_FORMAT_PAST_YEAR","LONG_FORMAT","timeAgo","timestamp","config","locale","shortFormatCurrentYear","shortFormatPastYear","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo","now","date","diffMinutes","diff","diffHours","diffDays","isSame","format","formatTime","formatTimeLong","longFormat"],"mappings":";;;AAcAA,KAAK,CAACC,MAAN,CAAaC,eAAb;IAaMC,SAAS,GAAG;AACdC,EAAAA,yBAAyB,EAAE,GADb;AAEdC,EAAAA,sBAAsB,EAAE,IAFV;AAGdC,EAAAA,WAAW,EAAE,QAHC;AAKdC,EAAAA,OALc,mBAKNC,SALM,EAKaC,MALb;QAKaA;AAAAA,MAAAA,SAAqB;;;
|
|
1
|
+
{"version":3,"file":"time-utils.js","sources":["../../../src/components/time/time-utils.ts"],"sourcesContent":["import dayjs from 'dayjs'\n/**\n * There's a problem with our setup where the default export from\n * localizedFormat (and likely every other dayjs plugin) isn't properly\n * recognized. The proposed workarounds (importing with `.js` ending, or adding\n * `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type\n * checking. After spending some time on this it was decided that further\n * investigations are not worth it, the code works and the eslint ignore is fine.\n * ref: https://github.com/iamkun/dayjs/issues/593\n * ref: https://day.js.org/docs/en/installation/typescript\n */\n// eslint-disable-next-line import/default\nimport LocalizedFormat from 'dayjs/plugin/localizedFormat'\n\ndayjs.extend(LocalizedFormat)\n\ntype TimeConfig = {\n locale?: string\n longFormat?: string\n shortFormatCurrentYear?: string\n shortFormatPastYear?: string\n daysSuffix?: string\n hoursSuffix?: string\n minutesSuffix?: string\n momentsAgo?: string\n}\n\nconst TimeUtils = {\n SHORT_FORMAT_CURRENT_YEAR: 'L',\n SHORT_FORMAT_PAST_YEAR: 'LL',\n LONG_FORMAT: 'LL, LT',\n\n timeAgo(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n daysSuffix = 'd',\n hoursSuffix = 'h',\n minutesSuffix = 'm',\n momentsAgo = 'moments ago',\n } = config\n const now = dayjs()\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n const diffMinutes = now.diff(date, 'minute')\n const diffHours = now.diff(date, 'hour')\n const diffDays = now.diff(date, 'day')\n\n if (diffDays > 1) {\n if (date.isSame(now, 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n } else if (diffDays === 1) {\n return `${diffDays}${daysSuffix}`\n } else if (diffHours > 0 && diffHours <= 23) {\n return `${diffHours}${hoursSuffix}`\n } else if (diffMinutes > 0 && diffMinutes <= 59) {\n return `${diffMinutes}${minutesSuffix}`\n } else {\n return momentsAgo\n }\n },\n\n formatTime(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n if (date.isSame(dayjs(), 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n },\n\n formatTimeLong(timestamp: number, config: TimeConfig = {}) {\n const { locale = 'en', longFormat = this.LONG_FORMAT } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n return date.format(longFormat)\n },\n}\n\nexport { TimeUtils, TimeConfig }\n"],"names":["dayjs","extend","LocalizedFormat","TimeUtils","SHORT_FORMAT_CURRENT_YEAR","SHORT_FORMAT_PAST_YEAR","LONG_FORMAT","timeAgo","timestamp","config","locale","shortFormatCurrentYear","shortFormatPastYear","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo","now","date","diffMinutes","diff","diffHours","diffDays","isSame","format","formatTime","formatTimeLong","longFormat"],"mappings":";;;AAcAA,KAAK,CAACC,MAAN,CAAaC,eAAb;IAaMC,SAAS,GAAG;AACdC,EAAAA,yBAAyB,EAAE,GADb;AAEdC,EAAAA,sBAAsB,EAAE,IAFV;AAGdC,EAAAA,WAAW,EAAE,QAHC;AAKdC,EAAAA,OALc,mBAKNC,SALM,EAKaC,MALb;QAKaA;AAAAA,MAAAA,SAAqB;;;AAC5C,kBAQIA,MARJ;AAAA,iCACIC,MADJ;AAAA,QACIA,MADJ,+BACa,IADb;AAAA,wCAEIC,sBAFJ;AAAA,QAEIA,sBAFJ,sCAE6B,KAAKP,yBAFlC;AAAA,wCAGIQ,mBAHJ;AAAA,QAGIA,mBAHJ,sCAG0B,KAAKP,sBAH/B;AAAA,qCAIIQ,UAJJ;AAAA,QAIIA,UAJJ,mCAIiB,GAJjB;AAAA,sCAKIC,WALJ;AAAA,QAKIA,WALJ,oCAKkB,GALlB;AAAA,wCAMIC,aANJ;AAAA,QAMIA,aANJ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A,yCAEIC,sBAFJ;AAAA,QAEIA,sBAFJ,sCAE6B,KAAKP,yBAFlC;AAAA,yCAGIQ,mBAHJ;AAAA,QAGIA,mBAHJ,sCAG0B,KAAKP,sBAH/B;AAKA,QAAMa,IAAI,GAAGlB,KAAK,CAACQ,SAAS,GAAG,IAAb,CAAlB;AACAU,IAAAA,IAAI,CAACR,MAAL,CAAYA,MAAZ;;AACA,QAAIQ,IAAI,CAACK,MAAL,CAAYvB,KAAK,EAAjB,EAAqB,MAArB,CAAJ,EAAkC;AAC9B,aAAOkB,IAAI,CAACM,MAAL,CAAYb,sBAAZ,CAAP;AACH,KAFD,MAEO;AACH,aAAOO,IAAI,CAACM,MAAL,CAAYZ,mBAAZ,CAAP;AACH;AACJ,GApDa;AAsDdc,EAAAA,cAtDc,0BAsDClB,SAtDD,EAsDoBC,MAtDpB;QAsDoBA;AAAAA,MAAAA,SAAqB;;;AACnD,mBAAyDA,MAAzD;AAAA,mCAAQC,MAAR;AAAA,QAAQA,MAAR,gCAAiB,IAAjB;AAAA,uCAAuBiB,UAAvB;AAAA,QAAuBA,UAAvB,oCAAoC,KAAKrB,WAAzC;AACA,QAAMY,IAAI,GAAGlB,KAAK,CAACQ,SAAS,GAAG,IAAb,CAAlB;AACAU,IAAAA,IAAI,CAACR,MAAL,CAAYA,MAAZ;AACA,WAAOQ,IAAI,CAACM,MAAL,CAAYG,UAAZ,CAAP;AACH;AA3Da;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sources":["../../../src/components/time/time.tsx"],"sourcesContent":["import React from 'react'\n\nimport { Tooltip } from '../tooltip'\nimport { TimeUtils, TimeConfig } from './time-utils'\n\nimport './time.less'\n\nconst DELAY = 60000\n\ntype Props = {\n /** UNIX timestamp of the time to display. */\n time?: number\n /** Configuration for localization. */\n config?: TimeConfig\n /** Additional css class applied to the time element. */\n className?: string\n tooltipOnHover?: boolean\n /** Refresh the component every DELAY seconds. */\n refresh?: boolean\n /** If you don't want to use the default time format on the tooltip use this prop to supply a custom text */\n tooltip?: React.ReactNode\n /** When hovering over time it expands to short absolute version. */\n expandOnHover?: boolean\n /** When hovering over time it expands to the full absolute version. */\n expandFullyOnHover?: boolean\n}\n\ntype State = {\n hovered: boolean\n mouseX?: number\n mouseY?: number\n}\n\nclass Time extends React.Component<Props, State> {\n public static displayName: string\n public static defaultProps: Props\n\n constructor(props: Props) {\n super(props)\n this.refreshInterval = undefined\n\n this.state = {\n hovered: false,\n mouseX: undefined,\n mouseY: undefined,\n }\n }\n\n componentDidMount() {\n if (this.props.refresh) {\n this._refresh()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!prevProps.refresh && this.props.refresh) {\n this._refresh()\n }\n\n if (prevProps.refresh && !this.props.refresh) {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n }\n\n componentWillUnmount() {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n\n refreshInterval?: ReturnType<typeof setTimeout>\n\n _setHovered(hovered: boolean, event: React.MouseEvent) {\n const { mouseX, mouseY } = this.state\n const { clientX, clientY } = event\n if (clientX !== mouseX || clientY !== mouseY) {\n // mouse has moved\n this.setState(() => ({\n hovered,\n mouseX: clientX,\n mouseY: clientY,\n }))\n }\n }\n\n _renderTime(config: Props['config']) {\n if (!this.props.time) {\n return\n }\n if (this.state.hovered) {\n if (this.props.expandFullyOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTimeLong(this.props.time, config)\n }\n if (this.props.expandOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTime(this.props.time, config)\n }\n }\n return TimeUtils.timeAgo(this.props.time, config)\n }\n\n _refresh() {\n this.refreshInterval = setInterval(() => {\n this.forceUpdate()\n }, DELAY)\n }\n\n render() {\n let className = 'reactist_time'\n if (this.props.className) {\n className = this.props.className\n }\n\n const timeComponent = this._renderTime(this.props.config)\n\n return (\n <time\n className={className}\n onMouseEnter={(event) => this._setHovered(true, event)}\n onMouseLeave={(event) => this._setHovered(false, event)}\n >\n {this.props.tooltipOnHover ? (\n <Tooltip\n content={\n this.props.tooltip ||\n (this.props.time &&\n TimeUtils.formatTimeLong(this.props.time, this.props.config))\n }\n >\n <span>{timeComponent}</span>\n </Tooltip>\n ) : (\n timeComponent\n )}\n </time>\n )\n }\n}\nTime.displayName = 'Time'\n\nTime.defaultProps = {\n expandOnHover: false,\n expandFullyOnHover: false,\n tooltipOnHover: false,\n refresh: true,\n config: {\n locale: 'en',\n daysSuffix: 'd',\n hoursSuffix: 'h',\n minutesSuffix: 'm',\n momentsAgo: 'moments ago',\n },\n}\n\nexport { Time }\n"],"names":["DELAY","Time","props","refreshInterval","undefined","state","hovered","mouseX","mouseY","componentDidMount","refresh","_refresh","componentDidUpdate","prevProps","clearTimeout","componentWillUnmount","_setHovered","event","clientX","clientY","setState","_renderTime","config","time","expandFullyOnHover","tooltipOnHover","TimeUtils","formatTimeLong","expandOnHover","formatTime","timeAgo","setInterval","forceUpdate","render","className","timeComponent","React","onMouseEnter","onMouseLeave","Tooltip","content","tooltip","Component","displayName","defaultProps","locale","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo"],"mappings":";;;;;AAOA,IAAMA,KAAK,GAAG,KAAd;;IA0BMC;;;AAIF,gBAAYC,KAAZ;;;AACI,wCAAMA,KAAN;AACA,UAAKC,eAAL,GAAuBC,SAAvB;AAEA,UAAKC,KAAL,GAAa;AACTC,MAAAA,OAAO,EAAE,KADA;AAETC,MAAAA,MAAM,EAAEH,SAFC;AAGTI,MAAAA,MAAM,EAAEJ;AAHC,KAAb;;AAKH;;;;SAEDK,oBAAA;AACI,QAAI,KAAKP,KAAL,CAAWQ,OAAf,EAAwB;AACpB,WAAKC,QAAL;AACH;AACJ;;SAEDC,qBAAA,4BAAmBC,SAAnB;AACI,QAAI,CAACA,SAAS,CAACH,OAAX,IAAsB,KAAKR,KAAL,CAAWQ,OAArC,EAA8C;AAC1C,WAAKC,QAAL;AACH;;AAED,QAAIE,SAAS,CAACH,OAAV,IAAqB,CAAC,KAAKR,KAAL,CAAWQ,OAArC,EAA8C;AAC1C,UAAI,KAAKP,eAAT,EAA0B;AACtBW,QAAAA,YAAY,CAAC,KAAKX,eAAN,CAAZ;AACH;AACJ;AACJ;;SAEDY,uBAAA;AACI,QAAI,KAAKZ,eAAT,EAA0B;AACtBW,MAAAA,YAAY,CAAC,KAAKX,eAAN,CAAZ;AACH;AACJ;;SAIDa,cAAA,qBAAYV,OAAZ,EAA8BW,KAA9B;
|
|
1
|
+
{"version":3,"file":"time.js","sources":["../../../src/components/time/time.tsx"],"sourcesContent":["import React from 'react'\n\nimport { Tooltip } from '../tooltip'\nimport { TimeUtils, TimeConfig } from './time-utils'\n\nimport './time.less'\n\nconst DELAY = 60000\n\ntype Props = {\n /** UNIX timestamp of the time to display. */\n time?: number\n /** Configuration for localization. */\n config?: TimeConfig\n /** Additional css class applied to the time element. */\n className?: string\n tooltipOnHover?: boolean\n /** Refresh the component every DELAY seconds. */\n refresh?: boolean\n /** If you don't want to use the default time format on the tooltip use this prop to supply a custom text */\n tooltip?: React.ReactNode\n /** When hovering over time it expands to short absolute version. */\n expandOnHover?: boolean\n /** When hovering over time it expands to the full absolute version. */\n expandFullyOnHover?: boolean\n}\n\ntype State = {\n hovered: boolean\n mouseX?: number\n mouseY?: number\n}\n\nclass Time extends React.Component<Props, State> {\n public static displayName: string\n public static defaultProps: Props\n\n constructor(props: Props) {\n super(props)\n this.refreshInterval = undefined\n\n this.state = {\n hovered: false,\n mouseX: undefined,\n mouseY: undefined,\n }\n }\n\n componentDidMount() {\n if (this.props.refresh) {\n this._refresh()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!prevProps.refresh && this.props.refresh) {\n this._refresh()\n }\n\n if (prevProps.refresh && !this.props.refresh) {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n }\n\n componentWillUnmount() {\n if (this.refreshInterval) {\n clearTimeout(this.refreshInterval)\n }\n }\n\n refreshInterval?: ReturnType<typeof setTimeout>\n\n _setHovered(hovered: boolean, event: React.MouseEvent) {\n const { mouseX, mouseY } = this.state\n const { clientX, clientY } = event\n if (clientX !== mouseX || clientY !== mouseY) {\n // mouse has moved\n this.setState(() => ({\n hovered,\n mouseX: clientX,\n mouseY: clientY,\n }))\n }\n }\n\n _renderTime(config: Props['config']) {\n if (!this.props.time) {\n return\n }\n if (this.state.hovered) {\n if (this.props.expandFullyOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTimeLong(this.props.time, config)\n }\n if (this.props.expandOnHover && !this.props.tooltipOnHover) {\n return TimeUtils.formatTime(this.props.time, config)\n }\n }\n return TimeUtils.timeAgo(this.props.time, config)\n }\n\n _refresh() {\n this.refreshInterval = setInterval(() => {\n this.forceUpdate()\n }, DELAY)\n }\n\n render() {\n let className = 'reactist_time'\n if (this.props.className) {\n className = this.props.className\n }\n\n const timeComponent = this._renderTime(this.props.config)\n\n return (\n <time\n className={className}\n onMouseEnter={(event) => this._setHovered(true, event)}\n onMouseLeave={(event) => this._setHovered(false, event)}\n >\n {this.props.tooltipOnHover ? (\n <Tooltip\n content={\n this.props.tooltip ||\n (this.props.time &&\n TimeUtils.formatTimeLong(this.props.time, this.props.config))\n }\n >\n <span>{timeComponent}</span>\n </Tooltip>\n ) : (\n timeComponent\n )}\n </time>\n )\n }\n}\nTime.displayName = 'Time'\n\nTime.defaultProps = {\n expandOnHover: false,\n expandFullyOnHover: false,\n tooltipOnHover: false,\n refresh: true,\n config: {\n locale: 'en',\n daysSuffix: 'd',\n hoursSuffix: 'h',\n minutesSuffix: 'm',\n momentsAgo: 'moments ago',\n },\n}\n\nexport { Time }\n"],"names":["DELAY","Time","props","refreshInterval","undefined","state","hovered","mouseX","mouseY","componentDidMount","refresh","_refresh","componentDidUpdate","prevProps","clearTimeout","componentWillUnmount","_setHovered","event","clientX","clientY","setState","_renderTime","config","time","expandFullyOnHover","tooltipOnHover","TimeUtils","formatTimeLong","expandOnHover","formatTime","timeAgo","setInterval","forceUpdate","render","className","timeComponent","React","onMouseEnter","onMouseLeave","Tooltip","content","tooltip","Component","displayName","defaultProps","locale","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo"],"mappings":";;;;;AAOA,IAAMA,KAAK,GAAG,KAAd;;IA0BMC;;;AAIF,gBAAYC,KAAZ;;;AACI,wCAAMA,KAAN;AACA,UAAKC,eAAL,GAAuBC,SAAvB;AAEA,UAAKC,KAAL,GAAa;AACTC,MAAAA,OAAO,EAAE,KADA;AAETC,MAAAA,MAAM,EAAEH,SAFC;AAGTI,MAAAA,MAAM,EAAEJ;AAHC,KAAb;;AAKH;;;;SAEDK,oBAAA;AACI,QAAI,KAAKP,KAAL,CAAWQ,OAAf,EAAwB;AACpB,WAAKC,QAAL;AACH;AACJ;;SAEDC,qBAAA,4BAAmBC,SAAnB;AACI,QAAI,CAACA,SAAS,CAACH,OAAX,IAAsB,KAAKR,KAAL,CAAWQ,OAArC,EAA8C;AAC1C,WAAKC,QAAL;AACH;;AAED,QAAIE,SAAS,CAACH,OAAV,IAAqB,CAAC,KAAKR,KAAL,CAAWQ,OAArC,EAA8C;AAC1C,UAAI,KAAKP,eAAT,EAA0B;AACtBW,QAAAA,YAAY,CAAC,KAAKX,eAAN,CAAZ;AACH;AACJ;AACJ;;SAEDY,uBAAA;AACI,QAAI,KAAKZ,eAAT,EAA0B;AACtBW,MAAAA,YAAY,CAAC,KAAKX,eAAN,CAAZ;AACH;AACJ;;SAIDa,cAAA,qBAAYV,OAAZ,EAA8BW,KAA9B;AACI,sBAA2B,KAAKZ,KAAhC;AAAA,QAAQE,MAAR,eAAQA,MAAR;AAAA,QAAgBC,MAAhB,eAAgBA,MAAhB;AACA,QAAQU,OAAR,GAA6BD,KAA7B,CAAQC,OAAR;AAAA,QAAiBC,OAAjB,GAA6BF,KAA7B,CAAiBE,OAAjB;;AACA,QAAID,OAAO,KAAKX,MAAZ,IAAsBY,OAAO,KAAKX,MAAtC,EAA8C;AAC1C;AACA,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,sBAACpB,KAAD;AAAA,eAAW,MAAI,CAACD,WAAL,CAAiB,IAAjB,EAAuBC,KAAvB,CAAX;AAAA;AACdqB,MAAAA,YAAY,EAAE,sBAACrB,KAAD;AAAA,eAAW,MAAI,CAACD,WAAL,CAAiB,KAAjB,EAAwBC,KAAxB,CAAX;AAAA;KAHlB,EAKK,KAAKf,KAAL,CAAWuB,cAAX,gBACGW,4BAAA,CAACG,OAAD;AACIC,MAAAA,OAAO,EACH,KAAKtC,KAAL,CAAWuC,OAAX,IACC,KAAKvC,KAAL,CAAWqB,IAAX,IACGG,SAAS,CAACC,cAAV,CAAyB,KAAKzB,KAAL,CAAWqB,IAApC,EAA0C,KAAKrB,KAAL,CAAWoB,MAArD;KAJZ,eAOIc,4BAAA,OAAA,MAAA,EAAOD,aAAP,CAPJ,CADH,GAWGA,aAhBR,CADJ;AAqBH;;;EAxGcC,cAAK,CAACM;;AA0GzBzC,IAAI,CAAC0C,WAAL,GAAmB,MAAnB;AAEA1C,IAAI,CAAC2C,YAAL,GAAoB;AAChBhB,EAAAA,aAAa,EAAE,KADC;AAEhBJ,EAAAA,kBAAkB,EAAE,KAFJ;AAGhBC,EAAAA,cAAc,EAAE,KAHA;AAIhBf,EAAAA,OAAO,EAAE,IAJO;AAKhBY,EAAAA,MAAM,EAAE;AACJuB,IAAAA,MAAM,EAAE,IADJ;AAEJC,IAAAA,UAAU,EAAE,GAFR;AAGJC,IAAAA,WAAW,EAAE,GAHT;AAIJC,IAAAA,aAAa,EAAE,GAJX;AAKJC,IAAAA,UAAU,EAAE;AALR;AALQ,CAApB;;;;"}
|
|
@@ -3,6 +3,8 @@ import React__default from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { TooltipReference, Tooltip as Tooltip$1, useTooltipState } from 'reakit/Tooltip';
|
|
5
5
|
|
|
6
|
+
var _excluded = ["children", "content", "position", "gapSize", "className"];
|
|
7
|
+
|
|
6
8
|
var SHOW_DELAY = 500;
|
|
7
9
|
var HIDE_DELAY = 100;
|
|
8
10
|
|
|
@@ -29,7 +31,7 @@ function Tooltip(_ref) {
|
|
|
29
31
|
_ref$gapSize = _ref.gapSize,
|
|
30
32
|
gapSize = _ref$gapSize === void 0 ? 3 : _ref$gapSize,
|
|
31
33
|
className = _ref.className,
|
|
32
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
34
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
33
35
|
|
|
34
36
|
var tooltip = useDelayedTooltipState({
|
|
35
37
|
placement: position,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport {\n useTooltipState,\n TooltipInitialState,\n Tooltip as ReakitTooltip,\n TooltipReference,\n TooltipProps as ReakitTooltipProps,\n} from 'reakit/Tooltip'\nimport { PopoverState } from 'reakit/Popover'\n\nimport './tooltip.less'\n\ntype TooltipProps = Omit<ReakitTooltipProps, 'children'> & {\n children: React.ReactNode\n content: React.ReactNode | (() => React.ReactNode)\n position?: PopoverState['placement']\n gapSize?: number\n}\n\n// These are exported to be used in the tests, they are not meant to be exported publicly\nexport const SHOW_DELAY = 500\nexport const HIDE_DELAY = 100\n\nfunction useDelayedTooltipState(initialState: TooltipInitialState) {\n const tooltipState = useTooltipState(initialState)\n const delay = useDelay()\n return React.useMemo(\n () => ({\n ...tooltipState,\n show: delay(() => tooltipState.show(), SHOW_DELAY),\n hide: delay(() => tooltipState.hide(), HIDE_DELAY),\n }),\n [delay, tooltipState],\n )\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n className,\n ...props\n}: TooltipProps) {\n const tooltip = useDelayedTooltipState({ placement: position, gutter: gapSize })\n\n const child = React.Children.only<React.ReactElement>(children as React.ReactElement)\n if (!content) {\n return child\n }\n\n /**\n * Prevents the tooltip from automatically firing on focus all the time. This is to prevent\n * tooltips from showing when the trigger element is focused back after a popover or dialog that\n * it opened was closed. See link below for more details.\n * @see https://github.com/reakit/reakit/discussions/749\n */\n function handleFocus(event: React.FocusEvent) {\n // If focus is not followed by a key up event, does it mean that it's not\n // an intentional keyboard focus? Not sure but it seems to work.\n // This may be resolved soon in an upcoming version of reakit:\n // https://github.com/reakit/reakit/issues/750\n function handleKeyUp(e: Event) {\n const eventKey = (e as KeyboardEvent).key\n if (eventKey !== 'Escape' && eventKey !== 'Enter' && eventKey !== 'Space') {\n tooltip.show()\n }\n }\n event.currentTarget.addEventListener('keyup', handleKeyUp, { once: true })\n // Prevent tooltip.show from being called by TooltipReference\n event.preventDefault()\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n if (typeof child.props.onFocus === 'function') child.props.onFocus(event)\n }\n\n return (\n <>\n <TooltipReference\n {...tooltip}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ref={(child as any).ref}\n {...child.props}\n onFocus={handleFocus}\n >\n {(referenceProps) => React.cloneElement(child, referenceProps)}\n </TooltipReference>\n {tooltip.visible ? (\n <ReakitTooltip\n {...tooltip}\n {...props}\n className={classNames('reactist_tooltip', className)}\n >\n {typeof content === 'function' ? content() : content}\n </ReakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n\n//\n// Internal helpers\n//\n\n/**\n * Returns a function offering the same interface as setTimeout, but cleans up on unmount.\n *\n * The timeout state is shared, and only one delayed function can be active at any given time. If\n * a new delayed function is called while another one was waiting for its time to run, that older\n * invocation is cleared and it never runs.\n *\n * This is suitable for our use case here, but probably not the most intuitive thing in general.\n * That's why this is not made a shared util or something like it.\n */\nfunction useDelay() {\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>()\n\n const clearTimeouts = React.useCallback(function clearTimeouts() {\n if (timeoutRef.current != null) {\n clearTimeout(timeoutRef.current)\n }\n }, [])\n\n // Runs clearTimeouts when the component is unmounted\n React.useEffect(() => clearTimeouts, [clearTimeouts])\n\n return React.useCallback(\n function delay(fn: () => void, delay: number) {\n return () => {\n clearTimeouts()\n timeoutRef.current = setTimeout(fn, delay)\n }\n },\n [clearTimeouts],\n )\n}\n"],"names":["SHOW_DELAY","HIDE_DELAY","useDelayedTooltipState","initialState","tooltipState","useTooltipState","delay","useDelay","React","useMemo","show","hide","Tooltip","children","content","position","gapSize","className","props","tooltip","placement","gutter","child","Children","only","handleFocus","event","handleKeyUp","e","eventKey","key","currentTarget","addEventListener","once","preventDefault","onFocus","TooltipReference","ref","referenceProps","cloneElement","visible","ReakitTooltip","classNames","timeoutRef","useRef","clearTimeouts","useCallback","current","clearTimeout","useEffect","fn","setTimeout"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport {\n useTooltipState,\n TooltipInitialState,\n Tooltip as ReakitTooltip,\n TooltipReference,\n TooltipProps as ReakitTooltipProps,\n} from 'reakit/Tooltip'\nimport { PopoverState } from 'reakit/Popover'\n\nimport './tooltip.less'\n\ntype TooltipProps = Omit<ReakitTooltipProps, 'children'> & {\n children: React.ReactNode\n content: React.ReactNode | (() => React.ReactNode)\n position?: PopoverState['placement']\n gapSize?: number\n}\n\n// These are exported to be used in the tests, they are not meant to be exported publicly\nexport const SHOW_DELAY = 500\nexport const HIDE_DELAY = 100\n\nfunction useDelayedTooltipState(initialState: TooltipInitialState) {\n const tooltipState = useTooltipState(initialState)\n const delay = useDelay()\n return React.useMemo(\n () => ({\n ...tooltipState,\n show: delay(() => tooltipState.show(), SHOW_DELAY),\n hide: delay(() => tooltipState.hide(), HIDE_DELAY),\n }),\n [delay, tooltipState],\n )\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n className,\n ...props\n}: TooltipProps) {\n const tooltip = useDelayedTooltipState({ placement: position, gutter: gapSize })\n\n const child = React.Children.only<React.ReactElement>(children as React.ReactElement)\n if (!content) {\n return child\n }\n\n /**\n * Prevents the tooltip from automatically firing on focus all the time. This is to prevent\n * tooltips from showing when the trigger element is focused back after a popover or dialog that\n * it opened was closed. See link below for more details.\n * @see https://github.com/reakit/reakit/discussions/749\n */\n function handleFocus(event: React.FocusEvent) {\n // If focus is not followed by a key up event, does it mean that it's not\n // an intentional keyboard focus? Not sure but it seems to work.\n // This may be resolved soon in an upcoming version of reakit:\n // https://github.com/reakit/reakit/issues/750\n function handleKeyUp(e: Event) {\n const eventKey = (e as KeyboardEvent).key\n if (eventKey !== 'Escape' && eventKey !== 'Enter' && eventKey !== 'Space') {\n tooltip.show()\n }\n }\n event.currentTarget.addEventListener('keyup', handleKeyUp, { once: true })\n // Prevent tooltip.show from being called by TooltipReference\n event.preventDefault()\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n if (typeof child.props.onFocus === 'function') child.props.onFocus(event)\n }\n\n return (\n <>\n <TooltipReference\n {...tooltip}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ref={(child as any).ref}\n {...child.props}\n onFocus={handleFocus}\n >\n {(referenceProps) => React.cloneElement(child, referenceProps)}\n </TooltipReference>\n {tooltip.visible ? (\n <ReakitTooltip\n {...tooltip}\n {...props}\n className={classNames('reactist_tooltip', className)}\n >\n {typeof content === 'function' ? content() : content}\n </ReakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n\n//\n// Internal helpers\n//\n\n/**\n * Returns a function offering the same interface as setTimeout, but cleans up on unmount.\n *\n * The timeout state is shared, and only one delayed function can be active at any given time. If\n * a new delayed function is called while another one was waiting for its time to run, that older\n * invocation is cleared and it never runs.\n *\n * This is suitable for our use case here, but probably not the most intuitive thing in general.\n * That's why this is not made a shared util or something like it.\n */\nfunction useDelay() {\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>()\n\n const clearTimeouts = React.useCallback(function clearTimeouts() {\n if (timeoutRef.current != null) {\n clearTimeout(timeoutRef.current)\n }\n }, [])\n\n // Runs clearTimeouts when the component is unmounted\n React.useEffect(() => clearTimeouts, [clearTimeouts])\n\n return React.useCallback(\n function delay(fn: () => void, delay: number) {\n return () => {\n clearTimeouts()\n timeoutRef.current = setTimeout(fn, delay)\n }\n },\n [clearTimeouts],\n )\n}\n"],"names":["SHOW_DELAY","HIDE_DELAY","useDelayedTooltipState","initialState","tooltipState","useTooltipState","delay","useDelay","React","useMemo","show","hide","Tooltip","children","content","position","gapSize","className","props","tooltip","placement","gutter","child","Children","only","handleFocus","event","handleKeyUp","e","eventKey","key","currentTarget","addEventListener","once","preventDefault","onFocus","TooltipReference","ref","referenceProps","cloneElement","visible","ReakitTooltip","classNames","timeoutRef","useRef","clearTimeouts","useCallback","current","clearTimeout","useEffect","fn","setTimeout"],"mappings":";;;;;;;IAsBaA,UAAU,GAAG;IACbC,UAAU,GAAG;;AAE1B,SAASC,sBAAT,CAAgCC,YAAhC;AACI,MAAMC,YAAY,GAAGC,eAAe,CAACF,YAAD,CAApC;AACA,MAAMG,KAAK,GAAGC,QAAQ,EAAtB;AACA,SAAOC,cAAK,CAACC,OAAN,CACH;AAAA,6CACOL,YADP;AAEIM,MAAAA,IAAI,EAAEJ,KAAK,CAAC;AAAA,eAAMF,YAAY,CAACM,IAAb,EAAN;AAAA,OAAD,EAA4BV,UAA5B,CAFf;AAGIW,MAAAA,IAAI,EAAEL,KAAK,CAAC;AAAA,eAAMF,YAAY,CAACO,IAAb,EAAN;AAAA,OAAD,EAA4BV,UAA5B;AAHf;AAAA,GADG,EAMH,CAACK,KAAD,EAAQF,YAAR,CANG,CAAP;AAQH;;AAED,SAASQ,OAAT;MACIC,gBAAAA;MACAC,eAAAA;2BACAC;MAAAA,sCAAW;0BACXC;MAAAA,oCAAU;MACVC,iBAAAA;MACGC;;AAE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D,EAAqBzB,SAArB;IAHzB,EAKK,OAAOH,OAAP,KAAmB,UAAnB,GAAgCA,OAAO,EAAvC,GAA4CA,OALjD,CADH,GAQG,IAlBR,CADJ;AAsBH;AAMD;AACA;;AAEA;;;;;;;;;;;AAUA,SAASP,QAAT;AACI,MAAMoC,UAAU,GAAGnC,cAAK,CAACoC,MAAN,EAAnB;AAEA,MAAMC,aAAa,GAAGrC,cAAK,CAACsC,WAAN,CAAkB,SAASD,aAAT;AACpC,QAAIF,UAAU,CAACI,OAAX,IAAsB,IAA1B,EAAgC;AAC5BC,MAAAA,YAAY,CAACL,UAAU,CAACI,OAAZ,CAAZ;AACH;AACJ,GAJqB,EAInB,EAJmB,CAAtB;;AAOAvC,EAAAA,cAAK,CAACyC,SAAN,CAAgB;AAAA,WAAMJ,aAAN;AAAA,GAAhB,EAAqC,CAACA,aAAD,CAArC;AAEA,SAAOrC,cAAK,CAACsC,WAAN,CACH,SAASxC,KAAT,CAAe4C,EAAf,EAA+B5C,KAA/B;AACI,WAAO;AACHuC,MAAAA,aAAa;AACbF,MAAAA,UAAU,CAACI,OAAX,GAAqBI,UAAU,CAACD,EAAD,EAAK5C,KAAL,CAA/B;AACH,KAHD;AAIH,GANE,EAOH,CAACuC,aAAD,CAPG,CAAP;AASH;;;;"}
|
package/es/index.js
CHANGED
|
@@ -29,18 +29,14 @@ export { default as DeprecatedButton } from './components/deprecated-button/inde
|
|
|
29
29
|
export { default as Dropdown } from './components/dropdown/index.js';
|
|
30
30
|
export { COLORS } from './components/color-picker/color-picker.js';
|
|
31
31
|
export { default as ColorPicker } from './components/color-picker/index.js';
|
|
32
|
-
export { default as ErrorMessage } from './components/error-message/index.js';
|
|
33
|
-
export { default as Icon } from './components/icon/index.js';
|
|
34
32
|
export { default as Input } from './components/input/index.js';
|
|
35
33
|
export { default as KeyboardShortcut } from './components/keyboard-shortcut/index.js';
|
|
36
34
|
export { SUPPORTED_KEYS } from './components/key-capturer/key-capturer.js';
|
|
37
35
|
export { default as KeyCapturer } from './components/key-capturer/index.js';
|
|
38
36
|
export { default as Popover } from './components/popover/index.js';
|
|
39
37
|
export { default as ProgressBar } from './components/progress-bar/index.js';
|
|
40
|
-
export { default as RangeInput } from './components/range-input/index.js';
|
|
41
38
|
export { default as Select } from './components/select/index.js';
|
|
42
39
|
export { default as Time } from './components/time/index.js';
|
|
43
|
-
export { default as Tip } from './components/tip/index.js';
|
|
44
40
|
export { Notification } from './components/notification/notification.js';
|
|
45
41
|
export { Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu } from './components/menu/menu.js';
|
|
46
42
|
export { default as DeprecatedModal } from './components/deprecated-modal/index.js';
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,6 +6,8 @@ import { Spinner } from '../spinner/spinner.js';
|
|
|
6
6
|
import { Tooltip } from '../../components/tooltip/tooltip.js';
|
|
7
7
|
import styles from './base-button.module.css.js';
|
|
8
8
|
|
|
9
|
+
var _excluded = ["as", "variant", "tone", "size", "disabled", "loading", "tooltip", "onClick", "exceptionallySetClassName", "children", "startIcon", "endIcon", "icon"];
|
|
10
|
+
|
|
9
11
|
function preventDefault(event) {
|
|
10
12
|
event.preventDefault();
|
|
11
13
|
}
|
|
@@ -39,7 +41,7 @@ var BaseButton = /*#__PURE__*/polymorphicComponent(function BaseButton(_ref, ref
|
|
|
39
41
|
startIcon = _ref.startIcon,
|
|
40
42
|
endIcon = _ref.endIcon,
|
|
41
43
|
icon = _ref.icon,
|
|
42
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
44
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
43
45
|
|
|
44
46
|
var isDisabled = loading || disabled;
|
|
45
47
|
var buttonElement = /*#__PURE__*/createElement(Box, Object.assign({}, props, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-button.js","sources":["../../../src/new-components/base-button/base-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Tooltip, TooltipProps } from '../../components/tooltip'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { Box } from '../box'\nimport { Spinner } from '../spinner'\nimport styles from './base-button.module.css'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactChild\n\ntype CommonProps = {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n /**\n * The button's tone.\n * @default 'normal'\n */\n tone?: ButtonTone\n /**\n * The button's size.\n * @default 'normal'\n */\n size?: ButtonSize\n /**\n * Whether the button is disabled or not.\n * @default false\n */\n disabled?: boolean\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n}\n\ntype IconButtonProps = {\n icon: IconElement\n 'aria-label': string\n children?: never\n startIcon?: never\n endIcon?: never\n}\n\ntype LabelledButtonProps = {\n children: NonNullable<React.ReactNode>\n startIcon?: IconElement\n endIcon?: IconElement\n icon?: never\n}\n\nexport type BaseButtonProps = CommonProps & (IconButtonProps | LabelledButtonProps)\n\n/**\n * The component that powers `Button` and `ButtonLink`, where the button styling logic and some\n * common functionality resides. This component is internal to Reactist.\n *\n * 🎨 [Figma](https://www.figma.com/file/LYlWNzvhMDh907l07mPPQk/Product-Web?node-id=4693%3A175143)\n *\n * @see Button\n * @see ButtonLink\n */\nexport const BaseButton = polymorphicComponent<'div', BaseButtonProps>(function BaseButton(\n {\n as = 'div',\n variant,\n tone = 'normal',\n size = 'normal',\n disabled = false,\n loading = false,\n tooltip,\n onClick,\n exceptionallySetClassName,\n children,\n startIcon,\n endIcon,\n icon,\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Box\n {...props}\n as={as}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={[\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n icon ? styles.iconButton : null,\n disabled ? styles.disabled : null,\n ]}\n >\n {icon ? (\n (loading && <Spinner />) || icon\n ) : (\n <>\n {startIcon ? (\n <Box display=\"flex\" className={styles.startIcon} aria-hidden>\n {loading && !endIcon ? <Spinner /> : startIcon}\n </Box>\n ) : null}\n {children ? <span className={styles.label}>{children}</span> : null}\n {endIcon || (loading && !startIcon) ? (\n <Box display=\"flex\" className={styles.endIcon} aria-hidden>\n {loading ? <Spinner /> : endIcon}\n </Box>\n ) : null}\n </>\n )}\n </Box>\n )\n\n // If it's an icon-only button, make sure it uses the aria-label as tooltip if no tooltip was provided\n const tooltipContent = icon ? tooltip ?? props['aria-label'] : tooltip\n return tooltipContent ? (\n <Tooltip content={tooltipContent}>{buttonElement}</Tooltip>\n ) : (\n buttonElement\n )\n})\n"],"names":["preventDefault","event","BaseButton","polymorphicComponent","ref","as","variant","tone","size","disabled","loading","tooltip","onClick","exceptionallySetClassName","children","startIcon","endIcon","icon","props","isDisabled","buttonElement","React","Box","className","styles","baseButton","iconButton","Spinner","display","label","tooltipContent","Tooltip","content"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-button.js","sources":["../../../src/new-components/base-button/base-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Tooltip, TooltipProps } from '../../components/tooltip'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { Box } from '../box'\nimport { Spinner } from '../spinner'\nimport styles from './base-button.module.css'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactChild\n\ntype CommonProps = {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n /**\n * The button's tone.\n * @default 'normal'\n */\n tone?: ButtonTone\n /**\n * The button's size.\n * @default 'normal'\n */\n size?: ButtonSize\n /**\n * Whether the button is disabled or not.\n * @default false\n */\n disabled?: boolean\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n}\n\ntype IconButtonProps = {\n icon: IconElement\n 'aria-label': string\n children?: never\n startIcon?: never\n endIcon?: never\n}\n\ntype LabelledButtonProps = {\n children: NonNullable<React.ReactNode>\n startIcon?: IconElement\n endIcon?: IconElement\n icon?: never\n}\n\nexport type BaseButtonProps = CommonProps & (IconButtonProps | LabelledButtonProps)\n\n/**\n * The component that powers `Button` and `ButtonLink`, where the button styling logic and some\n * common functionality resides. This component is internal to Reactist.\n *\n * 🎨 [Figma](https://www.figma.com/file/LYlWNzvhMDh907l07mPPQk/Product-Web?node-id=4693%3A175143)\n *\n * @see Button\n * @see ButtonLink\n */\nexport const BaseButton = polymorphicComponent<'div', BaseButtonProps>(function BaseButton(\n {\n as = 'div',\n variant,\n tone = 'normal',\n size = 'normal',\n disabled = false,\n loading = false,\n tooltip,\n onClick,\n exceptionallySetClassName,\n children,\n startIcon,\n endIcon,\n icon,\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Box\n {...props}\n as={as}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={[\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n icon ? styles.iconButton : null,\n disabled ? styles.disabled : null,\n ]}\n >\n {icon ? (\n (loading && <Spinner />) || icon\n ) : (\n <>\n {startIcon ? (\n <Box display=\"flex\" className={styles.startIcon} aria-hidden>\n {loading && !endIcon ? <Spinner /> : startIcon}\n </Box>\n ) : null}\n {children ? <span className={styles.label}>{children}</span> : null}\n {endIcon || (loading && !startIcon) ? (\n <Box display=\"flex\" className={styles.endIcon} aria-hidden>\n {loading ? <Spinner /> : endIcon}\n </Box>\n ) : null}\n </>\n )}\n </Box>\n )\n\n // If it's an icon-only button, make sure it uses the aria-label as tooltip if no tooltip was provided\n const tooltipContent = icon ? tooltip ?? props['aria-label'] : tooltip\n return tooltipContent ? (\n <Tooltip content={tooltipContent}>{buttonElement}</Tooltip>\n ) : (\n buttonElement\n )\n})\n"],"names":["preventDefault","event","BaseButton","polymorphicComponent","ref","as","variant","tone","size","disabled","loading","tooltip","onClick","exceptionallySetClassName","children","startIcon","endIcon","icon","props","isDisabled","buttonElement","React","Box","className","styles","baseButton","iconButton","Spinner","display","label","tooltipContent","Tooltip","content"],"mappings":";;;;;;;;;;AAOA,SAASA,cAAT,CAAwBC,KAAxB;AACIA,EAAAA,KAAK,CAACD,cAAN;AACH;AA2DD;;;;;;;;;;;IASaE,UAAU,gBAAGC,oBAAoB,CAAyB,SAASD,UAAT,OAiBnEE,GAjBmE;qBAE/DC;MAAAA,0BAAK;MACLC,eAAAA;uBACAC;MAAAA,8BAAO;uBACPC;MAAAA,8BAAO;2BACPC;MAAAA,sCAAW;0BACXC;MAAAA,oCAAU;MACVC,eAAAA;MACAC,eAAAA;MACAC,iCAAAA;MACAC,gBAAAA;MACAC,iBAAAA;MACAC,eAAAA;MACAC,YAAAA;MACGC;;AAIP,MAAMC,UAAU,GAAGT,OAAO,IAAID,QAA9B;AACA,MAAMW,aAAa,gBACfC,aAAA,CAACC,GAAD,oBACQ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A,CAACU,OAAD;AAASC,IAAAA,OAAO,EAAEF;GAAlB,EAAmCV,aAAnC,CADiB,GAGjBA,aAHJ;AAKH,CAhE6C;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var modules_b9569bce = {"label":"
|
|
1
|
+
var modules_b9569bce = {"label":"_1f20c88a","baseButton":"_623015f3","size-small":"_062de645","size-normal":"_55e2a6a9","size-large":"cab32a7c","disabled":"e71c191a","iconButton":"_368efc16","startIcon":"d35389c1","endIcon":"_900d41d8","variant-primary":"_7c95e162","variant-secondary":"_9cb889aa","variant-tertiary":"_611b5b28","variant-quaternary":"_80c2bb84","tone-destructive":"ee13c455"};
|
|
2
2
|
|
|
3
3
|
export default modules_b9569bce;
|
|
4
4
|
//# sourceMappingURL=base-button.module.css.js.map
|
|
@@ -6,7 +6,9 @@ import { getClassNames } from '../responsive-props.js';
|
|
|
6
6
|
import styles from './box.module.css.js';
|
|
7
7
|
import paddingStyles from './padding.module.css.js';
|
|
8
8
|
import marginStyles from './margin.module.css.js';
|
|
9
|
+
import widthStyles from './width.module.css.js';
|
|
9
10
|
|
|
11
|
+
var _excluded = ["as", "position", "display", "flexDirection", "flexWrap", "flexGrow", "flexShrink", "alignItems", "justifyContent", "overflow", "width", "height", "background", "border", "borderRadius", "minWidth", "maxWidth", "textAlign", "padding", "paddingY", "paddingX", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "margin", "marginY", "marginX", "marginTop", "marginRight", "marginBottom", "marginLeft", "className", "children"];
|
|
10
12
|
var Box = /*#__PURE__*/polymorphicComponent(function Box(_ref, ref) {
|
|
11
13
|
var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
|
|
12
14
|
|
|
@@ -48,7 +50,7 @@ var Box = /*#__PURE__*/polymorphicComponent(function Box(_ref, ref) {
|
|
|
48
50
|
marginLeft = _ref.marginLeft,
|
|
49
51
|
className = _ref.className,
|
|
50
52
|
children = _ref.children,
|
|
51
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
53
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
52
54
|
|
|
53
55
|
var resolvedPaddingTop = (_ref2 = paddingTop !== null && paddingTop !== void 0 ? paddingTop : paddingY) !== null && _ref2 !== void 0 ? _ref2 : padding;
|
|
54
56
|
var resolvedPaddingRight = (_ref3 = paddingRight !== null && paddingRight !== void 0 ? paddingRight : paddingX) !== null && _ref3 !== void 0 ? _ref3 : padding;
|
|
@@ -60,11 +62,11 @@ var Box = /*#__PURE__*/polymorphicComponent(function Box(_ref, ref) {
|
|
|
60
62
|
var resolvedMarginLeft = (_ref9 = marginLeft !== null && marginLeft !== void 0 ? marginLeft : marginX) !== null && _ref9 !== void 0 ? _ref9 : margin;
|
|
61
63
|
var omitFlex = !display || typeof display === 'string' && display !== 'flex' && display !== 'inlineFlex';
|
|
62
64
|
return /*#__PURE__*/createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
63
|
-
className: classNames(className, styles.box, display ? getClassNames(styles, 'display', display) : null, position !== 'static' ? getClassNames(styles, 'position', position) : null, minWidth != null ? getClassNames(
|
|
65
|
+
className: classNames(className, styles.box, display ? getClassNames(styles, 'display', display) : null, position !== 'static' ? getClassNames(styles, 'position', position) : null, minWidth != null ? getClassNames(widthStyles, 'minWidth', String(minWidth)) : null, getClassNames(widthStyles, 'maxWidth', maxWidth), textAlign !== 'start' ? getClassNames(styles, 'textAlign', textAlign) : null, // padding
|
|
64
66
|
getClassNames(paddingStyles, 'paddingTop', resolvedPaddingTop), getClassNames(paddingStyles, 'paddingRight', resolvedPaddingRight), getClassNames(paddingStyles, 'paddingBottom', resolvedPaddingBottom), getClassNames(paddingStyles, 'paddingLeft', resolvedPaddingLeft), // margin
|
|
65
67
|
getClassNames(marginStyles, 'marginTop', resolvedMarginTop), getClassNames(marginStyles, 'marginRight', resolvedMarginRight), getClassNames(marginStyles, 'marginBottom', resolvedMarginBottom), getClassNames(marginStyles, 'marginLeft', resolvedMarginLeft), // flex props
|
|
66
68
|
omitFlex ? null : getClassNames(styles, 'flexDirection', flexDirection), omitFlex ? null : getClassNames(styles, 'flexWrap', flexWrap), omitFlex ? null : getClassNames(styles, 'alignItems', alignItems), omitFlex ? null : getClassNames(styles, 'justifyContent', justifyContent), flexShrink != null ? getClassNames(styles, 'flexShrink', String(flexShrink)) : null, flexGrow != null ? getClassNames(styles, 'flexGrow', String(flexGrow)) : null, // other props
|
|
67
|
-
getClassNames(styles, 'overflow', overflow), getClassNames(
|
|
69
|
+
getClassNames(styles, 'overflow', overflow), width != null ? getClassNames(widthStyles, 'width', String(width)) : null, getClassNames(styles, 'height', height), getClassNames(styles, 'bg', background), borderRadius !== 'none' ? getClassNames(styles, 'borderRadius', borderRadius) : null, border !== 'none' ? getClassNames(styles, 'border', border) : null) || undefined,
|
|
68
70
|
ref: ref
|
|
69
71
|
}), children);
|
|
70
72
|
});
|