be-intl 0.0.13 → 0.0.15
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/README.md +2 -1
- package/be-intl.js +28 -74
- package/package.json +6 -5
- package/types.d.ts +3 -3
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@ emits
|
|
|
31
31
|
|
|
32
32
|
## Viewing Locally
|
|
33
33
|
|
|
34
|
+
Any web server than can serve static files will do, but...
|
|
35
|
+
|
|
34
36
|
1. Install git.
|
|
35
37
|
2. Fork/clone this repo.
|
|
36
38
|
3. Install node.
|
|
@@ -54,4 +56,3 @@ import 'be-intl/be-intl.js';
|
|
|
54
56
|
</script>
|
|
55
57
|
```
|
|
56
58
|
|
|
57
|
-
[TODO] aria-polite ?
|
package/be-intl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BE, propDefaults, propInfo } from 'be-enhanced/BE.js';
|
|
2
1
|
import { XE } from 'xtal-element/XE.js';
|
|
3
2
|
import { register } from 'be-hive/register.js';
|
|
4
|
-
|
|
3
|
+
import { BeValueAdded, beValueAddedActions, beValueAddedPropDefaults, beValueAddedPropInfo } from 'be-value-added/be-value-added.js';
|
|
4
|
+
export class BeIntl extends BeValueAdded {
|
|
5
5
|
static get beConfig() {
|
|
6
6
|
return {
|
|
7
7
|
parse: true,
|
|
@@ -9,72 +9,30 @@ export class BeIntl extends BE {
|
|
|
9
9
|
primaryPropReq: true,
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
switch (typeof newVal) {
|
|
28
|
-
case 'string':
|
|
29
|
-
if (!newVal) {
|
|
30
|
-
this.value = 0;
|
|
31
|
-
}
|
|
32
|
-
break;
|
|
33
|
-
default:
|
|
34
|
-
this.value = newVal;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const val = enhancedElement.value;
|
|
38
|
-
if (val !== '') {
|
|
39
|
-
this.value = JSON.parse(val);
|
|
40
|
-
}
|
|
41
|
-
if (localName === 'data') {
|
|
42
|
-
enhancedElement.ariaLive = 'polite';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
case 'time':
|
|
47
|
-
{
|
|
48
|
-
enhancedElement.ariaLive = 'polite';
|
|
49
|
-
propagator.addEventListener('dateTime', e => {
|
|
50
|
-
const newVal = e.detail.newVal;
|
|
51
|
-
switch (typeof newVal) {
|
|
52
|
-
case 'string':
|
|
53
|
-
try {
|
|
54
|
-
this.value = new Date(newVal);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
console.error(e);
|
|
58
|
-
}
|
|
59
|
-
default:
|
|
60
|
-
if (newVal instanceof Date) {
|
|
61
|
-
this.value = newVal;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
const val = enhancedElement.dateTime;
|
|
66
|
-
if (val !== '') {
|
|
67
|
-
try {
|
|
68
|
-
this.value = new Date(val);
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
console.error(e);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
break;
|
|
12
|
+
#langObserver;
|
|
13
|
+
hydrate(self) {
|
|
14
|
+
const { enhancedElement } = self;
|
|
15
|
+
const returnObj = super.hydrate(self);
|
|
16
|
+
const { observeAttr } = self;
|
|
17
|
+
if (observeAttr) {
|
|
18
|
+
const mutOptions = {
|
|
19
|
+
attributeFilter: ['lang'],
|
|
20
|
+
attributes: true
|
|
21
|
+
};
|
|
22
|
+
self.#langObserver = new MutationObserver(( /*mutations: MutationRecord[]*/) => {
|
|
23
|
+
self.locale = enhancedElement.lang || defaultLocale;
|
|
24
|
+
;
|
|
25
|
+
});
|
|
26
|
+
self.#langObserver.observe(enhancedElement, mutOptions);
|
|
76
27
|
}
|
|
77
|
-
|
|
28
|
+
returnObj.locale = enhancedElement.lang || defaultLocale;
|
|
29
|
+
delete returnObj.resolved;
|
|
30
|
+
return returnObj;
|
|
31
|
+
}
|
|
32
|
+
detach(detachedElement) {
|
|
33
|
+
super.detach(detachedElement);
|
|
34
|
+
if (this.#langObserver !== undefined)
|
|
35
|
+
this.#langObserver.disconnect();
|
|
78
36
|
}
|
|
79
37
|
formatNumber(self) {
|
|
80
38
|
const { enhancedElement, value } = self;
|
|
@@ -113,17 +71,13 @@ const xe = new XE({
|
|
|
113
71
|
config: {
|
|
114
72
|
tagName,
|
|
115
73
|
propDefaults: {
|
|
116
|
-
...
|
|
74
|
+
...beValueAddedPropDefaults,
|
|
117
75
|
},
|
|
118
76
|
propInfo: {
|
|
119
|
-
...
|
|
120
|
-
value: {
|
|
121
|
-
notify: {
|
|
122
|
-
dispatch: true
|
|
123
|
-
}
|
|
124
|
-
}
|
|
77
|
+
...beValueAddedPropInfo,
|
|
125
78
|
},
|
|
126
79
|
actions: {
|
|
80
|
+
...beValueAddedActions,
|
|
127
81
|
formatNumber: {
|
|
128
82
|
ifKeyIn: ['value'],
|
|
129
83
|
ifAllOf: ['intlNumberFormat']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "be-intl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"web-components",
|
|
6
6
|
"web-component",
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"update": "ncu -u && npm install"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"be-enhanced": "0.0.
|
|
29
|
+
"be-enhanced": "0.0.38",
|
|
30
30
|
"be-hive": "0.0.116",
|
|
31
31
|
"be-propagating": "0.0.21",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"be-value-added": "0.0.2",
|
|
33
|
+
"trans-render": "0.0.702",
|
|
34
|
+
"xtal-element": "0.0.577"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"may-it-serve": "0.0.5",
|
|
37
|
-
"@playwright/test": "1.
|
|
38
|
+
"@playwright/test": "1.37.0"
|
|
38
39
|
},
|
|
39
40
|
"author": "anderson.bruce.b@gmail.com",
|
|
40
41
|
"license": "MIT"
|
package/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ActionOnEventConfigs } from "trans-render/froop/types";
|
|
2
2
|
import {IBE, Declarations} from 'be-enhanced/types';
|
|
3
|
+
import {BVAEndUserProps, BVAAllProps} from 'be-value-added/types';
|
|
3
4
|
|
|
4
|
-
export interface EndUserProps extends
|
|
5
|
+
export interface EndUserProps extends BVAEndUserProps<HTMLDataElement | HTMLTimeElement, number | Date | boolean>{
|
|
5
6
|
format?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions,
|
|
6
|
-
value?: number | Date;
|
|
7
7
|
locale?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface AllProps extends EndUserProps{
|
|
10
|
+
export interface AllProps extends EndUserProps, BVAAllProps{
|
|
11
11
|
intlDateFormat?: Intl.DateTimeFormat,
|
|
12
12
|
intlNumberFormat?: Intl.NumberFormat,
|
|
13
13
|
}
|