@bolio-ui/core 1.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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/avatar/index.js +901 -0
- package/dist/badge/index.js +899 -0
- package/dist/bolio-ui-provider/index.js +1883 -0
- package/dist/breadcrumbs/index.js +985 -0
- package/dist/button/index.js +1358 -0
- package/dist/button-dropdown/index.js +1111 -0
- package/dist/button-group/index.js +782 -0
- package/dist/capacity/index.js +780 -0
- package/dist/card/index.js +1275 -0
- package/dist/checkbox/index.js +1042 -0
- package/dist/code/index.js +803 -0
- package/dist/col/index.js +90 -0
- package/dist/collapse/index.js +1158 -0
- package/dist/container/index.js +444 -0
- package/dist/css-baseline/index.js +348 -0
- package/dist/description/index.js +741 -0
- package/dist/display/index.js +745 -0
- package/dist/divider/index.js +767 -0
- package/dist/dot/index.js +755 -0
- package/dist/drawer/index.js +1513 -0
- package/dist/fieldset/index.js +1089 -0
- package/dist/grid/index.js +870 -0
- package/dist/image/index.js +1094 -0
- package/dist/index.js +9970 -0
- package/dist/input/index.js +1275 -0
- package/dist/keyboard/index.js +711 -0
- package/dist/link/index.js +863 -0
- package/dist/loading/index.js +765 -0
- package/dist/mdx-widgets/index.js +438 -0
- package/dist/modal/index.js +2220 -0
- package/dist/note/index.js +773 -0
- package/dist/page/index.js +928 -0
- package/dist/pagination/index.js +1201 -0
- package/dist/popover/index.js +1502 -0
- package/dist/progress/index.js +804 -0
- package/dist/radio/index.js +1028 -0
- package/dist/rating/index.js +912 -0
- package/dist/row/index.js +442 -0
- package/dist/section/index.js +733 -0
- package/dist/select/index.js +1865 -0
- package/dist/slider/index.js +1097 -0
- package/dist/snippet/index.js +1207 -0
- package/dist/spacer/index.js +692 -0
- package/dist/spinner/index.js +763 -0
- package/dist/styled-jsx.cjs.js +766 -0
- package/dist/tabs/index.js +1125 -0
- package/dist/tag/index.js +749 -0
- package/dist/text/index.js +830 -0
- package/dist/textarea/index.js +915 -0
- package/dist/themes/index.js +319 -0
- package/dist/toggle/index.js +852 -0
- package/dist/tooltip/index.js +1353 -0
- package/dist/use-all-themes/index.js +335 -0
- package/dist/use-body-scroll/index.js +173 -0
- package/dist/use-classes/index.js +55 -0
- package/dist/use-click-away/index.js +28 -0
- package/dist/use-clipboard/index.js +188 -0
- package/dist/use-current-state/index.js +90 -0
- package/dist/use-input/index.js +129 -0
- package/dist/use-keyboard/index.js +214 -0
- package/dist/use-media-query/index.js +495 -0
- package/dist/use-modal/index.js +114 -0
- package/dist/use-scale/index.js +673 -0
- package/dist/use-tabs/index.js +112 -0
- package/dist/use-theme/index.js +333 -0
- package/dist/use-toasts/index.js +236 -0
- package/esm/avatar/avatar-group.js +29 -0
- package/esm/avatar/avatar.js +107 -0
- package/esm/avatar/avatar.skeleton.js +21 -0
- package/esm/avatar/helpers.js +16 -0
- package/esm/avatar/index.js +4 -0
- package/esm/avatar/stories.js +113 -0
- package/esm/badge/badge-anchor.js +70 -0
- package/esm/badge/badge.js +58 -0
- package/esm/badge/index.js +4 -0
- package/esm/badge/stories.js +92 -0
- package/esm/bolio-ui-provider/bolio-ui-provider.js +62 -0
- package/esm/bolio-ui-provider/index.js +2 -0
- package/esm/bolio-ui-provider/theme-provider.js +47 -0
- package/esm/breadcrumbs/breadcrumbs-item.js +49 -0
- package/esm/breadcrumbs/breadcrumbs-separator.js +25 -0
- package/esm/breadcrumbs/breadcrumbs.js +47 -0
- package/esm/breadcrumbs/index.js +6 -0
- package/esm/breadcrumbs/stories.js +51 -0
- package/esm/button/button-icon.js +29 -0
- package/esm/button/button-loading.js +17 -0
- package/esm/button/button.drip.js +57 -0
- package/esm/button/button.js +146 -0
- package/esm/button/index.js +2 -0
- package/esm/button/stories.js +221 -0
- package/esm/button/styles.js +232 -0
- package/esm/button/utils.js +46 -0
- package/esm/button-dropdown/button-dropdown-context.js +11 -0
- package/esm/button-dropdown/button-dropdown-item.js +52 -0
- package/esm/button-dropdown/button-dropdown.js +111 -0
- package/esm/button-dropdown/icon.js +30 -0
- package/esm/button-dropdown/index.js +4 -0
- package/esm/button-dropdown/stories.js +92 -0
- package/esm/button-dropdown/styles.js +60 -0
- package/esm/button-group/button-group-context.js +9 -0
- package/esm/button-group/button-group.js +75 -0
- package/esm/button-group/index.js +2 -0
- package/esm/button-group/stories.js +66 -0
- package/esm/capacity/capacity.js +52 -0
- package/esm/capacity/index.js +2 -0
- package/esm/capacity/stories.js +55 -0
- package/esm/card/card-content.js +28 -0
- package/esm/card/card-footer.js +36 -0
- package/esm/card/card.js +68 -0
- package/esm/card/index.js +8 -0
- package/esm/card/stories.js +126 -0
- package/esm/card/styles.js +45 -0
- package/esm/checkbox/checkbox-context.js +10 -0
- package/esm/checkbox/checkbox-group.js +70 -0
- package/esm/checkbox/checkbox.icon.js +50 -0
- package/esm/checkbox/checkbox.js +114 -0
- package/esm/checkbox/index.js +4 -0
- package/esm/checkbox/stories.js +84 -0
- package/esm/checkbox/styles.js +34 -0
- package/esm/code/code.js +57 -0
- package/esm/code/index.js +2 -0
- package/esm/code/stories.js +53 -0
- package/esm/col/col.js +29 -0
- package/esm/col/index.js +2 -0
- package/esm/collapse/collapse-context.js +8 -0
- package/esm/collapse/collapse-group.js +75 -0
- package/esm/collapse/collapse-icon.js +28 -0
- package/esm/collapse/collapse.js +93 -0
- package/esm/collapse/index.js +4 -0
- package/esm/collapse/stories.js +48 -0
- package/esm/container/container.js +62 -0
- package/esm/container/index.js +2 -0
- package/esm/css-baseline/css-baseline.js +18 -0
- package/esm/css-baseline/index.js +1 -0
- package/esm/description/description.js +39 -0
- package/esm/description/index.js +2 -0
- package/esm/description/stories.js +23 -0
- package/esm/display/display.js +43 -0
- package/esm/display/index.js +2 -0
- package/esm/divider/divider.js +65 -0
- package/esm/divider/index.js +2 -0
- package/esm/divider/stories.js +41 -0
- package/esm/dot/dot.js +53 -0
- package/esm/dot/index.js +2 -0
- package/esm/dot/stories.js +40 -0
- package/esm/drawer/drawer-wrapper.js +86 -0
- package/esm/drawer/drawer.js +77 -0
- package/esm/drawer/helper.js +27 -0
- package/esm/drawer/index.js +8 -0
- package/esm/drawer/stories.js +79 -0
- package/esm/fieldset/fieldset-content.js +29 -0
- package/esm/fieldset/fieldset-context.js +9 -0
- package/esm/fieldset/fieldset-footer.js +30 -0
- package/esm/fieldset/fieldset-group.js +88 -0
- package/esm/fieldset/fieldset-subtitle.js +21 -0
- package/esm/fieldset/fieldset-title.js +23 -0
- package/esm/fieldset/fieldset.js +96 -0
- package/esm/fieldset/index.js +13 -0
- package/esm/fieldset/stories.js +72 -0
- package/esm/grid/basic-item.js +96 -0
- package/esm/grid/grid-container.js +46 -0
- package/esm/grid/grid-types.js +6 -0
- package/esm/grid/grid.js +37 -0
- package/esm/grid/index.js +4 -0
- package/esm/grid/stories.js +212 -0
- package/esm/icon/stories.js +36 -0
- package/esm/image/helpers.js +16 -0
- package/esm/image/image-browser-https-icon.js +23 -0
- package/esm/image/image-browser.js +86 -0
- package/esm/image/image.js +91 -0
- package/esm/image/image.skeleton.js +21 -0
- package/esm/image/index.js +4 -0
- package/esm/image/stories.js +73 -0
- package/esm/image/styles.js +15 -0
- package/esm/index.js +69 -0
- package/esm/input/index.js +6 -0
- package/esm/input/input-block-label.js +18 -0
- package/esm/input/input-icon-clear.js +47 -0
- package/esm/input/input-icon.js +19 -0
- package/esm/input/input-label.js +18 -0
- package/esm/input/input-props.js +12 -0
- package/esm/input/input.js +179 -0
- package/esm/input/password-icon.js +30 -0
- package/esm/input/password.js +66 -0
- package/esm/input/stories.js +113 -0
- package/esm/input/styles.js +41 -0
- package/esm/keyboard/index.js +2 -0
- package/esm/keyboard/keyboard.js +48 -0
- package/esm/keyboard/stories.js +43 -0
- package/esm/link/icon.js +30 -0
- package/esm/link/index.js +2 -0
- package/esm/link/link.js +50 -0
- package/esm/link/stories.js +59 -0
- package/esm/loading/index.js +2 -0
- package/esm/loading/loading.js +63 -0
- package/esm/loading/stories.js +75 -0
- package/esm/mdx-widgets/index.js +2 -0
- package/esm/mdx-widgets/mock-page.js +37 -0
- package/esm/mdx-widgets/parsed-codes/index.js +1 -0
- package/esm/mdx-widgets/parsed-codes/wait-time.js +13 -0
- package/esm/modal/index.js +10 -0
- package/esm/modal/modal-action.js +76 -0
- package/esm/modal/modal-actions.js +39 -0
- package/esm/modal/modal-content.js +28 -0
- package/esm/modal/modal-context.js +6 -0
- package/esm/modal/modal-subtitle.js +30 -0
- package/esm/modal/modal-title.js +30 -0
- package/esm/modal/modal-wrapper.js +80 -0
- package/esm/modal/modal.js +104 -0
- package/esm/modal/stories.js +165 -0
- package/esm/note/index.js +2 -0
- package/esm/note/note.js +71 -0
- package/esm/note/stories.js +68 -0
- package/esm/page/index.js +9 -0
- package/esm/page/page-content.js +26 -0
- package/esm/page/page-footer.js +25 -0
- package/esm/page/page-header.js +33 -0
- package/esm/page/page.js +88 -0
- package/esm/page/stories.js +54 -0
- package/esm/pagination/index.js +6 -0
- package/esm/pagination/pagination-context.js +8 -0
- package/esm/pagination/pagination-ellipsis.js +73 -0
- package/esm/pagination/pagination-item.js +50 -0
- package/esm/pagination/pagination-next.js +25 -0
- package/esm/pagination/pagination-pages.js +90 -0
- package/esm/pagination/pagination-previous.js +25 -0
- package/esm/pagination/pagination.js +105 -0
- package/esm/pagination/stories.js +49 -0
- package/esm/popover/index.js +5 -0
- package/esm/popover/popover-context.js +9 -0
- package/esm/popover/popover-item.js +65 -0
- package/esm/popover/popover.js +83 -0
- package/esm/popover/stories.js +84 -0
- package/esm/progress/index.js +2 -0
- package/esm/progress/progress.js +76 -0
- package/esm/progress/stories.js +114 -0
- package/esm/radio/index.js +7 -0
- package/esm/radio/radio-context.js +9 -0
- package/esm/radio/radio-description.js +30 -0
- package/esm/radio/radio-group.js +61 -0
- package/esm/radio/radio.js +123 -0
- package/esm/radio/stories.js +98 -0
- package/esm/radio/styles.js +41 -0
- package/esm/rating/index.js +2 -0
- package/esm/rating/rating-icon.js +20 -0
- package/esm/rating/rating.js +115 -0
- package/esm/rating/stories.js +72 -0
- package/esm/row/index.js +2 -0
- package/esm/row/row.js +60 -0
- package/esm/section/index.js +2 -0
- package/esm/section/section.js +30 -0
- package/esm/select/index.js +4 -0
- package/esm/select/select-context.js +9 -0
- package/esm/select/select-dropdown.js +41 -0
- package/esm/select/select-icon-clear.js +41 -0
- package/esm/select/select-icon.js +23 -0
- package/esm/select/select-input.js +34 -0
- package/esm/select/select-multiple-value.js +23 -0
- package/esm/select/select-option.js +100 -0
- package/esm/select/select.js +244 -0
- package/esm/select/stories.js +239 -0
- package/esm/select/styles.js +48 -0
- package/esm/shared/backdrop.js +77 -0
- package/esm/shared/css-transition.js +71 -0
- package/esm/shared/dropdown.js +109 -0
- package/esm/shared/ellipsis.js +15 -0
- package/esm/shared/expand.js +95 -0
- package/esm/shared/highlight.js +47 -0
- package/esm/slider/index.js +2 -0
- package/esm/slider/slider-dot.js +27 -0
- package/esm/slider/slider-mark.js +38 -0
- package/esm/slider/slider.js +163 -0
- package/esm/slider/stories.js +134 -0
- package/esm/slider/styles.js +27 -0
- package/esm/snippet/index.js +2 -0
- package/esm/snippet/snippet-icon.js +27 -0
- package/esm/snippet/snippet.js +100 -0
- package/esm/snippet/stories.js +133 -0
- package/esm/snippet/styles.js +58 -0
- package/esm/spacer/index.js +2 -0
- package/esm/spacer/spacer.js +28 -0
- package/esm/spacer/stories.js +54 -0
- package/esm/spinner/index.js +2 -0
- package/esm/spinner/spinner.js +46 -0
- package/esm/spinner/stories.js +13 -0
- package/esm/styled-jsx-server.es.js +5 -0
- package/esm/styled-jsx.es.js +757 -0
- package/esm/tabs/index.js +5 -0
- package/esm/tabs/stories.js +92 -0
- package/esm/tabs/tabs-context.js +8 -0
- package/esm/tabs/tabs-item.js +80 -0
- package/esm/tabs/tabs.js +151 -0
- package/esm/tag/index.js +2 -0
- package/esm/tag/stories.js +58 -0
- package/esm/tag/tag.js +86 -0
- package/esm/text/child.js +78 -0
- package/esm/text/index.js +2 -0
- package/esm/text/stories.js +104 -0
- package/esm/text/text.js +94 -0
- package/esm/textarea/index.js +2 -0
- package/esm/textarea/stories.js +104 -0
- package/esm/textarea/textarea.js +116 -0
- package/esm/themes/index.js +2 -0
- package/esm/themes/presets/dark.js +67 -0
- package/esm/themes/presets/default.js +67 -0
- package/esm/themes/presets/index.js +1 -0
- package/esm/themes/presets/shared.js +42 -0
- package/esm/themes/themes.js +89 -0
- package/esm/toggle/index.js +2 -0
- package/esm/toggle/stories.js +55 -0
- package/esm/toggle/styles.js +27 -0
- package/esm/toggle/toggle.js +82 -0
- package/esm/tooltip/helper.js +21 -0
- package/esm/tooltip/index.js +2 -0
- package/esm/tooltip/placement.js +160 -0
- package/esm/tooltip/stories.js +183 -0
- package/esm/tooltip/styles.js +18 -0
- package/esm/tooltip/tooltip-content.js +83 -0
- package/esm/tooltip/tooltip-icon.js +32 -0
- package/esm/tooltip/tooltip.js +132 -0
- package/esm/use-all-themes/all-themes-context.js +9 -0
- package/esm/use-all-themes/index.js +2 -0
- package/esm/use-body-scroll/index.js +2 -0
- package/esm/use-body-scroll/use-body-scroll.js +70 -0
- package/esm/use-classes/index.js +2 -0
- package/esm/use-classes/use-classes.js +41 -0
- package/esm/use-click-away/index.js +2 -0
- package/esm/use-click-away/use-click-away.js +22 -0
- package/esm/use-clipboard/index.js +2 -0
- package/esm/use-clipboard/use-clipboard.js +46 -0
- package/esm/use-current-state/index.js +2 -0
- package/esm/use-current-state/use-current-state.js +26 -0
- package/esm/use-input/index.js +2 -0
- package/esm/use-input/use-input.js +32 -0
- package/esm/use-keyboard/codes.js +97 -0
- package/esm/use-keyboard/helper.js +26 -0
- package/esm/use-keyboard/index.js +4 -0
- package/esm/use-keyboard/use-keyboard.js +79 -0
- package/esm/use-media-query/index.js +2 -0
- package/esm/use-media-query/use-media-query.js +90 -0
- package/esm/use-modal/index.js +2 -0
- package/esm/use-modal/use-modal.js +26 -0
- package/esm/use-scale/index.js +6 -0
- package/esm/use-scale/scale-context.js +37 -0
- package/esm/use-scale/utils.js +62 -0
- package/esm/use-scale/with-scale.js +114 -0
- package/esm/use-tabs/index.js +2 -0
- package/esm/use-tabs/use-tabs.js +24 -0
- package/esm/use-theme/index.js +2 -0
- package/esm/use-theme/theme-context.js +7 -0
- package/esm/use-toasts/helpers.js +72 -0
- package/esm/use-toasts/index.js +2 -0
- package/esm/use-toasts/toast-container.js +127 -0
- package/esm/use-toasts/toast-item.js +48 -0
- package/esm/use-toasts/use-toast.js +124 -0
- package/esm/utils/calculations.js +27 -0
- package/esm/utils/collections.js +138 -0
- package/esm/utils/color.js +43 -0
- package/esm/utils/layouts.js +82 -0
- package/esm/utils/prop-types.js +22 -0
- package/esm/utils/types.js +1 -0
- package/esm/utils/use-body-scroll.js +2 -0
- package/esm/utils/use-bolio-ui-context.js +27 -0
- package/esm/utils/use-click-anywhere.js +16 -0
- package/esm/utils/use-click-away.js +2 -0
- package/esm/utils/use-clipboard.js +2 -0
- package/esm/utils/use-context-state/create-bolio-ui-context.js +57 -0
- package/esm/utils/use-context-state/use-context-state.js +44 -0
- package/esm/utils/use-current-state.js +2 -0
- package/esm/utils/use-default-props.js +22 -0
- package/esm/utils/use-dom-observer.js +28 -0
- package/esm/utils/use-drag.js +75 -0
- package/esm/utils/use-portal.js +40 -0
- package/esm/utils/use-previous.js +11 -0
- package/esm/utils/use-real-shape.js +53 -0
- package/esm/utils/use-resize.js +21 -0
- package/esm/utils/use-ssr.js +20 -0
- package/esm/utils/use-warning.js +17 -0
- package/package.json +140 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children", "bg", "className"];
|
|
4
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import useScale, { withScale } from '../use-scale';
|
|
7
|
+
import useClasses from '../use-classes';
|
|
8
|
+
|
|
9
|
+
function SectionComponent(_ref) {
|
|
10
|
+
var children = _ref.children,
|
|
11
|
+
_ref$bg = _ref.bg,
|
|
12
|
+
bg = _ref$bg === void 0 ? 'transparent' : _ref$bg,
|
|
13
|
+
_ref$className = _ref.className,
|
|
14
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
|
|
17
|
+
var _useScale = useScale(),
|
|
18
|
+
SCALES = _useScale.SCALES;
|
|
19
|
+
|
|
20
|
+
return /*#__PURE__*/React.createElement("section", _extends({}, props, {
|
|
21
|
+
className: _JSXStyle.dynamic([["1871933825", [bg, SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0)]]]) + " " + (props && props.className != null && props.className || useClasses('section', className) || "")
|
|
22
|
+
}), children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
23
|
+
id: "1871933825",
|
|
24
|
+
dynamic: [bg, SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0)]
|
|
25
|
+
}, "section.__jsx-style-dynamic-selector{background-color:".concat(bg, ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}")));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
SectionComponent.displayName = 'BolioUISection';
|
|
29
|
+
var Section = withScale(SectionComponent);
|
|
30
|
+
export default Section;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var defaultContext = {
|
|
3
|
+
visible: false,
|
|
4
|
+
disableAll: false
|
|
5
|
+
};
|
|
6
|
+
export var SelectContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
7
|
+
export var useSelectContext = function useSelectContext() {
|
|
8
|
+
return React.useContext(SelectContext);
|
|
9
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
2
|
+
import React, { useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import useTheme from '../use-theme';
|
|
4
|
+
import { useSelectContext } from './select-context';
|
|
5
|
+
import Dropdown from '../shared/dropdown';
|
|
6
|
+
import useClasses from '../use-classes';
|
|
7
|
+
var SelectDropdown = /*#__PURE__*/React.forwardRef(function (_ref, dropdownRef) {
|
|
8
|
+
var visible = _ref.visible,
|
|
9
|
+
children = _ref.children,
|
|
10
|
+
_ref$className = _ref.className,
|
|
11
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
12
|
+
_ref$dropdownStyle = _ref.dropdownStyle,
|
|
13
|
+
dropdownStyle = _ref$dropdownStyle === void 0 ? {} : _ref$dropdownStyle,
|
|
14
|
+
disableMatchWidth = _ref.disableMatchWidth,
|
|
15
|
+
getPopupContainer = _ref.getPopupContainer;
|
|
16
|
+
var theme = useTheme();
|
|
17
|
+
var internalDropdownRef = useRef(null);
|
|
18
|
+
|
|
19
|
+
var _useSelectContext = useSelectContext(),
|
|
20
|
+
ref = _useSelectContext.ref;
|
|
21
|
+
|
|
22
|
+
var classes = useClasses('select-dropdown', className);
|
|
23
|
+
useImperativeHandle(dropdownRef, function () {
|
|
24
|
+
return internalDropdownRef.current;
|
|
25
|
+
});
|
|
26
|
+
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
27
|
+
parent: ref,
|
|
28
|
+
visible: visible,
|
|
29
|
+
disableMatchWidth: disableMatchWidth,
|
|
30
|
+
getPopupContainer: getPopupContainer
|
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
ref: internalDropdownRef,
|
|
33
|
+
style: dropdownStyle,
|
|
34
|
+
className: _JSXStyle.dynamic([["2782510679", [theme.layout.radius, theme.expressiveness.shadowLarge, theme.palette.background]]]) + " " + (classes || "")
|
|
35
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
36
|
+
id: "2782510679",
|
|
37
|
+
dynamic: [theme.layout.radius, theme.expressiveness.shadowLarge, theme.palette.background]
|
|
38
|
+
}, ".select-dropdown.__jsx-style-dynamic-selector{border-radius:".concat(theme.layout.radius, ";box-shadow:").concat(theme.expressiveness.shadowLarge, ";background-color:").concat(theme.palette.background, ";max-height:17em;overflow-y:auto;overflow-anchor:none;padding:0.38em 0;-webkit-scroll-behavior:smooth;-moz-scroll-behavior:smooth;-ms-scroll-behavior:smooth;scroll-behavior:smooth;}"))));
|
|
39
|
+
});
|
|
40
|
+
SelectDropdown.displayName = 'BolioUISelectDropdown';
|
|
41
|
+
export default SelectDropdown;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import useTheme from '../use-theme';
|
|
4
|
+
|
|
5
|
+
function SelectIconClear(_ref) {
|
|
6
|
+
var onClick = _ref.onClick;
|
|
7
|
+
var theme = useTheme();
|
|
8
|
+
|
|
9
|
+
var clickHandler = function clickHandler(event) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
13
|
+
onClick && onClick(event);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
onClick: clickHandler,
|
|
18
|
+
className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]]) + " " + "clear-icon"
|
|
19
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
20
|
+
viewBox: "0 0 24 24",
|
|
21
|
+
stroke: "currentColor",
|
|
22
|
+
strokeWidth: "1.5",
|
|
23
|
+
strokeLinecap: "round",
|
|
24
|
+
strokeLinejoin: "round",
|
|
25
|
+
fill: "none",
|
|
26
|
+
shapeRendering: "geometricPrecision",
|
|
27
|
+
className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]])
|
|
28
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
29
|
+
d: "M18 6L6 18",
|
|
30
|
+
className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]])
|
|
31
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
32
|
+
d: "M6 6l12 12",
|
|
33
|
+
className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]])
|
|
34
|
+
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
35
|
+
id: "1984024521",
|
|
36
|
+
dynamic: [theme.palette.accents_3, theme.palette.foreground]
|
|
37
|
+
}, ".clear-icon.__jsx-style-dynamic-selector{padding:0 0 0 0.5em;margin:0;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%;cursor:pointer;box-sizing:border-box;-webkit-transition:color 150ms ease 0s;transition:color 150ms ease 0s;color:".concat(theme.palette.accents_3, ";visibility:visible;opacity:1;}.clear-icon.__jsx-style-dynamic-selector:hover{color:").concat(theme.palette.foreground, ";}svg.__jsx-style-dynamic-selector{color:currentColor;width:1em;height:1em;}")));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var MemoSelectIconClear = /*#__PURE__*/React.memo(SelectIconClear);
|
|
41
|
+
export default MemoSelectIconClear;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
function SelectIconComponent() {
|
|
5
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
strokeWidth: "1",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
fill: "none",
|
|
11
|
+
shapeRendering: "geometricPrecision",
|
|
12
|
+
className: "jsx-2742933678"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
14
|
+
d: "M6 9l6 6 6-6",
|
|
15
|
+
className: "jsx-2742933678"
|
|
16
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
17
|
+
id: "2742933678"
|
|
18
|
+
}, "svg.jsx-2742933678{color:inherit;stroke:currentColor;-webkit-transition:all 200ms ease;transition:all 200ms ease;width:1.214em;height:1.214em;}"));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
SelectIconComponent.displayName = 'BolioUISelectIcon';
|
|
22
|
+
var SelectIcon = /*#__PURE__*/React.memo(SelectIconComponent);
|
|
23
|
+
export default SelectIcon;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
2
|
+
import React, { useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
var SelectInput = /*#__PURE__*/React.forwardRef(function (_ref, inputRef) {
|
|
4
|
+
var visible = _ref.visible,
|
|
5
|
+
onBlur = _ref.onBlur,
|
|
6
|
+
onFocus = _ref.onFocus;
|
|
7
|
+
var ref = useRef(null);
|
|
8
|
+
useImperativeHandle(inputRef, function () {
|
|
9
|
+
return ref.current;
|
|
10
|
+
});
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
if (visible) {
|
|
13
|
+
var _ref$current;
|
|
14
|
+
|
|
15
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
|
16
|
+
}
|
|
17
|
+
}, [visible]);
|
|
18
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
19
|
+
ref: ref,
|
|
20
|
+
type: "search",
|
|
21
|
+
role: "combobox",
|
|
22
|
+
"aria-haspopup": "listbox",
|
|
23
|
+
readOnly: true,
|
|
24
|
+
unselectable: "on",
|
|
25
|
+
"aria-expanded": visible,
|
|
26
|
+
onBlur: onBlur,
|
|
27
|
+
onFocus: onFocus,
|
|
28
|
+
className: "jsx-2813108835"
|
|
29
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
30
|
+
id: "2813108835"
|
|
31
|
+
}, "input.jsx-2813108835{position:fixed;top:-10000px;left:-10000px;opacity:0;z-index:-1;width:0;height:0;padding:0;font-size:0;border:none;}"));
|
|
32
|
+
});
|
|
33
|
+
SelectInput.displayName = 'BolioUISelectInput';
|
|
34
|
+
export default SelectInput;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import useTheme from '../use-theme';
|
|
4
|
+
import Grid from '../grid';
|
|
5
|
+
import SelectClearIcon from './select-icon-clear';
|
|
6
|
+
|
|
7
|
+
function SelectMultipleValue(_ref) {
|
|
8
|
+
var disabled = _ref.disabled,
|
|
9
|
+
onClear = _ref.onClear,
|
|
10
|
+
children = _ref.children;
|
|
11
|
+
var theme = useTheme();
|
|
12
|
+
return /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: _JSXStyle.dynamic([["1576722377", [theme.layout.radius, theme.palette.accents_2, disabled ? theme.palette.accents_4 : theme.palette.accents_6]]]) + " " + "item"
|
|
14
|
+
}, children, !!onClear && /*#__PURE__*/React.createElement(SelectClearIcon, {
|
|
15
|
+
onClick: onClear
|
|
16
|
+
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
17
|
+
id: "1576722377",
|
|
18
|
+
dynamic: [theme.layout.radius, theme.palette.accents_2, disabled ? theme.palette.accents_4 : theme.palette.accents_6]
|
|
19
|
+
}, ".item.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;justify-items:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:1;padding:0 0.5em;font-size:var(--select-font-size);height:calc(var(--select-font-size) * 2);border-radius:".concat(theme.layout.radius, ";background-color:").concat(theme.palette.accents_2, ";color:").concat(disabled ? theme.palette.accents_4 : theme.palette.accents_6, ";}.item.__jsx-style-dynamic-selector>div:not(.clear-icon),.item.__jsx-style-dynamic-selector>div:not(.clear-icon):hover{border-radius:0;background-color:transparent;padding:0;margin:0;color:inherit;}")));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
SelectMultipleValue.displayName = 'BolioUISelectMultipleValue';
|
|
23
|
+
export default SelectMultipleValue;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["value", "className", "children", "disabled", "divider", "label", "preventAllEvents"];
|
|
4
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
import useTheme from '../use-theme';
|
|
7
|
+
import { useSelectContext } from './select-context';
|
|
8
|
+
import useWarning from '../utils/use-warning';
|
|
9
|
+
import Ellipsis from '../shared/ellipsis';
|
|
10
|
+
import useScale, { withScale } from '../use-scale';
|
|
11
|
+
import useClasses from '../use-classes';
|
|
12
|
+
|
|
13
|
+
function SelectOptionComponent(_ref) {
|
|
14
|
+
var _ref$value = _ref.value,
|
|
15
|
+
identValue = _ref$value === void 0 ? '' : _ref$value,
|
|
16
|
+
_ref$className = _ref.className,
|
|
17
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
18
|
+
children = _ref.children,
|
|
19
|
+
_ref$disabled = _ref.disabled,
|
|
20
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
21
|
+
_ref$divider = _ref.divider,
|
|
22
|
+
divider = _ref$divider === void 0 ? false : _ref$divider,
|
|
23
|
+
_ref$label = _ref.label,
|
|
24
|
+
label = _ref$label === void 0 ? false : _ref$label,
|
|
25
|
+
_ref$preventAllEvents = _ref.preventAllEvents,
|
|
26
|
+
preventAllEvents = _ref$preventAllEvents === void 0 ? false : _ref$preventAllEvents,
|
|
27
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
|
|
29
|
+
var theme = useTheme();
|
|
30
|
+
|
|
31
|
+
var _useScale = useScale(),
|
|
32
|
+
SCALES = _useScale.SCALES;
|
|
33
|
+
|
|
34
|
+
var _useSelectContext = useSelectContext(),
|
|
35
|
+
updateValue = _useSelectContext.updateValue,
|
|
36
|
+
value = _useSelectContext.value,
|
|
37
|
+
disableAll = _useSelectContext.disableAll;
|
|
38
|
+
|
|
39
|
+
var isDisabled = useMemo(function () {
|
|
40
|
+
return disabled || disableAll;
|
|
41
|
+
}, [disabled, disableAll]);
|
|
42
|
+
var isLabel = useMemo(function () {
|
|
43
|
+
return label || divider;
|
|
44
|
+
}, [label, divider]);
|
|
45
|
+
var classes = useClasses('option', {
|
|
46
|
+
divider: divider,
|
|
47
|
+
label: label
|
|
48
|
+
}, className);
|
|
49
|
+
|
|
50
|
+
if (!isLabel && identValue === undefined) {
|
|
51
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
52
|
+
useWarning('The props "value" is required.', 'Select Option');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var selected = useMemo(function () {
|
|
56
|
+
if (!value) return false;
|
|
57
|
+
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
return identValue === value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return value.includes("".concat(identValue));
|
|
63
|
+
}, [identValue, value]);
|
|
64
|
+
var bgColor = useMemo(function () {
|
|
65
|
+
if (isDisabled) return theme.palette.accents_1;
|
|
66
|
+
return selected ? theme.palette.accents_2 : theme.palette.background;
|
|
67
|
+
}, [selected, isDisabled, theme.palette]);
|
|
68
|
+
var hoverBgColor = useMemo(function () {
|
|
69
|
+
if (isDisabled || isLabel || selected) return bgColor;
|
|
70
|
+
return theme.palette.accents_1;
|
|
71
|
+
}, [selected, isDisabled, theme.palette, isLabel, bgColor]);
|
|
72
|
+
var color = useMemo(function () {
|
|
73
|
+
if (isDisabled) return theme.palette.accents_4;
|
|
74
|
+
return selected ? theme.palette.foreground : theme.palette.accents_5;
|
|
75
|
+
}, [selected, isDisabled, theme.palette]);
|
|
76
|
+
|
|
77
|
+
var clickHandler = function clickHandler(event) {
|
|
78
|
+
if (preventAllEvents) return;
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
if (isDisabled || isLabel) return;
|
|
83
|
+
updateValue && updateValue(identValue);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
87
|
+
onClick: clickHandler
|
|
88
|
+
}, props, {
|
|
89
|
+
className: _JSXStyle.dynamic([["1707413548", [bgColor, color, isDisabled ? 'not-allowed' : 'pointer', SCALES.font(0.75), SCALES.width(1, '100%'), SCALES.height(2.25), SCALES.pt(0), SCALES.pr(0.667), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hoverBgColor, theme.palette.accents_7, theme.palette.border, SCALES.width(1, '100%'), SCALES.height(1, 0), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0.5), SCALES.mr(0), SCALES.mb(0.5), SCALES.ml(0), theme.palette.accents_7, theme.palette.border, SCALES.font(0.875), SCALES.width(1, '100%')]]]) + " " + (props && props.className != null && props.className || classes || "")
|
|
90
|
+
}), /*#__PURE__*/React.createElement(Ellipsis, {
|
|
91
|
+
height: SCALES.height(2.25)
|
|
92
|
+
}, children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
93
|
+
id: "1707413548",
|
|
94
|
+
dynamic: [bgColor, color, isDisabled ? 'not-allowed' : 'pointer', SCALES.font(0.75), SCALES.width(1, '100%'), SCALES.height(2.25), SCALES.pt(0), SCALES.pr(0.667), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hoverBgColor, theme.palette.accents_7, theme.palette.border, SCALES.width(1, '100%'), SCALES.height(1, 0), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0.5), SCALES.mr(0), SCALES.mb(0.5), SCALES.ml(0), theme.palette.accents_7, theme.palette.border, SCALES.font(0.875), SCALES.width(1, '100%')]
|
|
95
|
+
}, ".option.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;max-width:100%;box-sizing:border-box;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-weight:normal;background-color:".concat(bgColor, ";color:").concat(color, ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:0;cursor:").concat(isDisabled ? 'not-allowed' : 'pointer', ";-webkit-transition:background 0.2s ease 0s,border-color 0.2s ease 0s;transition:background 0.2s ease 0s,border-color 0.2s ease 0s;--select-font-size:").concat(SCALES.font(0.75), ";font-size:var(--select-font-size);width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(2.25), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0.667), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0.667), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.option.__jsx-style-dynamic-selector:hover{background-color:").concat(hoverBgColor, ";color:").concat(theme.palette.accents_7, ";}.divider.__jsx-style-dynamic-selector{line-height:0;overflow:hidden;border-top:1px solid ").concat(theme.palette.border, ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, 0), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0.5), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0.5), " ").concat(SCALES.ml(0), ";}.label.__jsx-style-dynamic-selector{color:").concat(theme.palette.accents_7, ";border-bottom:1px solid ").concat(theme.palette.border, ";text-transform:capitalize;cursor:default;font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, '100%'), ";font-weight:500;}")));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
SelectOptionComponent.displayName = 'BolioUISelectOption';
|
|
99
|
+
var SelectOption = withScale(SelectOptionComponent);
|
|
100
|
+
export default SelectOption;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["children", "type", "disabled", "initialValue", "value", "icon", "onChange", "pure", "multiple", "clearable", "placeholder", "className", "dropdownClassName", "dropdownStyle", "disableMatchWidth", "getPopupContainer", "onDropdownVisibleChange"];
|
|
6
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
7
|
+
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import useTheme from '../use-theme';
|
|
9
|
+
import useCurrentState from '../utils/use-current-state';
|
|
10
|
+
import { pickChildByProps } from '../utils/collections';
|
|
11
|
+
import SelectIcon from './select-icon';
|
|
12
|
+
import SelectDropdown from './select-dropdown';
|
|
13
|
+
import SelectMultipleValue from './select-multiple-value';
|
|
14
|
+
import Grid from '../grid';
|
|
15
|
+
import { SelectContext } from './select-context';
|
|
16
|
+
import { getColors } from './styles';
|
|
17
|
+
import Ellipsis from '../shared/ellipsis';
|
|
18
|
+
import SelectInput from './select-input';
|
|
19
|
+
import useScale, { withScale } from '../use-scale';
|
|
20
|
+
import useClasses from '../use-classes';
|
|
21
|
+
var defaultProps = {
|
|
22
|
+
disabled: false,
|
|
23
|
+
type: 'default',
|
|
24
|
+
icon: SelectIcon,
|
|
25
|
+
pure: false,
|
|
26
|
+
multiple: false,
|
|
27
|
+
clearable: true,
|
|
28
|
+
className: '',
|
|
29
|
+
disableMatchWidth: false,
|
|
30
|
+
onDropdownVisibleChange: function onDropdownVisibleChange() {}
|
|
31
|
+
};
|
|
32
|
+
var SelectComponent = /*#__PURE__*/React.forwardRef(function (_ref, selectRef) {
|
|
33
|
+
var children = _ref.children,
|
|
34
|
+
_ref$type = _ref.type,
|
|
35
|
+
type = _ref$type === void 0 ? 'default' : _ref$type,
|
|
36
|
+
_ref$disabled = _ref.disabled,
|
|
37
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
38
|
+
init = _ref.initialValue,
|
|
39
|
+
customValue = _ref.value,
|
|
40
|
+
_ref$icon = _ref.icon,
|
|
41
|
+
Icon = _ref$icon === void 0 ? SelectIcon : _ref$icon,
|
|
42
|
+
onChange = _ref.onChange,
|
|
43
|
+
_ref$pure = _ref.pure,
|
|
44
|
+
pure = _ref$pure === void 0 ? false : _ref$pure,
|
|
45
|
+
_ref$multiple = _ref.multiple,
|
|
46
|
+
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
47
|
+
_ref$clearable = _ref.clearable,
|
|
48
|
+
clearable = _ref$clearable === void 0 ? true : _ref$clearable,
|
|
49
|
+
placeholder = _ref.placeholder,
|
|
50
|
+
_ref$className = _ref.className,
|
|
51
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
52
|
+
dropdownClassName = _ref.dropdownClassName,
|
|
53
|
+
dropdownStyle = _ref.dropdownStyle,
|
|
54
|
+
_ref$disableMatchWidt = _ref.disableMatchWidth,
|
|
55
|
+
disableMatchWidth = _ref$disableMatchWidt === void 0 ? false : _ref$disableMatchWidt,
|
|
56
|
+
getPopupContainer = _ref.getPopupContainer,
|
|
57
|
+
_ref$onDropdownVisibl = _ref.onDropdownVisibleChange,
|
|
58
|
+
onDropdownVisibleChange = _ref$onDropdownVisibl === void 0 ? function () {} : _ref$onDropdownVisibl,
|
|
59
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
60
|
+
|
|
61
|
+
var theme = useTheme();
|
|
62
|
+
|
|
63
|
+
var _useScale = useScale(),
|
|
64
|
+
SCALES = _useScale.SCALES;
|
|
65
|
+
|
|
66
|
+
var ref = useRef(null);
|
|
67
|
+
var inputRef = useRef(null);
|
|
68
|
+
var dropdownRef = useRef(null);
|
|
69
|
+
|
|
70
|
+
var _useState = useState(false),
|
|
71
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
+
visible = _useState2[0],
|
|
73
|
+
setVisible = _useState2[1];
|
|
74
|
+
|
|
75
|
+
var _useState3 = useState(false),
|
|
76
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
|
+
selectFocus = _useState4[0],
|
|
78
|
+
setSelectFocus = _useState4[1];
|
|
79
|
+
|
|
80
|
+
var _useCurrentState = useCurrentState(function () {
|
|
81
|
+
if (!multiple) return init;
|
|
82
|
+
if (Array.isArray(init)) return init;
|
|
83
|
+
return typeof init === 'undefined' ? [] : [init];
|
|
84
|
+
}),
|
|
85
|
+
_useCurrentState2 = _slicedToArray(_useCurrentState, 3),
|
|
86
|
+
value = _useCurrentState2[0],
|
|
87
|
+
setValue = _useCurrentState2[1],
|
|
88
|
+
valueRef = _useCurrentState2[2];
|
|
89
|
+
|
|
90
|
+
var isEmpty = useMemo(function () {
|
|
91
|
+
if (!Array.isArray(value)) return !value;
|
|
92
|
+
return value.length === 0;
|
|
93
|
+
}, [value]);
|
|
94
|
+
|
|
95
|
+
var _useMemo = useMemo(function () {
|
|
96
|
+
return getColors(theme.palette, type);
|
|
97
|
+
}, [theme.palette, type]),
|
|
98
|
+
border = _useMemo.border,
|
|
99
|
+
borderActive = _useMemo.borderActive,
|
|
100
|
+
iconBorder = _useMemo.iconBorder,
|
|
101
|
+
placeholderColor = _useMemo.placeholderColor;
|
|
102
|
+
|
|
103
|
+
var updateVisible = function updateVisible(next) {
|
|
104
|
+
onDropdownVisibleChange(next);
|
|
105
|
+
setVisible(next);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var updateValue = function updateValue(next) {
|
|
109
|
+
setValue(function (last) {
|
|
110
|
+
if (!Array.isArray(last)) return next;
|
|
111
|
+
if (!last.includes(next)) return [].concat(_toConsumableArray(last), [next]);
|
|
112
|
+
return last.filter(function (item) {
|
|
113
|
+
return item !== next;
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
onChange && onChange(valueRef.current);
|
|
117
|
+
|
|
118
|
+
if (!multiple) {
|
|
119
|
+
updateVisible(false);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var initialValue = useMemo(function () {
|
|
124
|
+
return {
|
|
125
|
+
value: value,
|
|
126
|
+
visible: visible,
|
|
127
|
+
updateValue: updateValue,
|
|
128
|
+
updateVisible: updateVisible,
|
|
129
|
+
ref: ref,
|
|
130
|
+
disableAll: disabled
|
|
131
|
+
};
|
|
132
|
+
}, [visible, disabled, ref, value, multiple]);
|
|
133
|
+
|
|
134
|
+
var clickHandler = function clickHandler(event) {
|
|
135
|
+
event.stopPropagation();
|
|
136
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
if (disabled) return;
|
|
139
|
+
updateVisible(!visible);
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
var mouseDownHandler = function mouseDownHandler(event) {
|
|
144
|
+
/* istanbul ignore next */
|
|
145
|
+
if (visible) {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
useEffect(function () {
|
|
151
|
+
if (customValue === undefined) return;
|
|
152
|
+
setValue(customValue);
|
|
153
|
+
}, [customValue]);
|
|
154
|
+
useImperativeHandle(selectRef, function () {
|
|
155
|
+
return {
|
|
156
|
+
focus: function focus() {
|
|
157
|
+
var _inputRef$current;
|
|
158
|
+
|
|
159
|
+
return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
160
|
+
},
|
|
161
|
+
blur: function blur() {
|
|
162
|
+
var _inputRef$current2;
|
|
163
|
+
|
|
164
|
+
return (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.blur();
|
|
165
|
+
},
|
|
166
|
+
scrollTo: function scrollTo(options) {
|
|
167
|
+
var _dropdownRef$current;
|
|
168
|
+
|
|
169
|
+
return (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.scrollTo(options);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}, [inputRef, dropdownRef]);
|
|
173
|
+
var selectedChild = useMemo(function () {
|
|
174
|
+
var _pickChildByProps = pickChildByProps(children, 'value', value),
|
|
175
|
+
_pickChildByProps2 = _slicedToArray(_pickChildByProps, 2),
|
|
176
|
+
optionChildren = _pickChildByProps2[1];
|
|
177
|
+
|
|
178
|
+
return React.Children.map(optionChildren, function (child) {
|
|
179
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return null;
|
|
180
|
+
var el = /*#__PURE__*/React.cloneElement(child, {
|
|
181
|
+
preventAllEvents: true
|
|
182
|
+
});
|
|
183
|
+
if (!multiple) return el;
|
|
184
|
+
return /*#__PURE__*/React.createElement(SelectMultipleValue, {
|
|
185
|
+
disabled: disabled,
|
|
186
|
+
onClear: clearable ? function () {
|
|
187
|
+
return updateValue(child.props.value);
|
|
188
|
+
} : null
|
|
189
|
+
}, el);
|
|
190
|
+
});
|
|
191
|
+
}, [value, children, multiple]);
|
|
192
|
+
|
|
193
|
+
var onInputBlur = function onInputBlur() {
|
|
194
|
+
updateVisible(false);
|
|
195
|
+
setSelectFocus(false);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
var classes = useClasses('select', {
|
|
199
|
+
active: selectFocus || visible,
|
|
200
|
+
multiple: multiple
|
|
201
|
+
}, className);
|
|
202
|
+
return /*#__PURE__*/React.createElement(SelectContext.Provider, {
|
|
203
|
+
value: initialValue
|
|
204
|
+
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
205
|
+
ref: ref,
|
|
206
|
+
onClick: clickHandler,
|
|
207
|
+
onMouseDown: mouseDownHandler
|
|
208
|
+
}, props, {
|
|
209
|
+
className: _JSXStyle.dynamic([["3089088549", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + (props && props.className != null && props.className || classes || "")
|
|
210
|
+
}), /*#__PURE__*/React.createElement(SelectInput, {
|
|
211
|
+
ref: inputRef,
|
|
212
|
+
visible: visible,
|
|
213
|
+
onBlur: onInputBlur,
|
|
214
|
+
onFocus: function onFocus() {
|
|
215
|
+
return setSelectFocus(true);
|
|
216
|
+
}
|
|
217
|
+
}), isEmpty && /*#__PURE__*/React.createElement("span", {
|
|
218
|
+
className: _JSXStyle.dynamic([["3089088549", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + "value placeholder"
|
|
219
|
+
}, /*#__PURE__*/React.createElement(Ellipsis, {
|
|
220
|
+
height: "var(--select-height)"
|
|
221
|
+
}, placeholder)), value && !multiple && /*#__PURE__*/React.createElement("span", {
|
|
222
|
+
className: _JSXStyle.dynamic([["3089088549", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + "value"
|
|
223
|
+
}, selectedChild), value && multiple && /*#__PURE__*/React.createElement(Grid.Container, {
|
|
224
|
+
gap: 0.5
|
|
225
|
+
}, selectedChild), /*#__PURE__*/React.createElement(SelectDropdown, {
|
|
226
|
+
ref: dropdownRef,
|
|
227
|
+
visible: visible,
|
|
228
|
+
className: dropdownClassName,
|
|
229
|
+
dropdownStyle: dropdownStyle,
|
|
230
|
+
disableMatchWidth: disableMatchWidth,
|
|
231
|
+
getPopupContainer: getPopupContainer
|
|
232
|
+
}, children), !pure && /*#__PURE__*/React.createElement("div", {
|
|
233
|
+
className: _JSXStyle.dynamic([["3089088549", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + "icon"
|
|
234
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
235
|
+
className: _JSXStyle.dynamic([["3089088549", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]])
|
|
236
|
+
})), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
237
|
+
id: "3089088549",
|
|
238
|
+
dynamic: [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]
|
|
239
|
+
}, ".select.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;position:relative;cursor:".concat(disabled ? 'not-allowed' : 'pointer', ";max-width:90vw;overflow:hidden;-webkit-transition:border 150ms ease-in 0s,color 200ms ease-out 0s, box-shadow 200ms ease 0s;transition:border 150ms ease-in 0s,color 200ms ease-out 0s, box-shadow 200ms ease 0s;border:1px solid ").concat(border, ";border-radius:").concat(theme.layout.radius, ";background-color:").concat(disabled ? theme.palette.accents_1 : theme.palette.background, ";--select-font-size:").concat(SCALES.font(0.875), ";--select-height:").concat(SCALES.height(2.25), ";min-width:11.5em;width:").concat(SCALES.width(1, 'initial'), ";height:var(--select-height);padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0.334), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0.667), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.multiple.__jsx-style-dynamic-selector{height:auto;min-height:var(--select-height);padding:").concat(SCALES.pt(0.334), " ").concat(SCALES.pr(0.334), " ").concat(SCALES.pb(0.334), " ").concat(SCALES.pl(0.667), ";}.select.active.__jsx-style-dynamic-selector,.select.__jsx-style-dynamic-selector:hover{border-color:").concat(disabled ? theme.palette.border : borderActive, ";}.select.active.icon.__jsx-style-dynamic-selector,.select.__jsx-style-dynamic-selector:hover .icon.__jsx-style-dynamic-selector{color:").concat(disabled ? theme.palette.accents_5 : borderActive, ";}.value.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex:1;-ms-flex:1;flex:1;height:100%;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:1;padding:0;margin-right:1.25em;font-size:var(--select-font-size);color:").concat(disabled ? theme.palette.accents_4 : theme.palette.foreground, ";width:calc(100% - 1.25em);}.value.__jsx-style-dynamic-selector>div,.value.__jsx-style-dynamic-selector>div:hover{border-radius:0;background-color:transparent;padding:0;margin:0;color:inherit;}.placeholder.__jsx-style-dynamic-selector{color:").concat(placeholderColor, ";}.icon.__jsx-style-dynamic-selector{position:absolute;right:").concat(theme.layout.gapQuarter, ";font-size:var(--select-font-size);top:50%;bottom:0;-webkit-transform:translateY(-50%) rotate(").concat(visible ? '180' : '0', "deg);-ms-transform:translateY(-50%) rotate(").concat(visible ? '180' : '0', "deg);transform:translateY(-50%) rotate(").concat(visible ? '180' : '0', "deg);pointer-events:none;-webkit-transition:-webkit-transform 200ms ease;-webkit-transition:transform 200ms ease;transition:transform 200ms ease;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(iconBorder, ";}"))));
|
|
240
|
+
});
|
|
241
|
+
SelectComponent.defaultProps = defaultProps;
|
|
242
|
+
SelectComponent.displayName = 'BolioUISelect';
|
|
243
|
+
var Select = withScale(SelectComponent);
|
|
244
|
+
export default Select;
|