@bbn/bbn 2.0.24 → 2.0.26

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.
@@ -1,6 +1 @@
1
- export default function buildLocaleFromIntl(): {
2
- monthsLong: any[];
3
- monthsShort: any[];
4
- weekdaysLong: any[];
5
- weekdaysShort: any[];
6
- };
1
+ export default function buildLocaleFromIntl(): void;
@@ -1,4 +1,9 @@
1
+ import extend from "../../fn/object/extend.js";
2
+ import numProperties from "../../fn/object/numProperties.js";
1
3
  export default function buildLocaleFromIntl() {
4
+ if (numProperties(bbn.dt.locales)) {
5
+ return;
6
+ }
2
7
  const langs = [bbn.env.lang, ...navigator.languages];
3
8
  const fmtMonthLong = new Intl.DateTimeFormat(langs, { month: 'long' });
4
9
  const fmtMonthShort = new Intl.DateTimeFormat(langs, { month: 'short' });
@@ -22,11 +27,11 @@ export default function buildLocaleFromIntl() {
22
27
  weekdaysLong.push(fmtWeekLong.format(d));
23
28
  weekdaysShort.push(fmtWeekShort.format(d));
24
29
  }
25
- return {
30
+ extend(bbn.dt.locales, {
26
31
  monthsLong,
27
32
  monthsShort,
28
33
  weekdaysLong,
29
34
  weekdaysShort,
30
- };
35
+ });
31
36
  }
32
37
  ;
@@ -1,16 +1,17 @@
1
- import locales from '../vars/locales.js';
1
+ import buildLocaleFromIntl from './buildLocaleFromIntl.js';
2
2
  export default function parse(input, format, locale) {
3
3
  var _a, _b, _c, _d;
4
+ buildLocaleFromIntl();
4
5
  const TemporalAny = globalThis.Temporal;
5
6
  if (!TemporalAny) {
6
7
  throw new Error('Temporal API is required (load @js-temporal/polyfill)');
7
8
  }
8
9
  const T = TemporalAny;
9
10
  const loc = {
10
- monthsLong: (_a = locale === null || locale === void 0 ? void 0 : locale.monthsLong) !== null && _a !== void 0 ? _a : locales.monthsLong,
11
- monthsShort: (_b = locale === null || locale === void 0 ? void 0 : locale.monthsShort) !== null && _b !== void 0 ? _b : locales.monthsShort,
12
- weekdaysLong: (_c = locale === null || locale === void 0 ? void 0 : locale.weekdaysLong) !== null && _c !== void 0 ? _c : locales.weekdaysLong,
13
- weekdaysShort: (_d = locale === null || locale === void 0 ? void 0 : locale.weekdaysShort) !== null && _d !== void 0 ? _d : locales.weekdaysShort
11
+ monthsLong: (_a = locale === null || locale === void 0 ? void 0 : locale.monthsLong) !== null && _a !== void 0 ? _a : bbn.dt.locales.monthsLong,
12
+ monthsShort: (_b = locale === null || locale === void 0 ? void 0 : locale.monthsShort) !== null && _b !== void 0 ? _b : bbn.dt.locales.monthsShort,
13
+ weekdaysLong: (_c = locale === null || locale === void 0 ? void 0 : locale.weekdaysLong) !== null && _c !== void 0 ? _c : bbn.dt.locales.weekdaysLong,
14
+ weekdaysShort: (_d = locale === null || locale === void 0 ? void 0 : locale.weekdaysShort) !== null && _d !== void 0 ? _d : bbn.dt.locales.weekdaysShort
14
15
  };
15
16
  const escapeRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
16
17
  const makeTokenSpecs = () => [
package/dist/dt.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import parse from './dt/functions/parse.js';
2
2
  declare const dt: {
3
3
  (value: any, inputFormat?: null | String): void;
4
+ locales: any;
4
5
  parse: typeof parse;
5
6
  time(): void;
6
7
  date(): void;
package/dist/dt.js CHANGED
@@ -189,6 +189,7 @@ const unitsCorrespondence = {
189
189
  };
190
190
  const dt = (value, inputFormat = null) => {
191
191
  };
192
+ dt.locales = Object.create(null);
192
193
  dt.parse = parse;
193
194
  dt.time = () => { };
194
195
  dt.date = () => { };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ import { Temporal } from 'temporal-polyfill';
1
2
  declare const bbn: Bbn;
2
- export { bbn as default, bbn };
3
+ export { bbn as default, bbn, Temporal };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Temporal } from 'temporal-polyfill';
1
2
  import _ from './_.js';
2
3
  import $ from './$.js';
3
4
  import lng from './lng.js';
@@ -95,5 +96,8 @@ const bbn = {
95
96
  };
96
97
  if ('undefined' !== typeof window) {
97
98
  window.bbn = bbn;
99
+ if (!window.Temporal) {
100
+ window.Temporal = Temporal;
101
+ }
98
102
  }
99
- export { bbn as default, bbn };
103
+ export { bbn as default, bbn, Temporal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.24",
3
+ "version": "2.0.26",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- declare const locales: any;
2
- export default locales;
@@ -1,5 +0,0 @@
1
- import buildLocaleFromIntl from "../functions/buildLocaleFromIntl.js";
2
- import extend from "../../fn/object/extend.js";
3
- const locales = {};
4
- extend(locales, buildLocaleFromIntl());
5
- export default locales;