be-intl 0.0.27 → 0.0.28
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 +8 -0
- package/be-intl.js +34 -66
- package/behance.js +5 -0
- package/behivior.js +39 -6
- package/package.json +8 -8
- package/types.d.ts +4 -3
package/README.md
CHANGED
|
@@ -29,6 +29,14 @@ emits
|
|
|
29
29
|
<time lang="ar-EG" datetime="2011-11-18T14:54:39.929Z" be-intl="{ "weekday": "long", "year": "numeric", "month": "long", "day": "numeric" }">الجمعة، ١٨ نوفمبر ٢٠١١</time>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
[WIP]
|
|
33
|
+
|
|
34
|
+
We can also employ more semantic syntax:
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<data value=123456.789 lang="de-DE" be-intl-style=currency be-intl-currency=EUR></data>
|
|
38
|
+
```
|
|
39
|
+
|
|
32
40
|
[TODO] Support [expanding out the attribute](https://github.com/bahrus/be-hive#behivior-aspects-untested) to avoid use of JSON
|
|
33
41
|
|
|
34
42
|
## Viewing Locally
|
package/be-intl.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BeValueAdded, beValueAddedActions, beValueAddedPropDefaults, beValueAddedPropInfo } from 'be-value-added/be-value-added.js';
|
|
1
|
+
import { BeValueAdded } from 'be-value-added/be-value-added.js';
|
|
3
2
|
export class BeIntl extends BeValueAdded {
|
|
4
|
-
static
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
super.detach(detachedElement);
|
|
35
|
-
if (this.#langObserver !== undefined)
|
|
36
|
-
this.#langObserver.disconnect();
|
|
37
|
-
}
|
|
3
|
+
static config = {
|
|
4
|
+
propInfo: {
|
|
5
|
+
...(super.config.propInfo),
|
|
6
|
+
locale: {},
|
|
7
|
+
format: {},
|
|
8
|
+
intlDateFormat: {},
|
|
9
|
+
intlNumberFormat: {},
|
|
10
|
+
currency: {},
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
hydrate: {
|
|
14
|
+
ifAllOf: ['attached'],
|
|
15
|
+
},
|
|
16
|
+
formatNumber: {
|
|
17
|
+
ifKeyIn: ['value'],
|
|
18
|
+
ifAllOf: ['intlNumberFormat']
|
|
19
|
+
},
|
|
20
|
+
formatDate: {
|
|
21
|
+
ifKeyIn: ['value'],
|
|
22
|
+
ifAllOf: ['intlDateFormat']
|
|
23
|
+
},
|
|
24
|
+
onFormattingChange: {
|
|
25
|
+
ifAllOf: ['locale'],
|
|
26
|
+
ifKeyIn: ['format', 'currency']
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
positractions: [
|
|
30
|
+
...(super.config.positractions)
|
|
31
|
+
]
|
|
32
|
+
};
|
|
38
33
|
formatNumber(self) {
|
|
39
34
|
const { enhancedElement, value } = self;
|
|
40
35
|
if (value === undefined) {
|
|
@@ -49,7 +44,7 @@ export class BeIntl extends BeValueAdded {
|
|
|
49
44
|
enhancedElement.textContent = this.intlDateFormat.format(value);
|
|
50
45
|
}
|
|
51
46
|
onFormattingChange(self) {
|
|
52
|
-
const { enhancedElement, locale, format } = self;
|
|
47
|
+
const { enhancedElement, locale, format, currency } = self;
|
|
53
48
|
switch (enhancedElement.localName) {
|
|
54
49
|
case 'time':
|
|
55
50
|
return {
|
|
@@ -57,6 +52,8 @@ export class BeIntl extends BeValueAdded {
|
|
|
57
52
|
resolved: true
|
|
58
53
|
};
|
|
59
54
|
default:
|
|
55
|
+
if (currency !== undefined)
|
|
56
|
+
format.currency = currency;
|
|
60
57
|
return {
|
|
61
58
|
intlNumberFormat: new Intl.NumberFormat(locale, format),
|
|
62
59
|
resolved: true
|
|
@@ -64,32 +61,3 @@ export class BeIntl extends BeValueAdded {
|
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
|
-
const defaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
68
|
-
export const tagName = 'be-intl';
|
|
69
|
-
const xe = new XE({
|
|
70
|
-
config: {
|
|
71
|
-
tagName,
|
|
72
|
-
propDefaults: {
|
|
73
|
-
...beValueAddedPropDefaults,
|
|
74
|
-
},
|
|
75
|
-
propInfo: {
|
|
76
|
-
...beValueAddedPropInfo,
|
|
77
|
-
},
|
|
78
|
-
actions: {
|
|
79
|
-
...beValueAddedActions,
|
|
80
|
-
formatNumber: {
|
|
81
|
-
ifKeyIn: ['value'],
|
|
82
|
-
ifAllOf: ['intlNumberFormat']
|
|
83
|
-
},
|
|
84
|
-
formatDate: {
|
|
85
|
-
ifKeyIn: ['value'],
|
|
86
|
-
ifAllOf: ['intlDateFormat']
|
|
87
|
-
},
|
|
88
|
-
onFormattingChange: {
|
|
89
|
-
ifAllOf: ['locale'],
|
|
90
|
-
ifKeyIn: ['format']
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
superclass: BeIntl
|
|
95
|
-
});
|
package/behance.js
ADDED
package/behivior.js
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
import { BeHive } from 'be-hive/be-hive.js';
|
|
2
|
+
import { MountObserver } from 'mount-observer/MountObserver.js';
|
|
3
|
+
const base = 'be-intl';
|
|
4
|
+
const defaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
5
|
+
const emc = {
|
|
6
|
+
base,
|
|
7
|
+
branches: ['', 'style', 'currency',],
|
|
8
|
+
map: {
|
|
9
|
+
'0.0': {
|
|
10
|
+
instanceOf: 'Object',
|
|
11
|
+
mapsTo: 'format',
|
|
12
|
+
valIfFalsy: {},
|
|
13
|
+
},
|
|
14
|
+
'1.0': {
|
|
15
|
+
instanceOf: 'String',
|
|
16
|
+
mapsTo: '?.format?.style'
|
|
17
|
+
},
|
|
18
|
+
'2.0': {
|
|
19
|
+
instanceOf: 'String',
|
|
20
|
+
mapsTo: '?.format?.currency'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
osotas: [
|
|
24
|
+
{
|
|
25
|
+
name: 'lang',
|
|
26
|
+
valIfNull: defaultLocale,
|
|
27
|
+
mapsTo: 'locale',
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
enhPropKey: 'beIntl',
|
|
31
|
+
importEnh: async () => {
|
|
32
|
+
const { BeIntl } = await import('./behance.js');
|
|
33
|
+
return BeIntl;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const mose = document.createElement('script');
|
|
37
|
+
mose.id = base;
|
|
38
|
+
mose.synConfig = emc;
|
|
39
|
+
MountObserver.synthesize(document, BeHive, mose);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "be-intl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"web-components",
|
|
6
6
|
"web-component",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"update": "ncu -u && npm install"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"be-enhanced": "0.0.
|
|
30
|
-
"be-hive": "0.0.
|
|
31
|
-
"be-propagating": "0.0.
|
|
32
|
-
"be-value-added": "0.0.
|
|
33
|
-
"
|
|
34
|
-
"
|
|
29
|
+
"be-enhanced": "0.0.88",
|
|
30
|
+
"be-hive": "0.0.159",
|
|
31
|
+
"be-propagating": "0.0.39",
|
|
32
|
+
"be-value-added": "0.0.30",
|
|
33
|
+
"mount-observer": "0.0.25",
|
|
34
|
+
"trans-render": "0.0.769"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"may-it-serve": "0.0.6",
|
|
38
|
-
"@playwright/test": "1.
|
|
38
|
+
"@playwright/test": "1.44.1"
|
|
39
39
|
},
|
|
40
40
|
"author": "anderson.bruce.b@gmail.com",
|
|
41
41
|
"license": "MIT"
|
package/types.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { ActionOnEventConfigs } from "trans-render/froop/types";
|
|
2
|
-
import {
|
|
3
|
-
import {BVAEndUserProps, BVAAllProps} from 'be-value-added/types';
|
|
2
|
+
import {BVAEndUserProps, BVAAllProps, BVAActions} from 'be-value-added/types';
|
|
4
3
|
|
|
5
4
|
export interface EndUserProps extends BVAEndUserProps{
|
|
6
5
|
format?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions,
|
|
7
6
|
locale?: string;
|
|
8
7
|
observeAttr?: string;
|
|
8
|
+
currency?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface AllProps extends EndUserProps, BVAAllProps{
|
|
12
|
+
attached?: boolean;
|
|
12
13
|
intlDateFormat?: Intl.DateTimeFormat,
|
|
13
14
|
intlNumberFormat?: Intl.NumberFormat,
|
|
14
15
|
}
|
|
@@ -21,7 +22,7 @@ export type ProPAP = Promise<PAP>;
|
|
|
21
22
|
|
|
22
23
|
export type POA = [PAP | undefined, ActionOnEventConfigs<PAP, Actions>];
|
|
23
24
|
|
|
24
|
-
export interface Actions{
|
|
25
|
+
export interface Actions extends BVAActions {
|
|
25
26
|
formatNumber(self: this): void;
|
|
26
27
|
formatDate(self: this): void;
|
|
27
28
|
onFormattingChange(self: this): PAP;
|