kempo-ui 0.0.2 → 0.0.4
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/.github/copilot-instructions.md +149 -149
- package/.github/workflows/publish-major.yml +39 -0
- package/.github/workflows/publish-minor.yml +39 -0
- package/.github/workflows/{publish-npm.yml → publish-patch.yml} +44 -44
- package/.vscode/settings.json +2 -0
- package/CONTRIBUTING.md +149 -149
- package/README.md +0 -0
- package/dist/kempo-hljs.css +1 -0
- package/dist/kempo-vars.css +0 -0
- package/dist/src/components/Accordion.js +36 -0
- package/dist/src/components/Card.js +37 -0
- package/dist/src/components/Collapsible.js +41 -0
- package/dist/src/components/ContentSlider.js +44 -0
- package/dist/src/components/Dialog.js +113 -0
- package/dist/src/components/FocusCapture.js +7 -0
- package/dist/src/components/Icon.js +10 -0
- package/dist/src/components/Import.js +1 -0
- package/dist/src/components/PersistantCollapsible.js +1 -0
- package/dist/src/components/PhotoViewer.js +135 -0
- package/dist/src/components/Resize.js +96 -0
- package/dist/src/components/ShadowComponent.js +1 -0
- package/dist/src/components/ShowMore.js +42 -0
- package/dist/src/components/SideMenu.js +97 -0
- package/dist/src/components/Split.js +84 -0
- package/dist/src/components/Tabs.js +155 -0
- package/dist/src/components/Tags.js +69 -0
- package/dist/src/components/ThemeSwitcher.js +23 -0
- package/dist/src/components/Timestamp.js +1 -0
- package/dist/src/lit-all.min.js +120 -0
- package/dist/src/utils/debounce.js +1 -0
- package/dist/src/utils/drag.js +1 -0
- package/dist/src/utils/formatTimestamp.js +1 -0
- package/dist/src/utils/propConverters.js +1 -0
- package/dist/src/utils/watchWindowSize.js +1 -0
- package/docs/components/accordion.html +166 -0
- package/docs/components/card.html +92 -0
- package/docs/components/collapsible.html +198 -0
- package/docs/components/content-slider.html +223 -0
- package/docs/components/dialog.html +251 -0
- package/docs/components/focus-capture.html +67 -0
- package/docs/components/icon.html +158 -0
- package/docs/components/import.html +73 -0
- package/docs/components/persistant-collapsible.html +123 -0
- package/docs/components/photo-viewer.html +226 -0
- package/docs/components/resize.html +178 -0
- package/docs/components/show-more.html +129 -0
- package/docs/components/side-menu.html +159 -0
- package/docs/components/split.html +147 -0
- package/docs/components/table.html +312 -0
- package/docs/components/tableControls.html +77 -0
- package/docs/components/tableCustomFields.html +113 -0
- package/docs/components/tableFetchRecords.html +114 -0
- package/docs/components/tableFieldSortHide.html +75 -0
- package/docs/components/tablePagination.html +100 -0
- package/docs/components/tableRecordEditing.html +144 -0
- package/docs/components/tableRecordFiltering.html +88 -0
- package/docs/components/tableRecordHiding.html +80 -0
- package/docs/components/tableRecordSearching.html +75 -0
- package/docs/components/tableRecordSelection.html +75 -0
- package/docs/components/tableRowControls.html +78 -0
- package/docs/components/tableSorting.html +73 -0
- package/docs/components/tabs.html +180 -0
- package/docs/components/tags.html +110 -0
- package/docs/components/theme-switcher.html +126 -0
- package/docs/components/timestamp.html +82 -0
- package/docs/components/toast.html +319 -0
- package/docs/components/toggle.html +156 -0
- package/docs/dev.config.json +20 -0
- package/docs/icons/add.svg +1 -0
- package/docs/icons/arrow-back.svg +1 -0
- package/docs/icons/arrow-down-double.svg +1 -0
- package/docs/icons/arrow-down.svg +1 -0
- package/docs/icons/arrow-forward.svg +1 -0
- package/docs/icons/arrow-up-double.svg +1 -0
- package/docs/icons/arrow-up.svg +1 -0
- package/docs/icons/cards.svg +1 -0
- package/docs/icons/check.svg +1 -0
- package/docs/icons/chevron-left.svg +1 -0
- package/docs/icons/chevron-right.svg +1 -0
- package/docs/icons/close.svg +2 -0
- package/docs/icons/compare.svg +1 -0
- package/docs/icons/delete.svg +1 -0
- package/docs/icons/drag-handle.svg +1 -0
- package/docs/icons/drawing2.svg +124 -0
- package/docs/icons/edit.svg +1 -0
- package/docs/icons/error.svg +1 -0
- package/docs/icons/export-file.svg +1 -0
- package/docs/icons/file-text.svg +1 -0
- package/docs/icons/file.svg +1 -0
- package/docs/icons/filter-off.svg +1 -0
- package/docs/icons/filter.svg +1 -0
- package/docs/icons/first.svg +1 -0
- package/docs/icons/folder-clear.svg +1 -0
- package/docs/icons/folder-create.svg +1 -0
- package/docs/icons/folder-open.svg +1 -0
- package/docs/icons/folder.svg +1 -0
- package/docs/icons/hide.svg +1 -0
- package/docs/icons/image.svg +1 -0
- package/docs/icons/label-add.svg +1 -0
- package/docs/icons/label.svg +1 -0
- package/docs/icons/last.svg +1 -0
- package/docs/icons/menu.svg +1 -0
- package/docs/icons/mode-auto.svg +1 -0
- package/docs/icons/mode-dark.svg +1 -0
- package/docs/icons/mode-light.svg +1 -0
- package/docs/icons/open-in-browser.svg +1 -0
- package/docs/icons/pause.svg +1 -0
- package/docs/icons/play.svg +1 -0
- package/docs/icons/refresh.svg +1 -0
- package/docs/icons/remove.svg +1 -0
- package/docs/icons/save.svg +1 -0
- package/docs/icons/search.svg +1 -0
- package/docs/icons/settings.svg +1 -0
- package/docs/icons/show.svg +1 -0
- package/docs/icons/storage.svg +1 -0
- package/docs/icons/table-visibility.svg +1 -0
- package/docs/icons/tag.svg +1 -0
- package/docs/icons/tools.svg +1 -0
- package/docs/icons/trash-x.svg +1 -0
- package/docs/icons/warning.svg +1 -0
- package/docs/index.html +28 -21
- package/docs/kempo-hljs.css +1 -0
- package/docs/media/civic.jpg +0 -0
- package/docs/media/corvette.jpg +0 -0
- package/docs/media/evo.jpg +0 -0
- package/docs/media/gtr.jpg +0 -0
- package/docs/media/nsx.jpg +0 -0
- package/docs/nav.inc.html +67 -0
- package/docs/nav.inc.js +4 -0
- package/{config/production.json → docs/prod.config.json} +20 -16
- package/docs/src/components/Accordion.js +36 -0
- package/docs/src/components/Card.js +37 -0
- package/docs/src/components/Collapsible.js +41 -0
- package/docs/src/components/ContentSlider.js +44 -0
- package/docs/src/components/Dialog.js +113 -0
- package/docs/src/components/FocusCapture.js +7 -0
- package/docs/src/components/HybridComponent.js +1 -0
- package/docs/src/components/Icon.js +10 -0
- package/docs/src/components/Import.js +1 -0
- package/docs/src/components/LightComponent.js +1 -0
- package/docs/src/components/PersistantCollapsible.js +1 -0
- package/docs/src/components/PhotoViewer.js +135 -0
- package/docs/src/components/Resize.js +96 -0
- package/docs/src/components/ShadowComponent.js +1 -0
- package/docs/src/components/ShowMore.js +42 -0
- package/docs/src/components/SideMenu.js +97 -0
- package/docs/src/components/Split.js +84 -0
- package/docs/src/components/Tabs.js +155 -0
- package/docs/src/components/Tags.js +69 -0
- package/docs/src/components/ThemeSwitcher.js +23 -0
- package/docs/src/components/Timestamp.js +1 -0
- package/docs/src/lit-all.min.js +120 -0
- package/docs/src/utils/debounce.js +1 -0
- package/docs/src/utils/drag.js +1 -0
- package/docs/src/utils/formatTimestamp.js +1 -0
- package/docs/src/utils/propConverters.js +1 -0
- package/docs/src/utils/watchWindowSize.js +1 -0
- package/docs/styles.css +6 -0
- package/docs/utils/debounce.html +78 -0
- package/docs/utils/drag.html +104 -0
- package/docs/utils/formatTimestamp.html +114 -0
- package/docs/utils/propConverters.html +132 -0
- package/docs/utils/watchWindowSize.html +166 -0
- package/icons/add.svg +1 -0
- package/icons/arrow-back.svg +1 -0
- package/icons/arrow-down-double.svg +1 -0
- package/icons/arrow-down.svg +1 -0
- package/icons/arrow-forward.svg +1 -0
- package/icons/arrow-up-double.svg +1 -0
- package/icons/arrow-up.svg +1 -0
- package/icons/cards.svg +1 -0
- package/icons/check.svg +1 -0
- package/icons/chevron-left.svg +1 -0
- package/icons/chevron-right.svg +1 -0
- package/icons/close.svg +2 -0
- package/icons/compare.svg +1 -0
- package/icons/delete.svg +1 -0
- package/icons/drag-handle.svg +1 -0
- package/icons/drawing2.svg +124 -0
- package/icons/edit.svg +1 -0
- package/icons/error.svg +1 -0
- package/icons/export-file.svg +1 -0
- package/icons/file-text.svg +1 -0
- package/icons/file.svg +1 -0
- package/icons/filter-off.svg +1 -0
- package/icons/filter.svg +1 -0
- package/icons/first.svg +1 -0
- package/icons/folder-clear.svg +1 -0
- package/icons/folder-create.svg +1 -0
- package/icons/folder-open.svg +1 -0
- package/icons/folder.svg +1 -0
- package/icons/hide.svg +1 -0
- package/icons/image.svg +1 -0
- package/icons/label-add.svg +1 -0
- package/icons/label.svg +1 -0
- package/icons/last.svg +1 -0
- package/icons/menu.svg +1 -0
- package/icons/mode-auto.svg +1 -0
- package/icons/mode-dark.svg +1 -0
- package/icons/mode-light.svg +1 -0
- package/icons/open-in-browser.svg +1 -0
- package/icons/pause.svg +1 -0
- package/icons/play.svg +1 -0
- package/icons/refresh.svg +1 -0
- package/icons/remove.svg +1 -0
- package/icons/save.svg +1 -0
- package/icons/search.svg +1 -0
- package/icons/settings.svg +1 -0
- package/icons/show.svg +1 -0
- package/icons/storage.svg +1 -0
- package/icons/table-visibility.svg +1 -0
- package/icons/tag.svg +1 -0
- package/icons/tools.svg +1 -0
- package/icons/trash-x.svg +1 -0
- package/icons/warning.svg +1 -0
- package/package.json +2 -2
- package/scripts/build.js +109 -138
- package/scripts/docs.js +62 -60
- package/src/components/Accordion.js +229 -0
- package/src/components/Card.js +66 -0
- package/src/components/Collapsible.js +109 -0
- package/src/components/ContentSlider.js +205 -0
- package/src/components/Dialog.js +368 -0
- package/src/components/FocusCapture.js +23 -0
- package/src/components/HybridComponent.js +40 -40
- package/src/components/Icon.js +155 -0
- package/src/components/Import.js +104 -0
- package/src/components/LightComponent.js +32 -32
- package/src/components/PersistantCollapsible.js +69 -0
- package/src/components/PhotoViewer.js +368 -0
- package/src/components/Resize.js +210 -0
- package/src/components/ShadowComponent.js +32 -17
- package/src/components/ShowMore.js +109 -0
- package/src/components/SideMenu.js +167 -0
- package/src/components/Sortable.js +193 -0
- package/src/components/Split.js +192 -0
- package/src/components/Table.js +1202 -0
- package/src/components/Tabs.js +428 -0
- package/src/components/Tags.js +253 -0
- package/src/components/ThemeSwitcher.js +108 -0
- package/src/components/Timestamp.js +31 -0
- package/src/components/Toast.js +454 -0
- package/src/components/Toggle.js +173 -0
- package/src/components/tableControls/DeleteRecord.js +29 -0
- package/src/components/tableControls/Edit.js +88 -0
- package/src/components/tableControls/ExportCSV.js +71 -0
- package/src/components/tableControls/ExportJson.js +55 -0
- package/src/components/tableControls/FieldSortHide.js +76 -0
- package/src/components/tableControls/Filters.js +114 -0
- package/src/components/tableControls/FirstPage.js +65 -0
- package/src/components/tableControls/HiddenCount.js +45 -0
- package/src/components/tableControls/Hide.js +34 -0
- package/src/components/tableControls/LastPage.js +65 -0
- package/src/components/tableControls/NextPage.js +65 -0
- package/src/components/tableControls/PageSelect.js +109 -0
- package/src/components/tableControls/PageSize.js +68 -0
- package/src/components/tableControls/PrevPage.js +65 -0
- package/src/components/tableControls/Search.js +58 -0
- package/src/components/tableControls/ShowAll.js +34 -0
- package/src/components/tableControls/TableControl.js +105 -0
- package/src/kempo-hljs.css +146 -0
- package/src/utils/debounce.js +9 -0
- package/src/utils/drag.js +80 -0
- package/src/utils/formatTimestamp.js +27 -0
- package/src/utils/propConverters.js +11 -0
- package/src/utils/toTitleCase.js +9 -0
- package/src/utils/watchWindowSize.js +16 -0
- package/tests/HybridComponent.browser-test.js +214 -214
- package/tests/LightComponent.browser-test.js +169 -169
- package/tests/ShadowComponent.browser-test.js +130 -130
- package/config/development.json +0 -14
- package/docs/components/ShadowComponent.js +0 -1
- package/src/utils/cli.js +0 -43
- package/src/utils/fs-utils.js +0 -41
- /package/{docs → dist/src}/components/HybridComponent.js +0 -0
- /package/{docs → dist/src}/components/LightComponent.js +0 -0
- /package/docs/{utils → src/utils}/cli.js +0 -0
- /package/docs/{utils → src/utils}/fs-utils.js +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
:root,
|
|
2
|
+
[theme="light"] {
|
|
3
|
+
--c_text: #000000;
|
|
4
|
+
--c_keyword: #0000ff;
|
|
5
|
+
--c_builtin: #00b0e8;
|
|
6
|
+
--c_number: #709756;
|
|
7
|
+
--c_string: #a31515;
|
|
8
|
+
--c_regex: #914525;
|
|
9
|
+
--c_function: inherit;
|
|
10
|
+
--c_comment: #008000;
|
|
11
|
+
--c_doc: #808080;
|
|
12
|
+
--c_tag: #7d7d7d;
|
|
13
|
+
--c_var: #b436bf;
|
|
14
|
+
--c_attr: #ff0000;
|
|
15
|
+
--c_section: #a31515;
|
|
16
|
+
--c_selector: #0000ff;
|
|
17
|
+
--c_addition: #a31515;
|
|
18
|
+
--c_deletion: #2b91af;
|
|
19
|
+
--c_caret: black;
|
|
20
|
+
}
|
|
21
|
+
[auto-theme="dark"]:not([theme="light"]),
|
|
22
|
+
[theme="dark"] {
|
|
23
|
+
--c_text: #DCDCDC;
|
|
24
|
+
--c_keyword: #569CD6;
|
|
25
|
+
--c_builtin: #4EC9B0;
|
|
26
|
+
--c_number: #B8D7A3;
|
|
27
|
+
--c_string: #D69D85;
|
|
28
|
+
--c_regex: #9A5334;
|
|
29
|
+
--c_function: inehrit;
|
|
30
|
+
--c_comment: #57A64A;
|
|
31
|
+
--c_doc: #608B4E;
|
|
32
|
+
--c_tag: #9B9B9B;
|
|
33
|
+
--c_var: #BD63C5;
|
|
34
|
+
--c_attr: #9CDCFE;
|
|
35
|
+
--c_section: #ffd700;
|
|
36
|
+
--c_selector: #569CD6;
|
|
37
|
+
--c_addition: #144212;
|
|
38
|
+
--c_deletion: #600;
|
|
39
|
+
--c_caret: white;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.hljs {
|
|
43
|
+
display: block;
|
|
44
|
+
overflow-x: auto;
|
|
45
|
+
color: var(--c_text);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.hljs-keyword,
|
|
49
|
+
.hljs-literal,
|
|
50
|
+
.hljs-symbol,
|
|
51
|
+
.hljs-name,
|
|
52
|
+
.hljs-link {
|
|
53
|
+
color: var(--c_keyword);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.hljs-link {
|
|
57
|
+
text-decoration: underline;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.hljs-built_in,
|
|
61
|
+
.hljs-type {
|
|
62
|
+
color: var(--c_builtin);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.hljs-number,
|
|
66
|
+
.hljs-class {
|
|
67
|
+
color: var(--c_number);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.hljs-string,
|
|
71
|
+
.hljs-meta-string {
|
|
72
|
+
color: var(--c_string);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.hljs-regexp,
|
|
76
|
+
.hljs-template-tag {
|
|
77
|
+
color: var(--c_regex);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.hljs-subst,
|
|
81
|
+
.hljs-function,
|
|
82
|
+
.hljs-title,
|
|
83
|
+
.hljs-params,
|
|
84
|
+
.hljs-formula {
|
|
85
|
+
color: var(--c_function);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.hljs-comment,
|
|
89
|
+
.hljs-quote {
|
|
90
|
+
color: var(--c_comment);
|
|
91
|
+
font-style: italic
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.hljs-doctag {
|
|
95
|
+
color: var(--c_doc);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.hljs-meta,
|
|
99
|
+
.hljs-meta-keyword,
|
|
100
|
+
.hljs-tag {
|
|
101
|
+
color: var(--c_tag);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.hljs-variable,
|
|
105
|
+
.hljs-template-variable {
|
|
106
|
+
color: var(--c_var);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.hljs-attr,
|
|
110
|
+
.hljs-attribute,
|
|
111
|
+
.hljs-builtin-name {
|
|
112
|
+
color: var(--c_attr);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.hljs-section {
|
|
116
|
+
color: var(--c_section);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.hljs-emphasis {
|
|
120
|
+
font-style: italic
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.hljs-strong {
|
|
124
|
+
font-weight: bold
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.hljs-bullet,
|
|
128
|
+
.hljs-selector-tag,
|
|
129
|
+
.hljs-selector-id,
|
|
130
|
+
.hljs-selector-class,
|
|
131
|
+
.hljs-selector-attr,
|
|
132
|
+
.hljs-selector-pseudo {
|
|
133
|
+
color: var(--c_selector);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.hljs-addition {
|
|
137
|
+
background-color: var(--c_addition);
|
|
138
|
+
display: inline-block;
|
|
139
|
+
width: 100%
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.hljs-deletion {
|
|
143
|
+
background-color: var(--c_deletion);
|
|
144
|
+
display: inline-block;
|
|
145
|
+
width: 100%
|
|
146
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Drag Utility
|
|
3
|
+
*/
|
|
4
|
+
export default (options = {}) => {
|
|
5
|
+
let startX, startY, timeoutId;
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
element,
|
|
9
|
+
callback = () => {},
|
|
10
|
+
startCallback = () => {},
|
|
11
|
+
moveCallback = () => {},
|
|
12
|
+
endCallback = () => {},
|
|
13
|
+
preventScroll = false
|
|
14
|
+
} = options;
|
|
15
|
+
|
|
16
|
+
const dragMove = (event) => {
|
|
17
|
+
if(preventScroll) {
|
|
18
|
+
event.preventDefault(); // prevent drag scrolling
|
|
19
|
+
}
|
|
20
|
+
clearTimeout(timeoutId);
|
|
21
|
+
const pageX = event.pageX || event.touches[0].pageX;
|
|
22
|
+
const pageY = event.pageY || event.touches[0].pageY;
|
|
23
|
+
const diff = {
|
|
24
|
+
x: pageX - startX,
|
|
25
|
+
y: pageY - startY,
|
|
26
|
+
...options
|
|
27
|
+
};
|
|
28
|
+
callback(diff);
|
|
29
|
+
moveCallback(diff);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const dragEnd = (event) => {
|
|
33
|
+
clearTimeout(timeoutId);
|
|
34
|
+
const pageX = event.pageX || (event.changedTouches && event.changedTouches[0].pageX) || 0;
|
|
35
|
+
const pageY = event.pageY || (event.changedTouches && event.changedTouches[0].pageY) || 0;
|
|
36
|
+
const diff = {
|
|
37
|
+
x: pageX - startX,
|
|
38
|
+
y: pageY - startY,
|
|
39
|
+
...options
|
|
40
|
+
};
|
|
41
|
+
callback(diff);
|
|
42
|
+
endCallback(diff);
|
|
43
|
+
removeListeners();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const dragStart = (event) => {
|
|
47
|
+
if(event.button && event.button !== 0) return; // Only left click for mouse
|
|
48
|
+
|
|
49
|
+
clearTimeout(timeoutId);
|
|
50
|
+
startX = event.pageX || event.touches[0].pageX;
|
|
51
|
+
startY = event.pageY || event.touches[0].pageY;
|
|
52
|
+
const diff = {
|
|
53
|
+
x: 0,
|
|
54
|
+
y: 0,
|
|
55
|
+
...options
|
|
56
|
+
};
|
|
57
|
+
startCallback(diff);
|
|
58
|
+
window.addEventListener('mousemove', dragMove, { passive: !preventScroll });
|
|
59
|
+
window.addEventListener('mouseup', dragEnd, { passive: !preventScroll });
|
|
60
|
+
window.addEventListener('touchmove', dragMove, { passive: !preventScroll });
|
|
61
|
+
window.addEventListener('touchend', dragEnd, { passive: !preventScroll });
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const removeListeners = () => {
|
|
65
|
+
window.removeEventListener('mousemove', dragMove);
|
|
66
|
+
window.removeEventListener('mouseup', dragEnd);
|
|
67
|
+
window.removeEventListener('touchmove', dragMove);
|
|
68
|
+
window.removeEventListener('touchend', dragEnd);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
element.addEventListener('mousedown', dragStart, { passive: !preventScroll });
|
|
72
|
+
element.addEventListener('touchstart', dragStart, { passive: !preventScroll });
|
|
73
|
+
|
|
74
|
+
// Return cleanup function
|
|
75
|
+
return () => {
|
|
76
|
+
element.removeEventListener('mousedown', dragStart);
|
|
77
|
+
element.removeEventListener('touchstart', dragStart);
|
|
78
|
+
removeListeners();
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default (timestamp, format, forceLocale) => {
|
|
2
|
+
const date = new Date(parseInt(timestamp));
|
|
3
|
+
if (format) {
|
|
4
|
+
const pad = (num, size) => ('000' + num).slice(size * -1);
|
|
5
|
+
const tokens = {
|
|
6
|
+
YYYY: date.getFullYear(),
|
|
7
|
+
YY: String(date.getFullYear()).slice(-2),
|
|
8
|
+
MM: pad(date.getMonth() + 1, 2),
|
|
9
|
+
M: date.getMonth() + 1,
|
|
10
|
+
DD: pad(date.getDate(), 2),
|
|
11
|
+
D: date.getDate(),
|
|
12
|
+
hh: pad(date.getHours(), 2),
|
|
13
|
+
h: date.getHours(),
|
|
14
|
+
mm: pad(date.getMinutes(), 2),
|
|
15
|
+
m: date.getMinutes(),
|
|
16
|
+
ss: pad(date.getSeconds(), 2),
|
|
17
|
+
s: date.getSeconds(),
|
|
18
|
+
iiii: pad(date.getMilliseconds(), 3),
|
|
19
|
+
iii: pad(date.getMilliseconds(), 3),
|
|
20
|
+
ii: pad(date.getMilliseconds(), 2),
|
|
21
|
+
i: date.getMilliseconds()
|
|
22
|
+
};
|
|
23
|
+
return format.replace(/YYYY|YY|MM|M|DD|D|hh|h|mm|m|ss|s|iiii|iii|ii|i/g, (matched) => tokens[matched]);
|
|
24
|
+
} else {
|
|
25
|
+
return date.toLocaleString(forceLocale || navigator.language);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Boolean converter that uses explicit "true"/"false" string values
|
|
2
|
+
export const boolTrueFalse = {
|
|
3
|
+
fromAttribute: v => v === null ? undefined : v.toLowerCase() === 'true',
|
|
4
|
+
toAttribute: v => v ? 'true' : 'false'
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// Boolean converter that uses attribute presence/absence
|
|
8
|
+
export const boolExists = {
|
|
9
|
+
fromAttribute: v => v !== null,
|
|
10
|
+
toAttribute: v => v ? '' : null
|
|
11
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import debounce from './debounce.js';
|
|
2
|
+
|
|
3
|
+
const handlers = new Set();
|
|
4
|
+
window.addEventListener('resize', debounce(() => {
|
|
5
|
+
const width = window.innerWidth;
|
|
6
|
+
handlers.forEach((handler) => handler(width));
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
export const watchWindowSize = (handler) => {
|
|
10
|
+
handlers.add(handler);
|
|
11
|
+
return window.innerWidth;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const unwatchWindowSize = (handler) => {
|
|
15
|
+
handlers.delete(handler);
|
|
16
|
+
};
|