@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,107 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["src", "stacked", "text", "isSquare", "className"];
|
|
5
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
6
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import AvatarSkeleton from './avatar.skeleton';
|
|
8
|
+
import useTheme from '../use-theme';
|
|
9
|
+
import useScale, { withScale } from '../use-scale';
|
|
10
|
+
import useClasses from '../use-classes';
|
|
11
|
+
import { transformDataSource } from './helpers';
|
|
12
|
+
|
|
13
|
+
var safeText = function safeText(text) {
|
|
14
|
+
if (text.length <= 4) return text;
|
|
15
|
+
return text.slice(0, 3);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function AvatarComponent(_ref) {
|
|
19
|
+
var src = _ref.src,
|
|
20
|
+
_ref$stacked = _ref.stacked,
|
|
21
|
+
stacked = _ref$stacked === void 0 ? false : _ref$stacked,
|
|
22
|
+
_ref$text = _ref.text,
|
|
23
|
+
text = _ref$text === void 0 ? '' : _ref$text,
|
|
24
|
+
_ref$isSquare = _ref.isSquare,
|
|
25
|
+
isSquare = _ref$isSquare === void 0 ? false : _ref$isSquare,
|
|
26
|
+
_ref$className = _ref.className,
|
|
27
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
28
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
|
|
30
|
+
var theme = useTheme();
|
|
31
|
+
|
|
32
|
+
var _useScale = useScale(),
|
|
33
|
+
SCALES = _useScale.SCALES,
|
|
34
|
+
getScaleProps = _useScale.getScaleProps;
|
|
35
|
+
|
|
36
|
+
var showText = !src;
|
|
37
|
+
var radius = isSquare ? theme.layout.radius : '50%';
|
|
38
|
+
var marginLeft = stacked ? SCALES.ml(-0.625) : SCALES.ml(0);
|
|
39
|
+
var classes = useClasses('avatar', className);
|
|
40
|
+
var width = getScaleProps(['width', 'w']);
|
|
41
|
+
var height = getScaleProps(['height', 'h']);
|
|
42
|
+
var showAnimation = width && height;
|
|
43
|
+
|
|
44
|
+
var _useState = useState(true),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
loading = _useState2[0],
|
|
47
|
+
setLoading = _useState2[1];
|
|
48
|
+
|
|
49
|
+
var _useState3 = useState(true),
|
|
50
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
51
|
+
showSkeleton = _useState4[0],
|
|
52
|
+
setShowSkeleton = _useState4[1];
|
|
53
|
+
|
|
54
|
+
var imageRef = useRef(null);
|
|
55
|
+
var url = useMemo(function () {
|
|
56
|
+
return transformDataSource(src);
|
|
57
|
+
}, [src]);
|
|
58
|
+
|
|
59
|
+
var imageLoaded = function imageLoaded() {
|
|
60
|
+
if (!showAnimation) return;
|
|
61
|
+
setLoading(false);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
if (!showAnimation) return;
|
|
66
|
+
if (!imageRef.current) return;
|
|
67
|
+
|
|
68
|
+
if (imageRef.current.complete) {
|
|
69
|
+
setLoading(false);
|
|
70
|
+
setShowSkeleton(false);
|
|
71
|
+
}
|
|
72
|
+
}, [showAnimation]);
|
|
73
|
+
useEffect(function () {
|
|
74
|
+
var timer = setTimeout(function () {
|
|
75
|
+
if (showAnimation) {
|
|
76
|
+
setShowSkeleton(false);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
}, 3000);
|
|
81
|
+
return function () {
|
|
82
|
+
return clearTimeout(timer);
|
|
83
|
+
};
|
|
84
|
+
}, [loading, showAnimation]);
|
|
85
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
86
|
+
className: _JSXStyle.dynamic([["1130296330", [radius, theme.palette.accents_1, SCALES.width(1.75) || SCALES.height(1.75), SCALES.height(1.75) || SCALES.width(1.75), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), marginLeft, radius, SCALES.font(1)]]]) + " " + (classes || "")
|
|
87
|
+
}, !showText && /*#__PURE__*/React.createElement(React.Fragment, null, showSkeleton && showAnimation && /*#__PURE__*/React.createElement(AvatarSkeleton, {
|
|
88
|
+
opacity: loading ? 1 : 0
|
|
89
|
+
}), /*#__PURE__*/React.createElement("img", _extends({
|
|
90
|
+
alt: "Avatar",
|
|
91
|
+
src: src,
|
|
92
|
+
ref: imageRef,
|
|
93
|
+
onLoad: imageLoaded,
|
|
94
|
+
draggable: false
|
|
95
|
+
}, props, {
|
|
96
|
+
className: _JSXStyle.dynamic([["1130296330", [radius, theme.palette.accents_1, SCALES.width(1.75) || SCALES.height(1.75), SCALES.height(1.75) || SCALES.width(1.75), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), marginLeft, radius, SCALES.font(1)]]]) + " " + (props && props.className != null && props.className || "avatar-img")
|
|
97
|
+
}))), showText && /*#__PURE__*/React.createElement("span", _extends({}, props, {
|
|
98
|
+
className: _JSXStyle.dynamic([["1130296330", [radius, theme.palette.accents_1, SCALES.width(1.75) || SCALES.height(1.75), SCALES.height(1.75) || SCALES.width(1.75), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), marginLeft, radius, SCALES.font(1)]]]) + " " + (props && props.className != null && props.className || "avatar-text")
|
|
99
|
+
}), safeText(text)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
100
|
+
id: "1130296330",
|
|
101
|
+
dynamic: [radius, theme.palette.accents_1, SCALES.width(1.75) || SCALES.height(1.75), SCALES.height(1.75) || SCALES.width(1.75), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), marginLeft, radius, SCALES.font(1)]
|
|
102
|
+
}, ".avatar.__jsx-style-dynamic-selector{display:inline-block;position:relative;overflow:hidden;border-radius:".concat(radius, ";vertical-align:top;background-color:").concat(theme.palette.accents_1, ";box-sizing:border-box;width:").concat(SCALES.width(1.75) || SCALES.height(1.75), ";height:").concat(SCALES.height(1.75) || SCALES.width(1.75), ";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(marginLeft, ";}.avatar-img.__jsx-style-dynamic-selector{display:inline-block;object-fit:cover;width:100%;height:100%;border-radius:").concat(radius, ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-align:center;}.avatar-text.__jsx-style-dynamic-selector{position:absolute;left:50%;top:50%;font-size:").concat(SCALES.font(1), ";text-align:center;-webkit-transform:translate(-50%,-50%) scale(0.65);-ms-transform:translate(-50%,-50%) scale(0.65);transform:translate(-50%,-50%) scale(0.65);white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}")));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
AvatarComponent.displayName = 'BolioUIAvatar';
|
|
106
|
+
var Avatar = withScale(AvatarComponent);
|
|
107
|
+
export default Avatar;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["opacity"];
|
|
4
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import useTheme from '../use-theme';
|
|
7
|
+
var AvatarSkeleton = /*#__PURE__*/React.memo(function (_ref) {
|
|
8
|
+
var _ref$opacity = _ref.opacity,
|
|
9
|
+
opacity = _ref$opacity === void 0 ? 0.5 : _ref$opacity,
|
|
10
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
|
|
12
|
+
var theme = useTheme();
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
14
|
+
className: _JSXStyle.dynamic([["2946022605", [theme.palette.accents_1, theme.palette.accents_2, theme.palette.accents_2, theme.palette.accents_1, opacity]]]) + " " + (props && props.className != null && props.className || "skeleton")
|
|
15
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
16
|
+
id: "2946022605",
|
|
17
|
+
dynamic: [theme.palette.accents_1, theme.palette.accents_2, theme.palette.accents_2, theme.palette.accents_1, opacity]
|
|
18
|
+
}, ".skeleton.__jsx-style-dynamic-selector{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;background-image:linear-gradient( 270deg, ".concat(theme.palette.accents_1, ", ").concat(theme.palette.accents_2, ", ").concat(theme.palette.accents_2, ", ").concat(theme.palette.accents_1, " );background-size:400% 100%;-webkit-animation:loading-__jsx-style-dynamic-selector 3s ease-in-out infinite;animation:loading-__jsx-style-dynamic-selector 3s ease-in-out infinite;opacity:").concat(opacity, ";-webkit-transition:opacity 300ms ease-out;transition:opacity 300ms ease-out;}@-webkit-keyframes loading-__jsx-style-dynamic-selector{0%{background-position:200% 0;}to{background-position:-200% 0;}}@keyframes loading-__jsx-style-dynamic-selector{0%{background-position:200% 0;}to{background-position:-200% 0;}}")));
|
|
19
|
+
});
|
|
20
|
+
AvatarSkeleton.displayName = 'BolioUIAvatarSkeleton';
|
|
21
|
+
export default AvatarSkeleton;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var transformDataSource = function transformDataSource(src) {
|
|
2
|
+
var left = "".concat(src).slice(0, 4);
|
|
3
|
+
|
|
4
|
+
if (encodeURIComponent(left) === '%3Csvg') {
|
|
5
|
+
return "data:image/svg+xml;utf8,".concat(src);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return src;
|
|
9
|
+
};
|
|
10
|
+
export var getHostFromUrl = function getHostFromUrl(url) {
|
|
11
|
+
try {
|
|
12
|
+
return new URL(url).host;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import Avatar from '.';
|
|
2
|
+
import Grid from '../grid';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Data Display/Avatar',
|
|
5
|
+
component: Avatar
|
|
6
|
+
};
|
|
7
|
+
export var Default = function Default() {
|
|
8
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
9
|
+
gap: 2
|
|
10
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
11
|
+
src: "https://i.pravatar.cc/150?img=60",
|
|
12
|
+
isSquare: true,
|
|
13
|
+
width: 1.5,
|
|
14
|
+
height: 1.5
|
|
15
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
16
|
+
text: "Bill",
|
|
17
|
+
isSquare: true,
|
|
18
|
+
width: 1.5,
|
|
19
|
+
height: 1.5
|
|
20
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
21
|
+
src: "https://i.pravatar.cc/150?img=30",
|
|
22
|
+
isSquare: true,
|
|
23
|
+
width: 1.5,
|
|
24
|
+
height: 1.5
|
|
25
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
26
|
+
text: "Max",
|
|
27
|
+
isSquare: true,
|
|
28
|
+
width: 1.5,
|
|
29
|
+
height: 1.5
|
|
30
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
31
|
+
src: "https://i.pravatar.cc/150?img=20",
|
|
32
|
+
isSquare: true,
|
|
33
|
+
width: 1.5,
|
|
34
|
+
height: 1.5
|
|
35
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
36
|
+
text: "Jane",
|
|
37
|
+
isSquare: true,
|
|
38
|
+
width: 1.5,
|
|
39
|
+
height: 1.5
|
|
40
|
+
})));
|
|
41
|
+
};
|
|
42
|
+
export var Text = function Text() {
|
|
43
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
44
|
+
gap: 2
|
|
45
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
46
|
+
text: "BA",
|
|
47
|
+
width: 1.5,
|
|
48
|
+
height: 1.5
|
|
49
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
50
|
+
text: "ES",
|
|
51
|
+
width: 1.5,
|
|
52
|
+
height: 1.5
|
|
53
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
54
|
+
text: "MB",
|
|
55
|
+
width: 1.5,
|
|
56
|
+
height: 1.5
|
|
57
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
58
|
+
text: "WL",
|
|
59
|
+
width: 1.5,
|
|
60
|
+
height: 1.5
|
|
61
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
62
|
+
text: "ML",
|
|
63
|
+
width: 1.5,
|
|
64
|
+
height: 1.5
|
|
65
|
+
})), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
66
|
+
text: "TR",
|
|
67
|
+
width: 1.5,
|
|
68
|
+
height: 1.5
|
|
69
|
+
})));
|
|
70
|
+
};
|
|
71
|
+
export var Group = function Group() {
|
|
72
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
73
|
+
gap: 2,
|
|
74
|
+
direction: "column"
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar.Group, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
76
|
+
src: "https://i.pravatar.cc/150?img=60",
|
|
77
|
+
width: 1.5,
|
|
78
|
+
height: 1.5,
|
|
79
|
+
stacked: true
|
|
80
|
+
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
81
|
+
src: "https://i.pravatar.cc/150?img=30",
|
|
82
|
+
width: 1.5,
|
|
83
|
+
height: 1.5,
|
|
84
|
+
stacked: true
|
|
85
|
+
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
86
|
+
src: "https://i.pravatar.cc/150?img=20",
|
|
87
|
+
width: 1.5,
|
|
88
|
+
height: 1.5,
|
|
89
|
+
stacked: true
|
|
90
|
+
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
91
|
+
src: "https://i.pravatar.cc/150?img=10",
|
|
92
|
+
width: 1.5,
|
|
93
|
+
height: 1.5,
|
|
94
|
+
stacked: true
|
|
95
|
+
}))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Avatar.Group, {
|
|
96
|
+
count: 6
|
|
97
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
98
|
+
src: "https://i.pravatar.cc/150?img=60",
|
|
99
|
+
width: 1.5,
|
|
100
|
+
height: 1.5,
|
|
101
|
+
stacked: true
|
|
102
|
+
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
103
|
+
text: "C",
|
|
104
|
+
width: 1.5,
|
|
105
|
+
height: 1.5,
|
|
106
|
+
stacked: true
|
|
107
|
+
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
108
|
+
text: "Mag",
|
|
109
|
+
width: 1.5,
|
|
110
|
+
height: 1.5,
|
|
111
|
+
stacked: true
|
|
112
|
+
}))));
|
|
113
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { pickChild } from '../utils/collections';
|
|
5
|
+
import { tuple } from '../utils/prop-types';
|
|
6
|
+
import Badge from './badge';
|
|
7
|
+
var placement = tuple('topLeft', 'topRight', 'bottomLeft', 'bottomRight');
|
|
8
|
+
|
|
9
|
+
var getTransform = function getTransform(placement) {
|
|
10
|
+
var styles = {
|
|
11
|
+
topLeft: {
|
|
12
|
+
top: '0',
|
|
13
|
+
left: '0',
|
|
14
|
+
value: 'translate(-50%, -50%)',
|
|
15
|
+
origin: '0% 0%'
|
|
16
|
+
},
|
|
17
|
+
topRight: {
|
|
18
|
+
top: '0',
|
|
19
|
+
right: '0',
|
|
20
|
+
value: 'translate(50%, -50%)',
|
|
21
|
+
origin: '100% 0%'
|
|
22
|
+
},
|
|
23
|
+
bottomLeft: {
|
|
24
|
+
left: '0',
|
|
25
|
+
bottom: '0',
|
|
26
|
+
value: 'translate(-50%, 50%)',
|
|
27
|
+
origin: '0% 100%'
|
|
28
|
+
},
|
|
29
|
+
bottomRight: {
|
|
30
|
+
right: '0',
|
|
31
|
+
bottom: '0',
|
|
32
|
+
value: 'translate(50%, 50%)',
|
|
33
|
+
origin: '100% 100%'
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return styles[placement];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function BadgeAnchor(_ref) {
|
|
40
|
+
var children = _ref.children,
|
|
41
|
+
_ref$placement = _ref.placement,
|
|
42
|
+
placement = _ref$placement === void 0 ? 'topRight' : _ref$placement;
|
|
43
|
+
|
|
44
|
+
var _pickChild = pickChild(children, Badge),
|
|
45
|
+
_pickChild2 = _slicedToArray(_pickChild, 2),
|
|
46
|
+
withoutBadgeChildren = _pickChild2[0],
|
|
47
|
+
badgeChldren = _pickChild2[1];
|
|
48
|
+
|
|
49
|
+
var _useMemo = useMemo(function () {
|
|
50
|
+
return getTransform(placement);
|
|
51
|
+
}, [placement]),
|
|
52
|
+
top = _useMemo.top,
|
|
53
|
+
bottom = _useMemo.bottom,
|
|
54
|
+
left = _useMemo.left,
|
|
55
|
+
right = _useMemo.right,
|
|
56
|
+
value = _useMemo.value,
|
|
57
|
+
origin = _useMemo.origin;
|
|
58
|
+
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: _JSXStyle.dynamic([["1121745930", [top || 'auto', left || 'auto', right || 'auto', bottom || 'auto', value, origin]]]) + " " + "anchor"
|
|
61
|
+
}, withoutBadgeChildren, /*#__PURE__*/React.createElement("sup", {
|
|
62
|
+
className: _JSXStyle.dynamic([["1121745930", [top || 'auto', left || 'auto', right || 'auto', bottom || 'auto', value, origin]]])
|
|
63
|
+
}, badgeChldren), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
64
|
+
id: "1121745930",
|
|
65
|
+
dynamic: [top || 'auto', left || 'auto', right || 'auto', bottom || 'auto', value, origin]
|
|
66
|
+
}, ".anchor.__jsx-style-dynamic-selector{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;box-sizing:border-box;}sup.__jsx-style-dynamic-selector{position:absolute;top:".concat(top || 'auto', ";left:").concat(left || 'auto', ";right:").concat(right || 'auto', ";bottom:").concat(bottom || 'auto', ";-webkit-transform:").concat(value, ";-ms-transform:").concat(value, ";transform:").concat(value, ";-webkit-transform-origin:").concat(origin, ";-ms-transform-origin:").concat(origin, ";transform-origin:").concat(origin, ";z-index:1;}")));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
BadgeAnchor.displayName = 'BolioUIBadgeAnchor';
|
|
70
|
+
export default BadgeAnchor;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["type", "className", "children", "dot"];
|
|
4
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
import useTheme from '../use-theme';
|
|
7
|
+
import useScale, { withScale } from '../use-scale';
|
|
8
|
+
import useClasses from '../use-classes';
|
|
9
|
+
|
|
10
|
+
var getBgColor = function getBgColor(type, palette) {
|
|
11
|
+
var colors = {
|
|
12
|
+
"default": palette.foreground,
|
|
13
|
+
secondary: palette.secondary,
|
|
14
|
+
primary: palette.primary,
|
|
15
|
+
success: palette.success,
|
|
16
|
+
warning: palette.warning,
|
|
17
|
+
error: palette.error,
|
|
18
|
+
info: palette.info
|
|
19
|
+
};
|
|
20
|
+
return colors[type];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function BadgeComponent(_ref) {
|
|
24
|
+
var _ref$type = _ref.type,
|
|
25
|
+
type = _ref$type === void 0 ? 'default' : _ref$type,
|
|
26
|
+
_ref$className = _ref.className,
|
|
27
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
28
|
+
children = _ref.children,
|
|
29
|
+
_ref$dot = _ref.dot,
|
|
30
|
+
dot = _ref$dot === void 0 ? false : _ref$dot,
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
|
|
33
|
+
var theme = useTheme();
|
|
34
|
+
|
|
35
|
+
var _useScale = useScale(),
|
|
36
|
+
SCALES = _useScale.SCALES;
|
|
37
|
+
|
|
38
|
+
var bg = useMemo(function () {
|
|
39
|
+
return getBgColor(type, theme.palette);
|
|
40
|
+
}, [type, theme.palette]);
|
|
41
|
+
var color = useMemo(function () {
|
|
42
|
+
if (!type || type === 'default') return theme.palette.background;
|
|
43
|
+
return 'white';
|
|
44
|
+
}, [type, theme.palette.background]);
|
|
45
|
+
var classes = useClasses('badge', {
|
|
46
|
+
dot: dot
|
|
47
|
+
}, className);
|
|
48
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, props, {
|
|
49
|
+
className: _JSXStyle.dynamic([["3372370275", [bg, color, SCALES.font(0.875), SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.pt(0.5), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.py(0.25), SCALES.px(0.25)]]]) + " " + (props && props.className != null && props.className || classes || "")
|
|
50
|
+
}), !dot && children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
51
|
+
id: "3372370275",
|
|
52
|
+
dynamic: [bg, color, SCALES.font(0.875), SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.pt(0.5), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.py(0.25), SCALES.px(0.25)]
|
|
53
|
+
}, ".badge.__jsx-style-dynamic-selector{display:inline-block;border-radius:16px;font-variant:tabular-nums;line-height:1;vertical-align:middle;background-color:".concat(bg, ";color:").concat(color, ";border:0;font-size:").concat(SCALES.font(0.875), ";font-weight:500;width:").concat(SCALES.width(1, 'auto'), ";height:").concat(SCALES.height(1, 'auto'), ";padding:").concat(SCALES.pt(0.5), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.dot.__jsx-style-dynamic-selector{padding:").concat(SCALES.py(0.25), " ").concat(SCALES.px(0.25), ";border-radius:50%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}")));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
BadgeComponent.displayName = 'BolioUIBadge';
|
|
57
|
+
var Badge = withScale(BadgeComponent);
|
|
58
|
+
export default Badge;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useTheme } from '../use-theme/theme-context';
|
|
2
|
+
import Badge from '.';
|
|
3
|
+
import Grid from '../grid';
|
|
4
|
+
import Avatar from '../avatar';
|
|
5
|
+
import Button from '../button';
|
|
6
|
+
import Link from '../link';
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Data Display/Badge',
|
|
9
|
+
component: Badge
|
|
10
|
+
};
|
|
11
|
+
export var Default = function Default() {
|
|
12
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
13
|
+
gap: 2
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, null, "Default")));
|
|
15
|
+
};
|
|
16
|
+
export var Type = function Type() {
|
|
17
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
18
|
+
gap: 2
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, null, "Default")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
20
|
+
type: "primary"
|
|
21
|
+
}, "Primary")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
22
|
+
type: "secondary"
|
|
23
|
+
}, "Secondary")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
24
|
+
type: "success"
|
|
25
|
+
}, "Success")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
26
|
+
type: "warning"
|
|
27
|
+
}, "Warning")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
28
|
+
type: "error"
|
|
29
|
+
}, "Error")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
30
|
+
type: "info"
|
|
31
|
+
}, "Info")));
|
|
32
|
+
};
|
|
33
|
+
export var CustomColor = function CustomColor() {
|
|
34
|
+
var theme = useTheme();
|
|
35
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
36
|
+
gap: 2
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
38
|
+
style: {
|
|
39
|
+
backgroundColor: theme.palette.successLight
|
|
40
|
+
}
|
|
41
|
+
}, "Success Light")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
42
|
+
style: {
|
|
43
|
+
backgroundColor: theme.palette.alert
|
|
44
|
+
}
|
|
45
|
+
}, "Alert")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
46
|
+
style: {
|
|
47
|
+
backgroundColor: theme.palette.purple
|
|
48
|
+
}
|
|
49
|
+
}, "Purple")), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge, {
|
|
50
|
+
style: {
|
|
51
|
+
backgroundColor: theme.palette.secondary
|
|
52
|
+
}
|
|
53
|
+
}, "Violet")));
|
|
54
|
+
};
|
|
55
|
+
export var Anchor = function Anchor() {
|
|
56
|
+
return /*#__PURE__*/React.createElement(Grid.Container, {
|
|
57
|
+
gap: 2
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge.Anchor, null, /*#__PURE__*/React.createElement(Badge, {
|
|
59
|
+
scale: 0.5
|
|
60
|
+
}, "10"), /*#__PURE__*/React.createElement(Avatar, {
|
|
61
|
+
src: "https://i.pravatar.cc/150?img=60"
|
|
62
|
+
}))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge.Anchor, {
|
|
63
|
+
placement: "bottomRight"
|
|
64
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
|
65
|
+
scale: 0.5,
|
|
66
|
+
type: "success"
|
|
67
|
+
}, "10"), /*#__PURE__*/React.createElement(Avatar, {
|
|
68
|
+
scale: 1.5,
|
|
69
|
+
isSquare: true,
|
|
70
|
+
src: "https://i.pravatar.cc/150?img=30"
|
|
71
|
+
}))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge.Anchor, null, /*#__PURE__*/React.createElement(Badge, {
|
|
72
|
+
scale: 0.5,
|
|
73
|
+
type: "warning"
|
|
74
|
+
}, "99+"), /*#__PURE__*/React.createElement(Button, {
|
|
75
|
+
scale: 0.5,
|
|
76
|
+
auto: true
|
|
77
|
+
}, "Action"))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge.Anchor, null, /*#__PURE__*/React.createElement(Badge, {
|
|
78
|
+
scale: 0.5,
|
|
79
|
+
type: "error",
|
|
80
|
+
dot: true
|
|
81
|
+
}), /*#__PURE__*/React.createElement(Link, {
|
|
82
|
+
target: "_blank",
|
|
83
|
+
href: "https://github.com/bolio-ui/bolio-ui/"
|
|
84
|
+
}, "Bolio UI"))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Badge.Anchor, null, /*#__PURE__*/React.createElement(Badge, {
|
|
85
|
+
type: "error",
|
|
86
|
+
dot: true,
|
|
87
|
+
padding: "5px"
|
|
88
|
+
}), /*#__PURE__*/React.createElement(Link, {
|
|
89
|
+
target: "_blank",
|
|
90
|
+
href: "https://github.com/bolio-ui/bolio-ui/"
|
|
91
|
+
}, "Share Link"))));
|
|
92
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useMemo, useState } from 'react';
|
|
3
|
+
import { BolioUIContent, defaultToastLayout } from '../utils/use-bolio-ui-context';
|
|
4
|
+
import ThemeProvider from './theme-provider';
|
|
5
|
+
import useCurrentState from '../utils/use-current-state';
|
|
6
|
+
import ToastContainer from '../use-toasts/toast-container';
|
|
7
|
+
|
|
8
|
+
var BolioUIProvider = function BolioUIProvider(_ref) {
|
|
9
|
+
var themes = _ref.themes,
|
|
10
|
+
themeType = _ref.themeType,
|
|
11
|
+
children = _ref.children;
|
|
12
|
+
|
|
13
|
+
var _useState = useState(null),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
lastUpdateToastId = _useState2[0],
|
|
16
|
+
setLastUpdateToastId = _useState2[1];
|
|
17
|
+
|
|
18
|
+
var _useCurrentState = useCurrentState([]),
|
|
19
|
+
_useCurrentState2 = _slicedToArray(_useCurrentState, 3),
|
|
20
|
+
toasts = _useCurrentState2[0],
|
|
21
|
+
setToasts = _useCurrentState2[1],
|
|
22
|
+
toastsRef = _useCurrentState2[2];
|
|
23
|
+
|
|
24
|
+
var _useCurrentState3 = useCurrentState(defaultToastLayout),
|
|
25
|
+
_useCurrentState4 = _slicedToArray(_useCurrentState3, 3),
|
|
26
|
+
toastLayout = _useCurrentState4[0],
|
|
27
|
+
setToastLayout = _useCurrentState4[1],
|
|
28
|
+
toastLayoutRef = _useCurrentState4[2];
|
|
29
|
+
|
|
30
|
+
var updateToasts = function updateToasts(fn) {
|
|
31
|
+
var nextToasts = fn(toastsRef.current);
|
|
32
|
+
setToasts(nextToasts);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var updateToastLayout = function updateToastLayout(fn) {
|
|
36
|
+
var nextLayout = fn(toastLayoutRef.current);
|
|
37
|
+
setToastLayout(nextLayout);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var updateLastToastId = function updateLastToastId(fn) {
|
|
41
|
+
setLastUpdateToastId(fn());
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var initialValue = useMemo(function () {
|
|
45
|
+
return {
|
|
46
|
+
toasts: toasts,
|
|
47
|
+
toastLayout: toastLayout,
|
|
48
|
+
updateToasts: updateToasts,
|
|
49
|
+
lastUpdateToastId: lastUpdateToastId,
|
|
50
|
+
updateToastLayout: updateToastLayout,
|
|
51
|
+
updateLastToastId: updateLastToastId
|
|
52
|
+
};
|
|
53
|
+
}, [toasts, toastLayout, lastUpdateToastId]);
|
|
54
|
+
return /*#__PURE__*/React.createElement(BolioUIContent.Provider, {
|
|
55
|
+
value: initialValue
|
|
56
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
57
|
+
themes: themes,
|
|
58
|
+
themeType: themeType
|
|
59
|
+
}, children, /*#__PURE__*/React.createElement(ToastContainer, null)));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default BolioUIProvider;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import Themes from '../themes';
|
|
5
|
+
import { ThemeContext } from '../use-theme/theme-context';
|
|
6
|
+
import { AllThemesContext } from '../use-all-themes/all-themes-context';
|
|
7
|
+
|
|
8
|
+
var ThemeProvider = function ThemeProvider(_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
themeType = _ref.themeType,
|
|
11
|
+
_ref$themes = _ref.themes,
|
|
12
|
+
themes = _ref$themes === void 0 ? [] : _ref$themes;
|
|
13
|
+
|
|
14
|
+
var _useState = useState({
|
|
15
|
+
themes: Themes.getPresets()
|
|
16
|
+
}),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
allThemes = _useState2[0],
|
|
19
|
+
setAllThemes = _useState2[1];
|
|
20
|
+
|
|
21
|
+
var currentTheme = useMemo(function () {
|
|
22
|
+
var theme = allThemes.themes.find(function (item) {
|
|
23
|
+
return item.type === themeType;
|
|
24
|
+
});
|
|
25
|
+
if (theme) return theme;
|
|
26
|
+
return Themes.getPresetStaticTheme();
|
|
27
|
+
}, [allThemes, themeType]);
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (!(themes !== null && themes !== void 0 && themes.length)) return;
|
|
30
|
+
setAllThemes(function (last) {
|
|
31
|
+
var safeThemes = themes.filter(function (item) {
|
|
32
|
+
return Themes.isAvailableThemeType(item.type);
|
|
33
|
+
});
|
|
34
|
+
var nextThemes = Themes.getPresets().concat(safeThemes);
|
|
35
|
+
return _extends({}, last, {
|
|
36
|
+
themes: nextThemes
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}, [themes]);
|
|
40
|
+
return /*#__PURE__*/React.createElement(AllThemesContext.Provider, {
|
|
41
|
+
value: allThemes
|
|
42
|
+
}, /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
|
43
|
+
value: currentTheme
|
|
44
|
+
}, children));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default ThemeProvider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["href", "nextLink", "onClick", "children", "className"];
|
|
5
|
+
import Link from '../link';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
import { pickChild } from '../utils/collections';
|
|
8
|
+
import BreadcrumbsSeparator from './breadcrumbs-separator';
|
|
9
|
+
import useClasses from '../use-classes';
|
|
10
|
+
var BreadcrumbsItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
11
|
+
var href = _ref.href,
|
|
12
|
+
_ref$nextLink = _ref.nextLink,
|
|
13
|
+
nextLink = _ref$nextLink === void 0 ? false : _ref$nextLink,
|
|
14
|
+
onClick = _ref.onClick,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
_ref$className = _ref.className,
|
|
17
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
|
|
20
|
+
var isLink = useMemo(function () {
|
|
21
|
+
return href !== undefined || nextLink;
|
|
22
|
+
}, [href, nextLink]);
|
|
23
|
+
|
|
24
|
+
var _pickChild = pickChild(children, BreadcrumbsSeparator),
|
|
25
|
+
_pickChild2 = _slicedToArray(_pickChild, 1),
|
|
26
|
+
withoutSepChildren = _pickChild2[0];
|
|
27
|
+
|
|
28
|
+
var classes = useClasses('breadcrumbs-item', className);
|
|
29
|
+
|
|
30
|
+
var clickHandler = function clickHandler(event) {
|
|
31
|
+
onClick && onClick(event);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (!isLink) {
|
|
35
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
36
|
+
className: classes,
|
|
37
|
+
onClick: clickHandler
|
|
38
|
+
}, withoutSepChildren);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return /*#__PURE__*/React.createElement(Link, _extends({
|
|
42
|
+
className: classes,
|
|
43
|
+
href: href,
|
|
44
|
+
onClick: clickHandler,
|
|
45
|
+
ref: ref
|
|
46
|
+
}, props), withoutSepChildren);
|
|
47
|
+
});
|
|
48
|
+
BreadcrumbsItem.displayName = 'BolioUIBreadcrumbsItem';
|
|
49
|
+
export default BreadcrumbsItem;
|