@homecode/ui 4.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/esm/index.js +78 -0
- package/dist/esm/node_modules/style-inject/dist/style-inject.es.js +28 -0
- package/dist/esm/src/components/AssistiveText/AssistiveText.js +10 -0
- package/dist/esm/src/components/AssistiveText/AssistiveText.styl.js +7 -0
- package/dist/esm/src/components/Button/Button.helpers.js +12 -0
- package/dist/esm/src/components/Button/Button.js +38 -0
- package/dist/esm/src/components/Button/Button.styl.js +7 -0
- package/dist/esm/src/components/ButtonGroup/ButtonGroup.js +10 -0
- package/dist/esm/src/components/ButtonGroup/ButtonGroup.styl.js +7 -0
- package/dist/esm/src/components/Checkbox/Checkbox.js +48 -0
- package/dist/esm/src/components/Checkbox/Checkbox.styl.js +7 -0
- package/dist/esm/src/components/Container/Container.js +12 -0
- package/dist/esm/src/components/Container/Container.styl.js +7 -0
- package/dist/esm/src/components/DateTime/DateTime.js +17 -0
- package/dist/esm/src/components/Draggable/Draggable.js +136 -0
- package/dist/esm/src/components/Draggable/Draggable.styl.js +7 -0
- package/dist/esm/src/components/Expand/Expand.js +24 -0
- package/dist/esm/src/components/Expand/Expand.styl.js +7 -0
- package/dist/esm/src/components/Form/Form.helpers.js +42 -0
- package/dist/esm/src/components/Form/Form.js +286 -0
- package/dist/esm/src/components/Form/Form.styl.js +7 -0
- package/dist/esm/src/components/Form/Form.types.js +1 -0
- package/dist/esm/src/components/Form/SubmitButtons/SubmitButtons.js +8 -0
- package/dist/esm/src/components/Form/SubmitButtons/SubmitButtons.styl.js +7 -0
- package/dist/esm/src/components/Form/Validator.js +36 -0
- package/dist/esm/src/components/Gallery/Dots/Dots.js +9 -0
- package/dist/esm/src/components/Gallery/Dots/Dots.styl.js +7 -0
- package/dist/esm/src/components/Gallery/Gallery.js +180 -0
- package/dist/esm/src/components/Gallery/Gallery.styl.js +7 -0
- package/dist/esm/src/components/Heading/Heading.js +37 -0
- package/dist/esm/src/components/Heading/Heading.styl.js +7 -0
- package/dist/esm/src/components/Icon/Icon.js +27 -0
- package/dist/esm/src/components/Icon/Icon.styl.js +7 -0
- package/dist/esm/src/components/Icon/icons/avatar.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/brokenImage.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/check.svg.js +19 -0
- package/dist/esm/src/components/Icon/icons/chevronDown.svg.js +20 -0
- package/dist/esm/src/components/Icon/icons/chevronLeft.svg.js +20 -0
- package/dist/esm/src/components/Icon/icons/chevronRight.svg.js +20 -0
- package/dist/esm/src/components/Icon/icons/chevronUp.svg.js +20 -0
- package/dist/esm/src/components/Icon/icons/close.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/colors.svg.js +60 -0
- package/dist/esm/src/components/Icon/icons/copy.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/delete.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/draft.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/edit.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/externalLink.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/fullscreen.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/fullscreenExit.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/gear.svg.js +20 -0
- package/dist/esm/src/components/Icon/icons/history.svg.js +17 -0
- package/dist/esm/src/components/Icon/icons/home.svg.js +19 -0
- package/dist/esm/src/components/Icon/icons/index.js +41 -0
- package/dist/esm/src/components/Icon/icons/loader.svg.js +45 -0
- package/dist/esm/src/components/Icon/icons/menu.svg.js +18 -0
- package/dist/esm/src/components/Icon/icons/mic.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/minus.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/moreHorizontal.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/moreVertical.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/plus.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/redo.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/requiredStar.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/save.svg.js +17 -0
- package/dist/esm/src/components/Icon/icons/send.svg.js +16 -0
- package/dist/esm/src/components/Icon/icons/settings.svg.js +52 -0
- package/dist/esm/src/components/Icon/icons/shoppingBag.svg.js +17 -0
- package/dist/esm/src/components/Icon/icons/social_email.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/social_instagram.svg.js +15 -0
- package/dist/esm/src/components/Icon/icons/social_telegram.svg.js +19 -0
- package/dist/esm/src/components/Icon/icons/undo.svg.js +15 -0
- package/dist/esm/src/components/Input/Input.js +331 -0
- package/dist/esm/src/components/Input/Input.styl.js +7 -0
- package/dist/esm/src/components/InputFile/InputFile.js +292 -0
- package/dist/esm/src/components/InputFile/InputFile.styl.js +7 -0
- package/dist/esm/src/components/InputFile/InputFile.types.js +1 -0
- package/dist/esm/src/components/InputFile/Item/Item.js +18 -0
- package/dist/esm/src/components/InputFile/Item/Item.styl.js +7 -0
- package/dist/esm/src/components/Label/Label.constants.json.js +8 -0
- package/dist/esm/src/components/Label/Label.helpers.js +35 -0
- package/dist/esm/src/components/Label/Label.js +58 -0
- package/dist/esm/src/components/Label/Label.styl.js +7 -0
- package/dist/esm/src/components/Lazy/Lazy.js +65 -0
- package/dist/esm/src/components/LightBox/LightBox.js +28 -0
- package/dist/esm/src/components/LightBox/LightBox.styl.js +7 -0
- package/dist/esm/src/components/Notifications/Notifications.constants.json.js +6 -0
- package/dist/esm/src/components/Notifications/Notifications.js +67 -0
- package/dist/esm/src/components/Notifications/Notifications.styl.js +7 -0
- package/dist/esm/src/components/Notifications/store.js +62 -0
- package/dist/esm/src/components/Paranja/Paranja.js +14 -0
- package/dist/esm/src/components/Paranja/Paranja.styl.js +7 -0
- package/dist/esm/src/components/Popup/Popup.helpers.js +31 -0
- package/dist/esm/src/components/Popup/Popup.js +396 -0
- package/dist/esm/src/components/Popup/Popup.styl.js +7 -0
- package/dist/esm/src/components/PopupMenu/PopupMenu.js +15 -0
- package/dist/esm/src/components/PopupMenu/PopupMenu.styl.js +7 -0
- package/dist/esm/src/components/Portal/Portal.js +19 -0
- package/dist/esm/src/components/RequiredStar/RequiredStar.js +12 -0
- package/dist/esm/src/components/RequiredStar/RequiredStar.styl.js +7 -0
- package/dist/esm/src/components/Router/Link/Link.js +61 -0
- package/dist/esm/src/components/Router/Link/Link.styl.js +7 -0
- package/dist/esm/src/components/Router/Redirect.js +12 -0
- package/dist/esm/src/components/Router/Route.js +4 -0
- package/dist/esm/src/components/Router/Router.helpers.js +33 -0
- package/dist/esm/src/components/Router/Router.js +68 -0
- package/dist/esm/src/components/Router/context.js +5 -0
- package/dist/esm/src/components/Router/store.js +55 -0
- package/dist/esm/src/components/Scroll/Scroll.js +274 -0
- package/dist/esm/src/components/Scroll/Scroll.styl.js +7 -0
- package/dist/esm/src/components/Select/Select.helpers.js +37 -0
- package/dist/esm/src/components/Select/Select.js +583 -0
- package/dist/esm/src/components/Select/Select.styl.js +7 -0
- package/dist/esm/src/components/Spinner/Spinner.js +11 -0
- package/dist/esm/src/components/Spinner/Spinner.styl.js +7 -0
- package/dist/esm/src/components/Spinner/spinner.svg.js +24 -0
- package/dist/esm/src/components/Table/Table.js +24 -0
- package/dist/esm/src/components/Table/Table.styl.js +7 -0
- package/dist/esm/src/components/Tabs/Tabs.js +43 -0
- package/dist/esm/src/components/Tabs/Tabs.styl.js +7 -0
- package/dist/esm/src/components/Text/Text.js +44 -0
- package/dist/esm/src/components/Text/Text.styl.js +7 -0
- package/dist/esm/src/components/Theme/Theme.defaults.js +50 -0
- package/dist/esm/src/components/Theme/Theme.helpers.js +67 -0
- package/dist/esm/src/components/Theme/Theme.js +13 -0
- package/dist/esm/src/components/VH/VH.js +33 -0
- package/dist/esm/src/components/Virtualized/List/List.js +124 -0
- package/dist/esm/src/components/Virtualized/List/List.styl.js +7 -0
- package/dist/esm/src/components/Virtualized/List/ListScroll.js +21 -0
- package/dist/esm/src/components/Virtualized/List/ListScroll.styl.js +7 -0
- package/dist/esm/src/components/Virtualized/Virtualized.helpers.js +14 -0
- package/dist/esm/src/components/Virtualized/Virtualized.js +200 -0
- package/dist/esm/src/components/Virtualized/Virtualized.styl.js +7 -0
- package/dist/esm/src/components/Virtualized/Virtualized.types.js +1 -0
- package/dist/esm/src/services/i18n.js +68 -0
- package/dist/esm/src/tools/array.js +60 -0
- package/dist/esm/src/tools/config.js +9 -0
- package/dist/esm/src/tools/debounce.js +11 -0
- package/dist/esm/src/tools/dom.js +46 -0
- package/dist/esm/src/tools/env.js +3 -0
- package/dist/esm/src/tools/file.js +11 -0
- package/dist/esm/src/tools/localStorage.js +31 -0
- package/dist/esm/src/tools/number.js +27 -0
- package/dist/esm/src/tools/object.js +5 -0
- package/dist/esm/src/tools/queryParams.js +20 -0
- package/dist/esm/src/tools/rangeMap.js +3 -0
- package/dist/esm/src/tools/resizeObserver.js +64 -0
- package/dist/esm/src/tools/scroll.js +41 -0
- package/dist/esm/src/tools/string.js +7 -0
- package/dist/esm/src/tools/throttle.js +30 -0
- package/dist/esm/src/tools/uid.js +7 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/src/components/AssistiveText/AssistiveText.d.ts +3 -0
- package/dist/esm/types/src/components/AssistiveText/AssistiveText.types.d.ts +7 -0
- package/dist/esm/types/src/components/Button/Button.d.ts +4 -0
- package/dist/esm/types/src/components/Button/Button.helpers.d.ts +1 -0
- package/dist/esm/types/src/components/Button/Button.types.d.ts +14 -0
- package/dist/esm/types/src/components/ButtonGroup/ButtonGroup.d.ts +3 -0
- package/dist/esm/types/src/components/ButtonGroup/ButtonGroup.types.d.ts +5 -0
- package/dist/esm/types/src/components/Checkbox/Checkbox.d.ts +18 -0
- package/dist/esm/types/src/components/Checkbox/Checkbox.types.d.ts +10 -0
- package/dist/esm/types/src/components/Container/Container.d.ts +3 -0
- package/dist/esm/types/src/components/Container/Container.types.d.ts +13 -0
- package/dist/esm/types/src/components/DateTime/DateTime.d.ts +8 -0
- package/dist/esm/types/src/components/DateTime/DateTime.types.d.ts +6 -0
- package/dist/esm/types/src/components/Draggable/Draggable.d.ts +24 -0
- package/dist/esm/types/src/components/Draggable/Draggable.types.d.ts +11 -0
- package/dist/esm/types/src/components/Expand/Expand.d.ts +3 -0
- package/dist/esm/types/src/components/Expand/Expand.types.d.ts +16 -0
- package/dist/esm/types/src/components/Form/Form.d.ts +32 -0
- package/dist/esm/types/src/components/Form/Form.helpers.d.ts +6 -0
- package/dist/esm/types/src/components/Form/Form.types.d.ts +71 -0
- package/dist/esm/types/src/components/Form/SubmitButtons/SubmitButtons.d.ts +13 -0
- package/dist/esm/types/src/components/Form/Validator.d.ts +2 -0
- package/dist/esm/types/src/components/Form/index.d.ts +2 -0
- package/dist/esm/types/src/components/Gallery/Dots/Dots.d.ts +5 -0
- package/dist/esm/types/src/components/Gallery/Gallery.d.ts +36 -0
- package/dist/esm/types/src/components/Gallery/Gallery.types.d.ts +12 -0
- package/dist/esm/types/src/components/Heading/Heading.d.ts +3 -0
- package/dist/esm/types/src/components/Heading/Heading.types.d.ts +5 -0
- package/dist/esm/types/src/components/Icon/Icon.d.ts +45 -0
- package/dist/esm/types/src/components/Icon/Icon.example.d.ts +3 -0
- package/dist/esm/types/src/components/Icon/Icon.helpers.d.ts +1 -0
- package/dist/esm/types/src/components/Icon/Icon.types.d.ts +8 -0
- package/dist/esm/types/src/components/Icon/icons/index.d.ts +39 -0
- package/dist/esm/types/src/components/Input/Input.d.ts +42 -0
- package/dist/esm/types/src/components/Input/Input.types.d.ts +21 -0
- package/dist/esm/types/src/components/InputFile/InputFile.d.ts +48 -0
- package/dist/esm/types/src/components/InputFile/InputFile.types.d.ts +22 -0
- package/dist/esm/types/src/components/InputFile/Item/Item.d.ts +16 -0
- package/dist/esm/types/src/components/Label/Label.d.ts +19 -0
- package/dist/esm/types/src/components/Label/Label.helpers.d.ts +1 -0
- package/dist/esm/types/src/components/Label/Label.types.d.ts +8 -0
- package/dist/esm/types/src/components/Lazy/Lazy.d.ts +18 -0
- package/dist/esm/types/src/components/Lazy/Lazy.types.d.ts +15 -0
- package/dist/esm/types/src/components/LightBox/LightBox.d.ts +3 -0
- package/dist/esm/types/src/components/LightBox/LightBox.types.d.ts +7 -0
- package/dist/esm/types/src/components/Notifications/Notifications.d.ts +2 -0
- package/dist/esm/types/src/components/Notifications/Notifications.types.d.ts +19 -0
- package/dist/esm/types/src/components/Notifications/store.d.ts +2 -0
- package/dist/esm/types/src/components/Paranja/Paranja.d.ts +3 -0
- package/dist/esm/types/src/components/Paranja/Paranja.types.d.ts +8 -0
- package/dist/esm/types/src/components/Popup/Popup.d.ts +73 -0
- package/dist/esm/types/src/components/Popup/Popup.helpers.d.ts +8 -0
- package/dist/esm/types/src/components/Popup/Popup.types.d.ts +34 -0
- package/dist/esm/types/src/components/PopupMenu/PopupMenu.d.ts +3 -0
- package/dist/esm/types/src/components/PopupMenu/PopupMenu.types.d.ts +13 -0
- package/dist/esm/types/src/components/Portal/Portal.d.ts +7 -0
- package/dist/esm/types/src/components/RequiredStar/RequiredStar.d.ts +3 -0
- package/dist/esm/types/src/components/RequiredStar/RequiredStar.types.d.ts +6 -0
- package/dist/esm/types/src/components/Router/Link/Link.d.ts +1 -0
- package/dist/esm/types/src/components/Router/Link/Link.types.d.ts +12 -0
- package/dist/esm/types/src/components/Router/Redirect.d.ts +5 -0
- package/dist/esm/types/src/components/Router/Route.d.ts +5 -0
- package/dist/esm/types/src/components/Router/Router.d.ts +7 -0
- package/dist/esm/types/src/components/Router/Router.helpers.d.ts +2 -0
- package/dist/esm/types/src/components/Router/Router.types.d.ts +18 -0
- package/dist/esm/types/src/components/Router/context.d.ts +6 -0
- package/dist/esm/types/src/components/Router/store.d.ts +2 -0
- package/dist/esm/types/src/components/Scroll/Scroll.d.ts +67 -0
- package/dist/esm/types/src/components/Scroll/Scroll.types.d.ts +27 -0
- package/dist/esm/types/src/components/Select/Select.d.ts +94 -0
- package/dist/esm/types/src/components/Select/Select.helpers.d.ts +14 -0
- package/dist/esm/types/src/components/Select/Select.types.d.ts +74 -0
- package/dist/esm/types/src/components/Spinner/Spinner.d.ts +3 -0
- package/dist/esm/types/src/components/Spinner/Spinner.types.d.ts +4 -0
- package/dist/esm/types/src/components/Table/Table.d.ts +8 -0
- package/dist/esm/types/src/components/Table/Table.types.d.ts +19 -0
- package/dist/esm/types/src/components/Tabs/Tabs.d.ts +3 -0
- package/dist/esm/types/src/components/Tabs/Tabs.types.d.ts +27 -0
- package/dist/esm/types/src/components/Text/Text.d.ts +7 -0
- package/dist/esm/types/src/components/Theme/Theme.d.ts +5 -0
- package/dist/esm/types/src/components/Theme/Theme.defaults.d.ts +32 -0
- package/dist/esm/types/src/components/Theme/Theme.helpers.d.ts +15 -0
- package/dist/esm/types/src/components/Theme/Theme.types.d.ts +6 -0
- package/dist/esm/types/src/components/VH/VH.d.ts +12 -0
- package/dist/esm/types/src/components/Virtualized/Cards/Cards.d.ts +26 -0
- package/dist/esm/types/src/components/Virtualized/List/List.d.ts +44 -0
- package/dist/esm/types/src/components/Virtualized/List/ListScroll.d.ts +8 -0
- package/dist/esm/types/src/components/Virtualized/Table/Table.d.ts +26 -0
- package/dist/esm/types/src/components/Virtualized/Virtualized.d.ts +34 -0
- package/dist/esm/types/src/components/Virtualized/Virtualized.helpers.d.ts +18 -0
- package/dist/esm/types/src/components/Virtualized/Virtualized.types.d.ts +53 -0
- package/dist/esm/types/src/components/Virtualized/index.d.ts +4 -0
- package/dist/esm/types/src/components/index.d.ts +33 -0
- package/dist/esm/types/src/index.d.ts +3 -0
- package/dist/esm/types/src/services/i18n.d.ts +16 -0
- package/dist/esm/types/src/services/index.d.ts +1 -0
- package/dist/esm/types/src/tools/array.d.ts +8 -0
- package/dist/esm/types/src/tools/config.d.ts +10 -0
- package/dist/esm/types/src/tools/debounce.d.ts +1 -0
- package/dist/esm/types/src/tools/dom.d.ts +12 -0
- package/dist/esm/types/src/tools/env.d.ts +1 -0
- package/dist/esm/types/src/tools/file.d.ts +1 -0
- package/dist/esm/types/src/tools/index.d.ts +16 -0
- package/dist/esm/types/src/tools/localStorage.d.ts +12 -0
- package/dist/esm/types/src/tools/number.d.ts +5 -0
- package/dist/esm/types/src/tools/object.d.ts +1 -0
- package/dist/esm/types/src/tools/queryParams.d.ts +3 -0
- package/dist/esm/types/src/tools/rangeMap.d.ts +2 -0
- package/dist/esm/types/src/tools/resizeObserver.d.ts +2 -0
- package/dist/esm/types/src/tools/scroll.d.ts +5 -0
- package/dist/esm/types/src/tools/string.d.ts +1 -0
- package/dist/esm/types/src/tools/throttle.d.ts +6 -0
- package/dist/esm/types/src/tools/uid.d.ts +1 -0
- package/dist/esm/types/src/types.d.ts +15 -0
- package/package.json +117 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createStore } from 'justorm/react';
|
|
2
|
+
import Time from 'timen';
|
|
3
|
+
import { spliceWhere } from '../../tools/array.js';
|
|
4
|
+
import { generateUID } from '../../tools/uid.js';
|
|
5
|
+
import C from './Notifications.constants.json.js';
|
|
6
|
+
|
|
7
|
+
const SHOW_TIME = 5000;
|
|
8
|
+
const STORE = createStore('notifications', {
|
|
9
|
+
items: [],
|
|
10
|
+
autohide: [],
|
|
11
|
+
data: {},
|
|
12
|
+
paused: false,
|
|
13
|
+
show(data) {
|
|
14
|
+
const id = generateUID();
|
|
15
|
+
this.items.push(id);
|
|
16
|
+
this.data[id] = {
|
|
17
|
+
...data,
|
|
18
|
+
createdAt: Date.now(),
|
|
19
|
+
};
|
|
20
|
+
Time.after(C.ANIMATION_DURATION, () => (this.data[id].visible = true));
|
|
21
|
+
if (data.autohide !== false) {
|
|
22
|
+
this.autohide.push(id);
|
|
23
|
+
}
|
|
24
|
+
return id;
|
|
25
|
+
},
|
|
26
|
+
pause() {
|
|
27
|
+
this.paused = true;
|
|
28
|
+
this.pausedAt = Date.now();
|
|
29
|
+
},
|
|
30
|
+
unpause() {
|
|
31
|
+
const pauseTime = Date.now() - this.pausedAt;
|
|
32
|
+
this.autohide.forEach(id => {
|
|
33
|
+
this.data[id].createdAt += pauseTime;
|
|
34
|
+
});
|
|
35
|
+
this.paused = false;
|
|
36
|
+
},
|
|
37
|
+
close(id) {
|
|
38
|
+
this.data[id].visible = false;
|
|
39
|
+
Time.after(C.ANIMATION_DURATION, () => this.remove(id));
|
|
40
|
+
},
|
|
41
|
+
remove(id) {
|
|
42
|
+
spliceWhere(this.autohide, id);
|
|
43
|
+
spliceWhere(this.items, id);
|
|
44
|
+
delete this.data[id];
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
// worker
|
|
48
|
+
Time.every(50, function tick() {
|
|
49
|
+
const { paused, autohide, data } = STORE;
|
|
50
|
+
if (paused || autohide.length === 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const id = autohide[0]; // TODO: move trough all autohide until some will !readyToHide
|
|
54
|
+
const item = data[id];
|
|
55
|
+
const readyToHide = Date.now() - item.createdAt > SHOW_TIME;
|
|
56
|
+
if (item.visible && readyToHide) {
|
|
57
|
+
item.visible = false;
|
|
58
|
+
Time.after(C.ANIMATION_DURATION, () => STORE.remove(id));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export { STORE as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Portal } from '../Portal/Portal.js';
|
|
4
|
+
import S from './Paranja.styl.js';
|
|
5
|
+
|
|
6
|
+
const Paranja = ({ className, children, visible = true, inline = false, blur = false, }) => {
|
|
7
|
+
const classes = cn(S.root, visible && S.visible, blur && S.blur, className);
|
|
8
|
+
const node = jsx("div", { className: classes, children: children });
|
|
9
|
+
if (inline)
|
|
10
|
+
return node;
|
|
11
|
+
return jsx(Portal, { children: node });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { Paranja };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Paranja_root__ddboV{align-items:center;background-color:var(--decent-color-alpha-900);bottom:0;display:flex;justify-content:center;left:0;opacity:0;pointer-events:none;position:absolute;right:0;top:0;transition:opacity .2s ease-out;z-index:10}.Paranja_visible__xZukG{opacity:1;pointer-events:all}.Paranja_visible__xZukG.Paranja_blur__Hg0SQ{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px);background-color:var(--decent-color-alpha-500)}";
|
|
4
|
+
var S = {"root":"Paranja_root__ddboV","visible":"Paranja_visible__xZukG","blur":"Paranja_blur__Hg0SQ"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { spliceWhere } from '../../tools/array.js';
|
|
2
|
+
import 'nanoid';
|
|
3
|
+
import '../../tools/dom.js';
|
|
4
|
+
import 'timen';
|
|
5
|
+
import 'compareq';
|
|
6
|
+
import 'lodash.pick';
|
|
7
|
+
import '../../tools/queryParams.js';
|
|
8
|
+
|
|
9
|
+
const childs = {};
|
|
10
|
+
let popupIds = 0;
|
|
11
|
+
const getId = () => ++popupIds;
|
|
12
|
+
const getPopupId = (elem, attr = 'data-popup-id') => {
|
|
13
|
+
const id = elem.getAttribute(attr);
|
|
14
|
+
return id ? parseInt(id, 10) : null;
|
|
15
|
+
};
|
|
16
|
+
function isLastChild(rootId, id) {
|
|
17
|
+
const ids = childs[rootId];
|
|
18
|
+
return ids && ids[ids.length - 1] === id;
|
|
19
|
+
}
|
|
20
|
+
function setChild(rootId, id) {
|
|
21
|
+
if (!childs[rootId])
|
|
22
|
+
childs[rootId] = [];
|
|
23
|
+
childs[rootId].push(id);
|
|
24
|
+
}
|
|
25
|
+
function unsetChild(rootId, id) {
|
|
26
|
+
spliceWhere(childs[rootId], id);
|
|
27
|
+
if (!childs[rootId].length)
|
|
28
|
+
delete childs[rootId];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { childs, getId, getPopupId, isLastChild, setChild, unsetChild };
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Component, createRef } from 'react';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { createStore } from 'justorm/react';
|
|
5
|
+
import Time from 'timen';
|
|
6
|
+
import { Paranja } from '../Paranja/Paranja.js';
|
|
7
|
+
import { Portal } from '../Portal/Portal.js';
|
|
8
|
+
import { getCoords } from '../../tools/dom.js';
|
|
9
|
+
import { observe, unobserve } from '../../tools/resizeObserver.js';
|
|
10
|
+
import { isBrowser } from '../../tools/env.js';
|
|
11
|
+
import debounce from '../../tools/debounce.js';
|
|
12
|
+
import throttle from '../../tools/throttle.js';
|
|
13
|
+
import S from './Popup.styl.js';
|
|
14
|
+
import { getId, getPopupId, isLastChild, unsetChild, childs, setChild } from './Popup.helpers.js';
|
|
15
|
+
|
|
16
|
+
const ANIMATION_DURATION = 100;
|
|
17
|
+
const OFFSET_GAP = 10;
|
|
18
|
+
const INITIAL_OFFSET = { top: 0, left: 0 };
|
|
19
|
+
class Popup extends Component {
|
|
20
|
+
rootElem = createRef();
|
|
21
|
+
triggerElem = createRef();
|
|
22
|
+
containerElem = null;
|
|
23
|
+
onContainerElemRef = elem => {
|
|
24
|
+
this.containerElem = elem;
|
|
25
|
+
// TODO: useElemResize(elem, callback)
|
|
26
|
+
if (elem) {
|
|
27
|
+
this.unsubscribeSizeChange();
|
|
28
|
+
this.subscribeSizeChange();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
focused = false;
|
|
32
|
+
pointerPressed = false;
|
|
33
|
+
subscribedHoverControl = false;
|
|
34
|
+
subscribedSizeChange = false;
|
|
35
|
+
pointerDownTarget = null;
|
|
36
|
+
isPointerPressedInside = false;
|
|
37
|
+
needDropOffset = false;
|
|
38
|
+
id;
|
|
39
|
+
parentPopupContent;
|
|
40
|
+
store;
|
|
41
|
+
timers = Time.create();
|
|
42
|
+
scrollParent;
|
|
43
|
+
offset = { ...INITIAL_OFFSET };
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
size: 'm',
|
|
46
|
+
direction: '',
|
|
47
|
+
animated: true,
|
|
48
|
+
};
|
|
49
|
+
constructor(props) {
|
|
50
|
+
super(props);
|
|
51
|
+
const isOpen = Boolean(props.isOpen);
|
|
52
|
+
this.id = getId();
|
|
53
|
+
this.store = createStore(this, {
|
|
54
|
+
rootPopupId: null,
|
|
55
|
+
isOpen,
|
|
56
|
+
isContentVisible: isOpen,
|
|
57
|
+
animating: false,
|
|
58
|
+
direction: props.direction,
|
|
59
|
+
triggerBounds: null,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
componentDidMount() {
|
|
63
|
+
const { hoverControl, focusControl } = this.props;
|
|
64
|
+
const parentPopupContent = this.triggerElem.current.closest(`.${S.content}`);
|
|
65
|
+
document.addEventListener('pointerdown', this.onDocPointerDown, true);
|
|
66
|
+
document.addEventListener('pointerup', this.onDocPointerUp, true);
|
|
67
|
+
if (parentPopupContent) {
|
|
68
|
+
this.store.rootPopupId =
|
|
69
|
+
getPopupId(parentPopupContent, 'data-root-popup-id') ||
|
|
70
|
+
getPopupId(parentPopupContent, 'data-popup-id');
|
|
71
|
+
}
|
|
72
|
+
if (focusControl) {
|
|
73
|
+
document.addEventListener('keydown', this.onDocKeyDown, true);
|
|
74
|
+
document.addEventListener('keyup', this.onDocKeyUp);
|
|
75
|
+
}
|
|
76
|
+
if (hoverControl)
|
|
77
|
+
this.subscribeHoverControl();
|
|
78
|
+
this.subscribeScroll();
|
|
79
|
+
}
|
|
80
|
+
componentDidUpdate(prevProps) {
|
|
81
|
+
const { isOpen, disabled, hoverControl } = this.props;
|
|
82
|
+
if (disabled) {
|
|
83
|
+
this.store.isOpen = false; // close when receive disabled=true
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!prevProps.hoverControl && hoverControl)
|
|
87
|
+
this.subscribeHoverControl();
|
|
88
|
+
if (prevProps.hoverControl && !hoverControl)
|
|
89
|
+
this.unsubscribeHoverControl();
|
|
90
|
+
if (typeof isOpen === 'boolean' && isOpen !== prevProps.isOpen) {
|
|
91
|
+
isOpen ? this.open() : this.close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
componentWillUnmount() {
|
|
95
|
+
this.timers.clear();
|
|
96
|
+
document.removeEventListener('keyup', this.onDocKeyUp, true);
|
|
97
|
+
if (this.scrollParent) {
|
|
98
|
+
this.scrollParent.removeEventListener('scroll', this.close);
|
|
99
|
+
}
|
|
100
|
+
this.unsubscribeHoverControl();
|
|
101
|
+
this.unsubscribeSizeChange();
|
|
102
|
+
this.unsubscribeScroll();
|
|
103
|
+
}
|
|
104
|
+
subscribeSizeChange() {
|
|
105
|
+
if (this.subscribedSizeChange)
|
|
106
|
+
return;
|
|
107
|
+
this.subscribedSizeChange = true;
|
|
108
|
+
observe(this.triggerElem.current, this.onTriggerResize);
|
|
109
|
+
observe(this.containerElem, this.onContainerResize);
|
|
110
|
+
}
|
|
111
|
+
subscribeScroll() {
|
|
112
|
+
if (isBrowser && !this.props.inline) {
|
|
113
|
+
document.addEventListener('scroll', this.onScroll, true);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
unsubscribeScroll() {
|
|
117
|
+
document.removeEventListener('scroll', this.onScroll, true);
|
|
118
|
+
}
|
|
119
|
+
unsubscribeSizeChange() {
|
|
120
|
+
this.subscribedSizeChange = false;
|
|
121
|
+
unobserve(this.triggerElem.current);
|
|
122
|
+
unobserve(this.containerElem);
|
|
123
|
+
}
|
|
124
|
+
subscribeHoverControl() {
|
|
125
|
+
if (this.subscribedHoverControl)
|
|
126
|
+
return;
|
|
127
|
+
this.subscribedHoverControl = true;
|
|
128
|
+
document.addEventListener('pointermove', this.checkHover);
|
|
129
|
+
document.addEventListener('pointerup', this.checkHover);
|
|
130
|
+
}
|
|
131
|
+
unsubscribeHoverControl() {
|
|
132
|
+
if (!this.subscribedHoverControl)
|
|
133
|
+
return;
|
|
134
|
+
this.subscribedHoverControl = false;
|
|
135
|
+
document.removeEventListener('pointermove', this.checkHover);
|
|
136
|
+
document.removeEventListener('pointerup', this.checkHover);
|
|
137
|
+
}
|
|
138
|
+
updateBounds() {
|
|
139
|
+
if (this.store.animating || !this.containerElem)
|
|
140
|
+
return;
|
|
141
|
+
if (!this.triggerElem.current)
|
|
142
|
+
return;
|
|
143
|
+
this.updateBoundsThrottled();
|
|
144
|
+
}
|
|
145
|
+
updateBoundsThrottled = throttle(() => {
|
|
146
|
+
const trigger = this.triggerElem.current;
|
|
147
|
+
const bounds = {
|
|
148
|
+
minHeight: trigger.offsetHeight,
|
|
149
|
+
minWidth: trigger.offsetWidth,
|
|
150
|
+
...getCoords(trigger),
|
|
151
|
+
};
|
|
152
|
+
Object.entries(bounds).forEach(([key, value]) => {
|
|
153
|
+
this.triggerElem.current.style[key] = value;
|
|
154
|
+
});
|
|
155
|
+
this.updateOffset();
|
|
156
|
+
this.store.triggerBounds = bounds;
|
|
157
|
+
}, 200, { trailing: true });
|
|
158
|
+
prevContentBounds = { width: 0, height: 0 };
|
|
159
|
+
updateOffset = () => {
|
|
160
|
+
const content = this.containerElem.getBoundingClientRect();
|
|
161
|
+
if (!content.height ||
|
|
162
|
+
!content.width ||
|
|
163
|
+
this.prevContentBounds.width !== content.width ||
|
|
164
|
+
this.prevContentBounds.height !== content.height) {
|
|
165
|
+
this.prevContentBounds = content;
|
|
166
|
+
Time.after(100, this.updateOffset);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const { offset } = this;
|
|
170
|
+
const { innerHeight, innerWidth } = window;
|
|
171
|
+
const bottom = content.top + content.height + OFFSET_GAP - offset.top;
|
|
172
|
+
const right = content.left + content.width + OFFSET_GAP - offset.left;
|
|
173
|
+
if (content.top < 0) {
|
|
174
|
+
offset.top = -content.top + OFFSET_GAP;
|
|
175
|
+
}
|
|
176
|
+
else if (bottom > innerHeight) {
|
|
177
|
+
offset.top = innerHeight - bottom;
|
|
178
|
+
}
|
|
179
|
+
if (content.left < 0) {
|
|
180
|
+
offset.left = -content.left + OFFSET_GAP;
|
|
181
|
+
}
|
|
182
|
+
else if (right > innerWidth) {
|
|
183
|
+
offset.left = innerWidth - right;
|
|
184
|
+
}
|
|
185
|
+
this.applyOffset();
|
|
186
|
+
};
|
|
187
|
+
applyOffset() {
|
|
188
|
+
const { left, top } = this.offset;
|
|
189
|
+
this.containerElem.style.marginTop = `${top}px`;
|
|
190
|
+
this.containerElem.style.marginLeft = `${left}px`;
|
|
191
|
+
}
|
|
192
|
+
checkHover = debounce((e) => {
|
|
193
|
+
if (this.isPointerPressedInside)
|
|
194
|
+
return;
|
|
195
|
+
const { isOpen, rootPopupId } = this.store;
|
|
196
|
+
const overTrigger = this.isPointerOver(e.target, S.trigger);
|
|
197
|
+
const overContent = this.isPointerOver(e.target, S.content);
|
|
198
|
+
if (!isOpen) {
|
|
199
|
+
if (overTrigger)
|
|
200
|
+
this.open();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// isOpen
|
|
204
|
+
if (overTrigger || overContent)
|
|
205
|
+
return;
|
|
206
|
+
if (typeof rootPopupId === 'number') {
|
|
207
|
+
if (isLastChild(rootPopupId, this.id)) {
|
|
208
|
+
this.close();
|
|
209
|
+
unsetChild(rootPopupId, this.id);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const isOverAnyPopupContent = e.target.closest(`.${S.content}`);
|
|
214
|
+
if (!isOverAnyPopupContent || !childs[this.id]?.length) {
|
|
215
|
+
this.close();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}, 100);
|
|
219
|
+
isLastClickInside = () => this.pointerDownTarget &&
|
|
220
|
+
(this.pointerDownTarget.closest(`.${S.trigger}`) ||
|
|
221
|
+
this.pointerDownTarget.closest(`.${S.content}`));
|
|
222
|
+
onDocPointerDown = (e) => {
|
|
223
|
+
this.pointerDownTarget = e.target;
|
|
224
|
+
this.isPointerPressedInside = this.isLastClickInside();
|
|
225
|
+
this.timers.after(100, () => (this.pointerDownTarget = null));
|
|
226
|
+
};
|
|
227
|
+
onDocPointerUp = (e) => {
|
|
228
|
+
if (!this.isPointerPressedInside)
|
|
229
|
+
this.close();
|
|
230
|
+
this.isPointerPressedInside = false;
|
|
231
|
+
};
|
|
232
|
+
isPointerOver(target, elem) {
|
|
233
|
+
return target.closest(`.${elem}[data-popup-id="${this.id}"]`);
|
|
234
|
+
}
|
|
235
|
+
onScroll = throttle(e => {
|
|
236
|
+
if (!this.store.isOpen) {
|
|
237
|
+
const { top, left } = this.offset;
|
|
238
|
+
if (left || top) {
|
|
239
|
+
this.offset = { ...INITIAL_OFFSET };
|
|
240
|
+
this.applyOffset();
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
// if scrolling outside this popup - close it
|
|
245
|
+
if (!this.isPointerOver(e.target, S.content)) {
|
|
246
|
+
this.needDropOffset = true;
|
|
247
|
+
this.close();
|
|
248
|
+
}
|
|
249
|
+
}, 200);
|
|
250
|
+
onDocKeyDown = (e) => {
|
|
251
|
+
this.pointerDownTarget = null;
|
|
252
|
+
};
|
|
253
|
+
onDocKeyUp = (e) => {
|
|
254
|
+
if (this.store.isOpen && e.key === 'Escape') {
|
|
255
|
+
e.stopPropagation();
|
|
256
|
+
this.close();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (this.focused && /Enter| /.test(e.key)) {
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
this.toggle();
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
onTriggerPointerDown = e => {
|
|
265
|
+
this.pointerDownTarget = e.target;
|
|
266
|
+
this.pointerPressed = true;
|
|
267
|
+
};
|
|
268
|
+
onTriggerPointerUp = e => {
|
|
269
|
+
this.pointerPressed = false;
|
|
270
|
+
if (e.traget === this.pointerDownTarget)
|
|
271
|
+
this.toggle();
|
|
272
|
+
};
|
|
273
|
+
onFocus = e => {
|
|
274
|
+
this.focused = true;
|
|
275
|
+
this.props.triggerProps?.onFocus?.(e);
|
|
276
|
+
if (!this.pointerPressed)
|
|
277
|
+
this.open();
|
|
278
|
+
};
|
|
279
|
+
onBlur = e => {
|
|
280
|
+
this.focused = false;
|
|
281
|
+
this.props.triggerProps?.onBlur?.(e);
|
|
282
|
+
// give time to fire clicks inside popup
|
|
283
|
+
this.timers.after(80, () => {
|
|
284
|
+
if (!this.isLastClickInside())
|
|
285
|
+
this.close();
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
onTriggerResize = () => {
|
|
289
|
+
this.updateBounds();
|
|
290
|
+
};
|
|
291
|
+
onContainerResize = () => {
|
|
292
|
+
this.updateBounds();
|
|
293
|
+
};
|
|
294
|
+
open = throttle(() => {
|
|
295
|
+
const { rootPopupId } = this.store;
|
|
296
|
+
if (this.store.isOpen)
|
|
297
|
+
return;
|
|
298
|
+
this.updateBounds();
|
|
299
|
+
this.subscribeSizeChange();
|
|
300
|
+
this.subscribeScroll();
|
|
301
|
+
this.store.isContentVisible = true;
|
|
302
|
+
this.changeState(true, this.afterOpen);
|
|
303
|
+
if (rootPopupId)
|
|
304
|
+
setChild(rootPopupId, this.id);
|
|
305
|
+
}, 100);
|
|
306
|
+
close = () => {
|
|
307
|
+
if (!this.store.isOpen)
|
|
308
|
+
return;
|
|
309
|
+
this.unsubscribeSizeChange();
|
|
310
|
+
this.changeState(false, this.afterClose);
|
|
311
|
+
};
|
|
312
|
+
changeState(isOpen, callback) {
|
|
313
|
+
const { animated } = this.props;
|
|
314
|
+
this.timers.clear();
|
|
315
|
+
this.store.isOpen = isOpen;
|
|
316
|
+
if (animated) {
|
|
317
|
+
this.store.animating = true;
|
|
318
|
+
this.timers.after(ANIMATION_DURATION + 500, () => {
|
|
319
|
+
this.store.animating = false;
|
|
320
|
+
callback();
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
callback();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
afterOpen = () => {
|
|
328
|
+
this.props.onOpen?.();
|
|
329
|
+
};
|
|
330
|
+
afterClose = () => {
|
|
331
|
+
this.store.isContentVisible = false;
|
|
332
|
+
this.dropOffset();
|
|
333
|
+
this.props.onClose?.();
|
|
334
|
+
};
|
|
335
|
+
dropOffset() {
|
|
336
|
+
if (!this.needDropOffset)
|
|
337
|
+
return;
|
|
338
|
+
this.offset = { ...INITIAL_OFFSET };
|
|
339
|
+
this.applyOffset();
|
|
340
|
+
}
|
|
341
|
+
toggle = throttle(() => {
|
|
342
|
+
this.store.isOpen ? this.close() : this.open();
|
|
343
|
+
}, 100);
|
|
344
|
+
renderTrigger() {
|
|
345
|
+
const { trigger, content, disabled, focusControl, hoverControl, ...rest } = this.props;
|
|
346
|
+
const triggerProps = { ...rest.triggerProps };
|
|
347
|
+
const { isOpen } = this.store;
|
|
348
|
+
if (!trigger)
|
|
349
|
+
return null;
|
|
350
|
+
const disableTrigger = disabled || !content;
|
|
351
|
+
const classesTrigger = cn(S.trigger, isOpen && S.isOpen, disableTrigger && S.disabled, triggerProps.className);
|
|
352
|
+
if (!disableTrigger) {
|
|
353
|
+
triggerProps.role = 'button';
|
|
354
|
+
if (hoverControl) {
|
|
355
|
+
Object.assign(triggerProps, {
|
|
356
|
+
onPointerDown: this.onTriggerPointerDown,
|
|
357
|
+
onPointerUp: this.onTriggerPointerUp,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (focusControl) {
|
|
361
|
+
Object.assign(triggerProps, {
|
|
362
|
+
onFocus: this.onFocus,
|
|
363
|
+
onBlur: this.onBlur,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return (jsx("div", { className: classesTrigger, ...triggerProps, suppressHydrationWarning: true, "data-popup-id": this.id, ref: this.triggerElem, children: trigger }));
|
|
368
|
+
}
|
|
369
|
+
renderContent() {
|
|
370
|
+
const { content, contentProps = {}, wrapperProps = {}, size, disabled, inline, outlined, animated, paranja, blur, elevation, } = this.props;
|
|
371
|
+
const { isOpen, isContentVisible, animating, direction, triggerBounds, rootPopupId, } = this.store;
|
|
372
|
+
if (disabled)
|
|
373
|
+
return null;
|
|
374
|
+
const wrapperClasses = cn(S.contentWrapper, blur && S.blur, inline && S.inline, isOpen && S.isOpen, wrapperProps.className);
|
|
375
|
+
const trigger = this.triggerElem.current;
|
|
376
|
+
const [axis, float] = direction.split('-');
|
|
377
|
+
const classes = cn(S.content, outlined && S.outlined, animated && animating && S.animating, elevation && S[`elevation-${elevation}`], S[`size-${size}`], S[`axis-${axis}`], S[`float-${float || 'middle'}`], contentProps.className);
|
|
378
|
+
if (trigger && !inline && triggerBounds) {
|
|
379
|
+
wrapperProps.style = { ...triggerBounds };
|
|
380
|
+
}
|
|
381
|
+
const contentNode = (jsx("div", { ...wrapperProps, className: wrapperClasses, children: jsxs("div", { ...contentProps, ref: this.onContainerElemRef, className: classes, suppressHydrationWarning: true, "data-popup-id": this.id, "data-root-popup-id": rootPopupId, style: {
|
|
382
|
+
marginTop: this.offset.top,
|
|
383
|
+
marginLeft: this.offset.left,
|
|
384
|
+
}, children: [paranja && !rootPopupId && (jsx(Paranja, { visible: isContentVisible, blur: blur })), isContentVisible && jsx(Fragment, { children: content })] }) }));
|
|
385
|
+
if (inline)
|
|
386
|
+
return contentNode;
|
|
387
|
+
return jsx(Portal, { children: contentNode });
|
|
388
|
+
}
|
|
389
|
+
render() {
|
|
390
|
+
const { className } = this.props;
|
|
391
|
+
const classes = cn(S.root, className);
|
|
392
|
+
return (jsxs("div", { className: classes, ref: this.rootElem, children: [this.renderTrigger(), this.renderContent()] }));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export { ANIMATION_DURATION, Popup };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Popup_root__uQ-fP{display:inline-block;position:relative}.Popup_contentWrapper__2yi-2{pointer-events:none;position:absolute}.Popup_contentWrapper__2yi-2.Popup_inline__1-l1S.Popup_isOpen__BRIdP{position:relative}.Popup_contentWrapper__2yi-2:not(.Popup_inline__1-l1S),.Popup_contentWrapper__2yi-2:not(.Popup_inline__1-l1S)>.Popup_content__e8Qyu{position:absolute}.Popup_trigger__jQNaQ{cursor:pointer}.Popup_trigger__jQNaQ.Popup_isOpen__BRIdP{position:relative;z-index:11}.Popup_trigger__jQNaQ.Popup_disabled__DlE9y{opacity:.4;pointer-events:none}.Popup_content__e8Qyu{-webkit-backface-visibility:hidden;backface-visibility:hidden;background-color:var(--decent-color);box-shadow:inset 0 0 0 1px var(--accent-color-alpha-100);max-width:70vw;min-width:100%;opacity:0;overflow:hidden;pointer-events:none;position:relative;transform-origin:top center;z-index:11}.Popup_blur__1hfU8 .Popup_content__e8Qyu{-webkit-backdrop-filter:blur(50px);backdrop-filter:blur(50px);background-color:var(--decent-color-alpha-500)}.Popup_content__e8Qyu.Popup_size-s__UmixP{border-radius:4px}.Popup_content__e8Qyu.Popup_size-m__FYpTL{border-radius:6px}.Popup_content__e8Qyu.Popup_size-l__BTS57{border-radius:8px}.Popup_content__e8Qyu.Popup_elevation-1__vmP3e{box-shadow:inset 0 0 0 1px var(--accent-color-alpha-100),0 0 var(--indent-s) 2px var(--decent-color)}.Popup_content__e8Qyu.Popup_elevation-2__Ci4sI{box-shadow:inset 0 0 0 1px var(--accent-color-alpha-100),0 0 var(--indent-m) 2px var(--decent-color)}.Popup_content__e8Qyu.Popup_outlined__g3cJV:after{border-radius:inherit;bottom:0;content:\"\";left:0;pointer-events:none;position:absolute;right:0;top:0}.Popup_isOpen__BRIdP .Popup_content__e8Qyu{opacity:1;pointer-events:all;transform:scaleX(1)}.Popup_animating__kR0qF{transition:70ms ease-out;transition-property:transform,opacity,margin}.Popup_axis-top__BaLgG{bottom:100%}.Popup_axis-bottom__hZwwr{top:100%}.Popup_axis-right__LMYVy{left:100%}.Popup_axis-left__SFKm-{right:100%}.Popup_float-top__8SQAu{bottom:0}.Popup_float-right__mdm-3{left:0}.Popup_float-bottom__7flve{top:0}.Popup_float-left__tz7fX{right:0}.Popup_axis-bottom__hZwwr,.Popup_axis-top__BaLgG{transform:scaleY(.5)}.Popup_axis-bottom__hZwwr.Popup_float-middle__Dmnn1,.Popup_axis-top__BaLgG.Popup_float-middle__Dmnn1{left:50%;transform:translateX(-50%) scaleY(.5)}.Popup_isOpen__BRIdP .Popup_axis-bottom__hZwwr.Popup_float-middle__Dmnn1,.Popup_isOpen__BRIdP .Popup_axis-top__BaLgG.Popup_float-middle__Dmnn1{transform:translateX(-50%) scaleX(1)}.Popup_axis-left__SFKm-,.Popup_axis-right__LMYVy{transform:scaleX(.5)}.Popup_axis-left__SFKm-.Popup_float-middle__Dmnn1,.Popup_axis-right__LMYVy.Popup_float-middle__Dmnn1{top:50%;transform:translateY(-50%) scaleX(.5)}.Popup_isOpen__BRIdP .Popup_axis-left__SFKm-.Popup_float-middle__Dmnn1,.Popup_isOpen__BRIdP .Popup_axis-right__LMYVy.Popup_float-middle__Dmnn1{transform:translateY(-50%) scaleX(1)}.Popup_axis-top__BaLgG.Popup_float-middle__Dmnn1{transform-origin:bottom center}.Popup_axis-top__BaLgG.Popup_float-right__mdm-3{transform-origin:bottom left}.Popup_axis-top__BaLgG.Popup_float-left__tz7fX{transform-origin:bottom right}.Popup_axis-bottom__hZwwr.Popup_float-middle__Dmnn1{transform-origin:top center}.Popup_axis-bottom__hZwwr.Popup_float-right__mdm-3{transform-origin:top left}.Popup_axis-bottom__hZwwr.Popup_float-left__tz7fX{transform-origin:top right}.Popup_axis-right__LMYVy.Popup_float-middle__Dmnn1{transform-origin:center left}.Popup_axis-right__LMYVy.Popup_float-top__8SQAu{transform-origin:bottom left}.Popup_axis-right__LMYVy.Popup_float-bottom__7flve{transform-origin:top left}.Popup_axis-left__SFKm-.Popup_float-middle__Dmnn1{transform-origin:center right}.Popup_axis-left__SFKm-.Popup_float-top__8SQAu{transform-origin:bottom right}.Popup_axis-left__SFKm-.Popup_float-bottom__7flve{transform-origin:top right}";
|
|
4
|
+
var S = {"root":"Popup_root__uQ-fP","contentWrapper":"Popup_contentWrapper__2yi-2","inline":"Popup_inline__1-l1S","isOpen":"Popup_isOpen__BRIdP","content":"Popup_content__e8Qyu","trigger":"Popup_trigger__jQNaQ","disabled":"Popup_disabled__DlE9y","blur":"Popup_blur__1hfU8","size-s":"Popup_size-s__UmixP","size-m":"Popup_size-m__FYpTL","size-l":"Popup_size-l__BTS57","elevation-1":"Popup_elevation-1__vmP3e","elevation-2":"Popup_elevation-2__Ci4sI","outlined":"Popup_outlined__g3cJV","animating":"Popup_animating__kR0qF","axis-top":"Popup_axis-top__BaLgG","axis-bottom":"Popup_axis-bottom__hZwwr","axis-right":"Popup_axis-right__LMYVy","axis-left":"Popup_axis-left__SFKm-","float-top":"Popup_float-top__8SQAu","float-right":"Popup_float-right__mdm-3","float-bottom":"Popup_float-bottom__7flve","float-left":"Popup_float-left__tz7fX","float-middle":"Popup_float-middle__Dmnn1"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { Button } from '../Button/Button.js';
|
|
5
|
+
import { Popup } from '../Popup/Popup.js';
|
|
6
|
+
import S from './PopupMenu.styl.js';
|
|
7
|
+
|
|
8
|
+
function PopupMenu({ items, onClose, ...props }) {
|
|
9
|
+
if (items.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
const { size } = props;
|
|
12
|
+
return (jsx(Popup, { ...props, content: jsx("div", { className: S.list, children: items.map(({ id, title, className, ...rest }) => (createElement(Button, { variant: "clear", size: size, ...rest, className: cn(S.item, className), key: id }, title))) }) }));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { PopupMenu };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".PopupMenu_list__G7xP3{align-items:stretch;border-radius:inherit;display:flex;flex-direction:column;padding:2px}.PopupMenu_item__wxay-+.PopupMenu_item__wxay-{margin-top:2px}.PopupMenu_item__wxay-:first-child{border-top-left-radius:inherit;border-top-right-radius:inherit}.PopupMenu_item__wxay-:last-child{border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}";
|
|
4
|
+
var S = {"list":"PopupMenu_list__G7xP3","item":"PopupMenu_item__wxay-"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { config } from '../../tools/config.js';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_SELECTOR = `#${config.appOverlayId}`;
|
|
7
|
+
function Portal(props) {
|
|
8
|
+
const { selector = DEFAULT_SELECTOR, children } = props;
|
|
9
|
+
const [isMounted, setMounted] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
// prevent HTML mismatch between server and client
|
|
12
|
+
setMounted(true);
|
|
13
|
+
}, []);
|
|
14
|
+
if (!isMounted)
|
|
15
|
+
return null;
|
|
16
|
+
return createPortal(jsx(Fragment, { children: children }), document.querySelector(selector));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { Portal };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Icon } from '../Icon/Icon.js';
|
|
4
|
+
import S from './RequiredStar.styl.js';
|
|
5
|
+
|
|
6
|
+
function RequiredStar(props) {
|
|
7
|
+
const { className, inline, ...rest } = props;
|
|
8
|
+
const classes = cn(S.root, className, inline && S.inline);
|
|
9
|
+
return jsx(Icon, { ...rest, type: "requiredStar", className: classes });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { RequiredStar };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".RequiredStar_root__qZpQW{color:var(--danger-color)!important;pointer-events:none;position:absolute;right:2px;top:2px;transform:scale(.6)}.RequiredStar_inline__328Ou{position:relative;transform:translateY(-.5em)}";
|
|
4
|
+
var S = {"root":"RequiredStar_root__qZpQW","inline":"RequiredStar_inline__328Ou"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useContext, useMemo, useCallback } from 'react';
|
|
3
|
+
import { withStore } from 'justorm/react';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { Icon } from '../../Icon/Icon.js';
|
|
6
|
+
import Context from '../context.js';
|
|
7
|
+
import S from './Link.styl.js';
|
|
8
|
+
|
|
9
|
+
const isStartFromDoubleSlash = href => /^\/\//.test(href);
|
|
10
|
+
const Link = withStore({ router: ['path'] })(({ className, exactClassName, children, href: hrefProp, isClear = false, isDisabled = false, disableExternalIcon = false, inline = false, store: { router }, isPartialExact = false, onClick, ...rest }) => {
|
|
11
|
+
const { path } = router;
|
|
12
|
+
const isFromRoot = isStartFromDoubleSlash(hrefProp);
|
|
13
|
+
const domElem = useRef(null);
|
|
14
|
+
const { basePath } = useContext(Context);
|
|
15
|
+
const isExternal = useMemo(() => /\./.test(hrefProp), [hrefProp]);
|
|
16
|
+
const rootPath = useMemo(() => {
|
|
17
|
+
if (isExternal || isFromRoot)
|
|
18
|
+
return '';
|
|
19
|
+
return basePath ?? '';
|
|
20
|
+
}, [isExternal, isFromRoot, basePath]);
|
|
21
|
+
const href = useMemo(() => {
|
|
22
|
+
let str = hrefProp;
|
|
23
|
+
if (isFromRoot)
|
|
24
|
+
str = str.replace(/^\//, '');
|
|
25
|
+
if (str === '/')
|
|
26
|
+
str = '';
|
|
27
|
+
return `${rootPath}${str}`;
|
|
28
|
+
}, [hrefProp, rootPath]);
|
|
29
|
+
const handleClick = useCallback(e => {
|
|
30
|
+
onClick?.(e, href);
|
|
31
|
+
if (!isExternal && router.path !== href) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
if (e.ctrlKey || e.metaKey) {
|
|
34
|
+
window.open(href, '_blank');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
router.go(href);
|
|
38
|
+
}
|
|
39
|
+
domElem.current?.blur();
|
|
40
|
+
}
|
|
41
|
+
}, [href, isExternal, onClick]);
|
|
42
|
+
const isExact = useMemo(() => {
|
|
43
|
+
if (isPartialExact)
|
|
44
|
+
return path.startsWith(href);
|
|
45
|
+
return path === href;
|
|
46
|
+
}, [path, href, isPartialExact]);
|
|
47
|
+
const props = { ...rest, href };
|
|
48
|
+
const isNested = !/^\//.test(href) && !isExternal;
|
|
49
|
+
const classes = cn(S.root, isDisabled && S.disabled, isExternal && S.external, isExact && cn(S.exact, exactClassName), isClear && S.clear, inline && S.inline, className);
|
|
50
|
+
if (isNested) {
|
|
51
|
+
props.href = `${path.replace(/\/$/, '')}/${href}`;
|
|
52
|
+
}
|
|
53
|
+
if (isExternal) {
|
|
54
|
+
props.target = '_blank';
|
|
55
|
+
if (!/^http/.test(href))
|
|
56
|
+
props.href = `http://${href}`;
|
|
57
|
+
}
|
|
58
|
+
return (jsxs("a", { className: classes, ...props, onClick: handleClick, ref: domElem, children: [children, isExternal && !disableExternalIcon && (jsx(Icon, { type: "externalLink", className: S.externalIcon }))] }));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export { Link };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Link_root__KhBI1{align-items:center;box-shadow:inset 0 0 0 2px none;color:var(--link-color);cursor:pointer;display:inline-flex;padding:5px;position:relative;text-decoration:none;transition:color .1s ease-out;white-space:nowrap}.Link_root__KhBI1:before{background-color:var(--accent-color);bottom:0;content:\"\";height:2px;left:5px;pointer-events:none;position:absolute;right:5px;transform:scale(0);transition:transform .1s ease-out}.Link_root__KhBI1.Link_clear__abVgJ:before{content:none}.Link_root__KhBI1.Link_inline__iuNov{padding:0}.Link_root__KhBI1.Link_inline__iuNov:before{bottom:-2px;left:0;right:0}.Link_root__KhBI1.Link_exact__3MNoz{color:var(--accent-color);pointer-events:none}.Link_root__KhBI1.Link_external__drijI:before{background-color:var(--active-color)}.Link_root__KhBI1:active,.Link_root__KhBI1:focus,.Link_root__KhBI1:hover{color:var(--accent-color)}.Link_root__KhBI1:active.Link_external__drijI,.Link_root__KhBI1:focus.Link_external__drijI,.Link_root__KhBI1:hover.Link_external__drijI{color:var(--active-color)}.Link_root__KhBI1:active::-moz-selection,.Link_root__KhBI1:focus::-moz-selection,.Link_root__KhBI1:hover::-moz-selection{color:var(--accent-color)}.Link_root__KhBI1:active::selection,.Link_root__KhBI1:focus::selection,.Link_root__KhBI1:hover::selection{color:var(--accent-color)}.Link_root__KhBI1:active:before,.Link_root__KhBI1:focus:before,.Link_root__KhBI1:hover:before{transform:scale(1)}.Link_root__KhBI1.Link_disabled__wkAeH{color:var(--accent-color);opacity:.4;pointer-events:none}.Link_externalIcon__YDRJG{display:inline-block;height:1em;margin-bottom:-2px;margin-left:3px;width:1em}";
|
|
4
|
+
var S = {"root":"Link_root__KhBI1","clear":"Link_clear__abVgJ","inline":"Link_inline__iuNov","exact":"Link_exact__3MNoz","external":"Link_external__drijI","disabled":"Link_disabled__wkAeH","externalIcon":"Link_externalIcon__YDRJG"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|