@neovici/cosmoz-utils 5.38.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date.js +2 -2
- package/dist/directives/consume.d.ts +1 -1
- package/dist/directives/consume.js +1 -1
- package/dist/directives/provide.d.ts +1 -1
- package/dist/directives/provide.js +1 -1
- package/dist/elements/cz-icon.js +9 -9
- package/dist/elements/cz-spinner.js +1 -1
- package/dist/haunted-polymer.d.ts +1 -1
- package/dist/haunted-polymer.js +1 -1
- package/dist/hooks/use-abort-signal.js +1 -1
- package/dist/hooks/use-debounce-raf.js +1 -1
- package/dist/hooks/use-drag-items.js +1 -1
- package/dist/hooks/use-dropped-files.js +1 -1
- package/dist/hooks/use-handle-drop.js +1 -1
- package/dist/hooks/use-host-bounds.js +1 -1
- package/dist/hooks/use-host.js +1 -1
- package/dist/hooks/use-imperative-api.js +1 -1
- package/dist/hooks/use-meta.js +1 -1
- package/dist/hooks/use-notify-property.js +1 -1
- package/dist/hooks/use-promise.js +24 -15
- package/dist/hooks/use-property.js +1 -1
- package/dist/tag.d.ts +21 -23
- package/dist/tag.js +23 -25
- package/package.json +6 -5
package/dist/date.js
CHANGED
|
@@ -105,8 +105,8 @@ timeago = (date, locale) => {
|
|
|
105
105
|
return '';
|
|
106
106
|
}
|
|
107
107
|
return new Intl.RelativeTimeFormat(locale, {
|
|
108
|
-
localeMatcher: 'best fit',
|
|
109
|
-
numeric: 'auto',
|
|
108
|
+
localeMatcher: 'best fit', // other values: "lookup"
|
|
109
|
+
numeric: 'auto', // other values: "auto"
|
|
110
110
|
style: 'long', // other values: "short" or "narrow"
|
|
111
111
|
}).format(...getValUnitDiff(d, new Date()));
|
|
112
112
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from '
|
|
1
|
+
import { Context } from '@pionjs/pion/lib/create-context';
|
|
2
2
|
import { AttributePart } from 'lit-html';
|
|
3
3
|
import { AsyncDirective } from 'lit-html/async-directive.js';
|
|
4
4
|
import { ChildPart, DirectiveParameters } from 'lit-html/directive.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, ContextDetail } from '
|
|
1
|
+
import { Context, ContextDetail } from '@pionjs/pion/lib/create-context';
|
|
2
2
|
import { AsyncDirective } from 'lit-html/async-directive.js';
|
|
3
3
|
import { ChildPart } from 'lit-html/directive.js';
|
|
4
4
|
declare class ProvideDirective<T> extends AsyncDirective {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { contextEvent } from '
|
|
1
|
+
import { contextEvent } from '@pionjs/pion/lib/symbols';
|
|
2
2
|
import { noChange, nothing } from 'lit-html';
|
|
3
3
|
import { AsyncDirective, directive } from 'lit-html/async-directive.js';
|
|
4
4
|
class ProvideDirective extends AsyncDirective {
|
package/dist/elements/cz-icon.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { html, svg } from 'lit-html';
|
|
2
2
|
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
3
|
-
import { component } from '
|
|
3
|
+
import { component } from '@pionjs/pion';
|
|
4
4
|
export const arrowDropDown = svg `<path d="M7 10l5 5 5-5z"></path>`, cancel = svg `<path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"></path>`, check = svg `<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path>`, clear = svg `<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path>`, warning = svg `<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" fill="currentColor"></path>`, undo = svg `<path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"></path>`, edit = svg `<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path>`, rightArrow = svg `<path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z" fill="currentColor"></path>`, leftArrow = svg `<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" fill="currentColor"></path>`, download = svg `<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" fill="currentColor"></path>`, print = svg `<path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z" fill="currentColor"></path>`, renderIcon = ({ icon, width = 24, height } = {}) => html `<svg
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
preserveAspectRatio="xMidYMid meet"
|
|
7
|
+
focusable="false"
|
|
8
|
+
width=${width}
|
|
9
|
+
height=${ifDefined(height)}
|
|
10
|
+
>
|
|
11
|
+
${icon}
|
|
12
|
+
</svg>`;
|
|
13
13
|
customElements.define('cz-icon', component(renderIcon, {
|
|
14
14
|
observedAttributes: ['width', 'height'],
|
|
15
15
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseScheduler, GenericRenderer, ComponentOrVirtualComponent } from '
|
|
1
|
+
import { BaseScheduler, GenericRenderer, ComponentOrVirtualComponent } from '@pionjs/pion';
|
|
2
2
|
import { ChildPart } from 'lit-html';
|
|
3
3
|
import { Rec } from './object';
|
|
4
4
|
export type Constructor<T> = new (...args: any[]) => T;
|
package/dist/haunted-polymer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useCallback } from '
|
|
1
|
+
import { useState, useCallback } from '@pionjs/pion';
|
|
2
2
|
import { useHandleDrop } from './use-handle-drop';
|
|
3
3
|
export const useDroppedFiles = (el) => {
|
|
4
4
|
const [files, setFiles] = useState([]), handleDrop = useCallback((event) => setFiles(Array.from(event.dataTransfer?.files ?? [])), [setFiles]);
|
package/dist/hooks/use-host.js
CHANGED
package/dist/hooks/use-meta.js
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import { useReducer, useEffect } from '
|
|
1
|
+
import { useReducer, useEffect } from '@pionjs/pion';
|
|
2
2
|
import { reduce, action } from '../reduce';
|
|
3
3
|
const states = {
|
|
4
4
|
pending: 'pending',
|
|
5
5
|
rejected: 'rejected',
|
|
6
|
-
resolved: 'resolved'
|
|
6
|
+
resolved: 'resolved',
|
|
7
7
|
}, initial = {
|
|
8
8
|
error: undefined,
|
|
9
9
|
result: undefined,
|
|
10
|
-
state: states.pending
|
|
11
|
-
}, pending = action(states.pending), resolved = action(states.resolved, result => ({ result })), rejected = action(states.rejected, error => ({ error })), reducer = reduce(initial, [
|
|
12
|
-
[
|
|
10
|
+
state: states.pending,
|
|
11
|
+
}, pending = action(states.pending), resolved = action(states.resolved, (result) => ({ result })), rejected = action(states.rejected, (error) => ({ error })), reducer = reduce(initial, [
|
|
12
|
+
[
|
|
13
|
+
pending,
|
|
14
|
+
() => ({
|
|
13
15
|
error: undefined,
|
|
14
16
|
result: undefined,
|
|
15
|
-
state: states.pending
|
|
16
|
-
})
|
|
17
|
-
|
|
17
|
+
state: states.pending,
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
resolved,
|
|
22
|
+
(state, { result }) => ({
|
|
18
23
|
error: undefined,
|
|
19
24
|
result,
|
|
20
|
-
state: states.resolved
|
|
21
|
-
})
|
|
22
|
-
|
|
25
|
+
state: states.resolved,
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
rejected,
|
|
30
|
+
(state, { error }) => ({
|
|
23
31
|
error,
|
|
24
32
|
result: undefined,
|
|
25
|
-
state: states.rejected
|
|
26
|
-
})
|
|
33
|
+
state: states.rejected,
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
27
36
|
]);
|
|
28
|
-
export const usePromise = promise => {
|
|
37
|
+
export const usePromise = (promise) => {
|
|
29
38
|
const [{ error, result, state }, dispatch] = useReducer(reducer, initial);
|
|
30
39
|
useEffect(() => {
|
|
31
40
|
if (!promise) {
|
|
@@ -33,7 +42,7 @@ export const usePromise = promise => {
|
|
|
33
42
|
}
|
|
34
43
|
let canceled = false;
|
|
35
44
|
dispatch(pending());
|
|
36
|
-
promise.then(result => !canceled && dispatch(resolved(result)), error => !canceled && dispatch(rejected(error)));
|
|
45
|
+
promise.then((result) => !canceled && dispatch(resolved(result)), (error) => !canceled && dispatch(rejected(error)));
|
|
37
46
|
return () => {
|
|
38
47
|
canceled = true;
|
|
39
48
|
};
|
package/dist/tag.d.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
tag: (strings: string[], component: string, ...values: unknown[]) => import("lit-html").TemplateResult<1>;
|
|
1
|
+
export declare const /**
|
|
2
|
+
* Dynamic component support for lit-html.
|
|
3
|
+
*
|
|
4
|
+
* Normally lit-html does not support interpolating the component tag, but we can trick it
|
|
5
|
+
* by calling the template function manually.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: You can only use this function for interpolating a single tag and it must be the
|
|
8
|
+
* first interpolated value. If you need multiple components, you can do multiple interpolations.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* tag`<${name} some=${param}/>`
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* html`A: ${ tag`<${ aTag }/>` } - B: ${ tag`${ bTag }` }`
|
|
15
|
+
*
|
|
16
|
+
* @param {string[]} strings The static strings.
|
|
17
|
+
* @param {string} component The interpolated component name.
|
|
18
|
+
* @param {any[]} values The interpolated values.
|
|
19
|
+
*
|
|
20
|
+
* @return {TemplateResult} The lit template result.
|
|
21
|
+
*/ tag: (strings: string[], component: string, ...values: unknown[]) => import("lit-html").TemplateResult<1>;
|
package/dist/tag.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { html as htm } from '
|
|
1
|
+
import { html as htm } from 'lit-html';
|
|
2
2
|
const html = (arr, ...thru) => htm(Object.assign(arr, { raw: true }), ...thru);
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
tag = (strings, component, ...values) => html([
|
|
3
|
+
export const /**
|
|
4
|
+
* Dynamic component support for lit-html.
|
|
5
|
+
*
|
|
6
|
+
* Normally lit-html does not support interpolating the component tag, but we can trick it
|
|
7
|
+
* by calling the template function manually.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: You can only use this function for interpolating a single tag and it must be the
|
|
10
|
+
* first interpolated value. If you need multiple components, you can do multiple interpolations.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* tag`<${name} some=${param}/>`
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* html`A: ${ tag`<${ aTag }/>` } - B: ${ tag`${ bTag }` }`
|
|
17
|
+
*
|
|
18
|
+
* @param {string[]} strings The static strings.
|
|
19
|
+
* @param {string} component The interpolated component name.
|
|
20
|
+
* @param {any[]} values The interpolated values.
|
|
21
|
+
*
|
|
22
|
+
* @return {TemplateResult} The lit template result.
|
|
23
|
+
*/ tag = (strings, component, ...values) => html([
|
|
26
24
|
strings[0] + component + strings[1],
|
|
27
|
-
...strings.slice(2)
|
|
25
|
+
...strings.slice(2),
|
|
28
26
|
], ...values);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Date, money and template management functions commonly needed in Cosmoz views.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polymer",
|
|
@@ -71,19 +71,20 @@
|
|
|
71
71
|
"./memoize": "./dist/memoize.js"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"
|
|
74
|
+
"@pionjs/pion": "^2.0.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@commitlint/cli": "^18.0.0",
|
|
78
78
|
"@commitlint/config-conventional": "^18.0.0",
|
|
79
79
|
"@neovici/cfg": "^1.15.1",
|
|
80
|
-
"@open-wc/testing": "^
|
|
80
|
+
"@open-wc/testing": "^4.0.0",
|
|
81
81
|
"@polymer/polymer": "^3.3.1",
|
|
82
82
|
"@semantic-release/changelog": "^6.0.0",
|
|
83
83
|
"@semantic-release/git": "^10.0.0",
|
|
84
|
+
"@types/mocha": "^10.0.3",
|
|
84
85
|
"husky": "^8.0.0",
|
|
85
86
|
"lit-html": "^2.0.0 || ^3.0.0",
|
|
86
|
-
"semantic-release": "^
|
|
87
|
-
"sinon": "^
|
|
87
|
+
"semantic-release": "^22.0.0",
|
|
88
|
+
"sinon": "^17.0.0"
|
|
88
89
|
}
|
|
89
90
|
}
|