@mgdis/core-ui-helpers 1.4.0 → 1.6.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/README.md CHANGED
@@ -93,3 +93,47 @@ Mostly used when your project doesn't have a bundler but uses scripts to compile
93
93
  <!-- Use in VUE project -->
94
94
  <script src="/node_modules/@mgdis/core-ui-helpers/dist/vue/index.umd.js"></script>
95
95
  ```
96
+
97
+ ## Migrating from the legacy helper packages
98
+
99
+ `@mgdis/mg-components-helpers`, `@mgdis/stencil-helpers` and `@mgdis/playwright-helpers` were thin re-export layers over this package and have been removed from the monorepo.
100
+
101
+ Their last published versions remain available on their respective registries, so existing projects keep working untouched. They will no longer receive updates: to pick up any new fix or feature, switch the import to `@mgdis/core-ui-helpers`.
102
+
103
+ ### `@mgdis/mg-components-helpers` (last version 4.2.20)
104
+
105
+ | Legacy import | Replacement |
106
+ | -------------------------------------- | ------------------------------------- |
107
+ | `@mgdis/mg-components-helpers/angular` | `@mgdis/core-ui-helpers/dist/angular` |
108
+ | `@mgdis/mg-components-helpers/utils` | `@mgdis/core-ui-helpers/dist/utils` |
109
+ | `@mgdis/mg-components-helpers/vue` | `@mgdis/core-ui-helpers/dist/vue` |
110
+
111
+ ### `@mgdis/stencil-helpers` (last version 3.2.20)
112
+
113
+ Everything was exported from the package root; the replacement module depends on the symbol.
114
+
115
+ **`@mgdis/core-ui-helpers/dist/utils`** — `createID`, `isValideID`, `formatID`, `ClassList`, `allItemsAreString`, `isTagName`, `focusableElements`, `getWindows`, `getParentWindows`, `isValidString`, `toString`, `isValidNumber`, `cleanString`, `nextTick`, `isObject`, `getObjectValueFromKey`, `Cursor`, `CursorType`, `Page`, `Paginate`, `ObjectType`, `dateToString`, `dateRegExp`
116
+
117
+ **`@mgdis/core-ui-helpers/dist/stencil`** — `webTypesGenerator`, `vsCodeGenerator`, `vsCodeCssGenerator`
118
+
119
+ **`@mgdis/core-ui-helpers/dist/locale`** — `localeCurrency`, `localeNumber`, `localePercent`, `localeUnit`, `localeDate`, `defineLocales`
120
+
121
+ **`@mgdis/core-ui-helpers/dist/storybook`** — `filterArgs`, `stencilWrapper`, `getStoryHTML`, `getStorybookUrl`, `StorybookPreview`
122
+
123
+ **`@mgdis/core-ui-helpers/dist/tests`** — `setupMutationObserverMock`, `setupResizeObserverMock`, `setupSubmitEventMock`, `setUpRequestAnimationFrameMock`
124
+
125
+ One symbol was renamed: `getLocaleDatePattern` is `localeDatePattern` in `@mgdis/core-ui-helpers/dist/locale`.
126
+
127
+ ```diff
128
+ -import { getLocaleDatePattern } from '@mgdis/stencil-helpers';
129
+ +import { localeDatePattern } from '@mgdis/core-ui-helpers/dist/locale';
130
+ ```
131
+
132
+ ### `@mgdis/playwright-helpers` (last version 1.1.23)
133
+
134
+ `playwrightBaseConfig`, `renderAttributes` and `renderProperties` all move to `@mgdis/core-ui-helpers/dist/playwright`; only the import path changes.
135
+
136
+ ```diff
137
+ -import { playwrightBaseConfig } from '@mgdis/playwright-helpers';
138
+ +import { playwrightBaseConfig } from '@mgdis/core-ui-helpers/dist/playwright';
139
+ ```
@@ -9,6 +9,15 @@
9
9
  * ```
10
10
  */
11
11
  const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
12
+ /**
13
+ * Local date time RegExp, matching the `<input type="datetime-local">` value with a minute precision
14
+ * @example
15
+ * ```ts
16
+ * dateTimeLocalRegExp.test('2020-12-31') // false
17
+ * dateTimeLocalRegExp.test('2020-12-31T23:59') // true
18
+ * ```
19
+ */
20
+ const dateTimeLocalRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d$/;
12
21
 
13
22
  /**
14
23
  * Gets the date pattern based on the specified locale.
@@ -28,6 +37,63 @@ const localeDatePattern = (locale) => {
28
37
  .replace(month.value, month.pattern)
29
38
  .replace(day.value, day.pattern);
30
39
  };
40
+ const dateTimeFormatOptions = {
41
+ year: 'numeric',
42
+ month: '2-digit',
43
+ day: '2-digit',
44
+ hour: '2-digit',
45
+ minute: '2-digit',
46
+ // the value has no time zone: format its wall-clock time as UTC so no time zone, nor DST gap, shifts it
47
+ timeZone: 'UTC',
48
+ };
49
+ const dateTimePatternParts = {
50
+ year: 'yyyy',
51
+ month: 'mm',
52
+ day: 'dd',
53
+ hour: 'hh',
54
+ minute: 'mm',
55
+ dayPeriod: 'AM/PM',
56
+ };
57
+ /**
58
+ * Gets the date time pattern based on the specified locale.
59
+ * @param locale - the locale to refer to
60
+ * @returns date time pattern
61
+ * @example
62
+ * ```ts
63
+ * localeDateTimePattern('fr') // 'dd/mm/yyyy hh:mm'
64
+ * localeDateTimePattern('en') // 'mm/dd/yyyy, hh:mm AM/PM'
65
+ * ```
66
+ */
67
+ const localeDateTimePattern = (locale) => new Intl.DateTimeFormat(locale, dateTimeFormatOptions)
68
+ .formatToParts(new Date(Date.UTC(2023, 11, 24, 14, 30)))
69
+ // some engines separate the day period with a narrow no-break space
70
+ .map(({ type, value }) => dateTimePatternParts[type] ?? value.replace(/\s/g, ' '))
71
+ .join('');
72
+ /**
73
+ * Locale date time format
74
+ * @param dateTime - local date time to format, without time zone (`yyyy-mm-ddThh:mm`)
75
+ * @param locale - locale to apply
76
+ * @returns formatted date time
77
+ * @example
78
+ * ```ts
79
+ * localeDateTime('2022-06-02T14:30', 'fr') // '02/06/2022 14:30'
80
+ * ```
81
+ */
82
+ const localeDateTime = (dateTime, locale) => typeof dateTime !== 'string' || !dateTimeLocalRegExp.test(dateTime)
83
+ ? ''
84
+ : new Intl.DateTimeFormat(locale, dateTimeFormatOptions).format(new Date(`${dateTime}Z`));
85
+ /**
86
+ * Find the closest element with a lang attribute, going out of shadow roots through their host
87
+ * @param element - element to start from
88
+ * @returns the closest element with a lang attribute or null
89
+ */
90
+ const closestLangElement = (element) => {
91
+ const found = element.closest('[lang]');
92
+ if (found !== null)
93
+ return found;
94
+ const root = element.getRootNode();
95
+ return root instanceof ShadowRoot ? closestLangElement(root.host) : null;
96
+ };
31
97
  /**
32
98
  * Get locale and messages
33
99
  * We load the defined locale but for now we only support the first subtag for messages
@@ -38,7 +104,7 @@ const localeDatePattern = (locale) => {
38
104
  */
39
105
  const localeMessages = (element, messages, defaultLocale) => {
40
106
  // Get local
41
- const closestLangAttribute = element.closest('[lang]');
107
+ const closestLangAttribute = closestLangElement(element);
42
108
  const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang);
43
109
  const locale = closestLang.length > 0 && typeof closestLang[0] === 'string' ? closestLang[0] : navigator.language || defaultLocale;
44
110
  // Only keep first subtag
@@ -184,6 +250,8 @@ exports.localeByte = localeByte;
184
250
  exports.localeCurrency = localeCurrency;
185
251
  exports.localeDate = localeDate;
186
252
  exports.localeDatePattern = localeDatePattern;
253
+ exports.localeDateTime = localeDateTime;
254
+ exports.localeDateTimePattern = localeDateTimePattern;
187
255
  exports.localeNumber = localeNumber;
188
256
  exports.localePercent = localePercent;
189
257
  exports.localeUnit = localeUnit;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/utils/date/date.ts","../../src/locale/locale.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,+CAA+C;;ACLzE;;;;;;;;AAQG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAAc,KAAI;IAClD,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;IAC/C,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5C,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;AAC1C,IAAA,OAAO,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC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I,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,aAAA,GAAwB,CAAC,KAAY;AACjG,IAAA,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;AACnC,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,qBAAqB,EAAE,aAAa;AACpC,QAAA,qBAAqB,EAAE,aAAa;AACrC,KAAA,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACnB;AAEA;;;;;;;;;;;;;;AAcG;AACI,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,MAAc,EACd,IAAsC,EACtC,WAAA,GAAuD,OAAO,EAC9D,aAAA,GAAwB,CAAC,KACf;AACV,IAAA,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;AACnC,QAAA,KAAK,EAAE,MAAM;QACb,IAAI;QACJ,WAAW;AACX,QAAA,qBAAqB,EAAE,aAAa;AACpC,QAAA,qBAAqB,EAAE,aAAa;AACrC,KAAA,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACnB;AAEA;;;;;;;;;;AAUG;AACI,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAc,EAAE,MAAmC,KACtG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI;AAC9D,MAAE;AACF,MAAE,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;AAEnE;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,aAAa,GACxB,CAAC,QAAoB,EAAE,aAA0B,KACjD,CAAC,OAAoB,KACnB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/utils/date/date.ts","../../src/locale/locale.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAAA;;;;;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AACnC,QAAA,KAAK,EAAE,MAAM;QACb,IAAI;QACJ,WAAW;AACX,QAAA,qBAAqB,EAAE,aAAa;AACpC,QAAA,qBAAqB,EAAE,aAAa;AACrC,KAAA,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACnB;AAEA;;;;;;;;;;AAUG;AACI,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAc,EAAE,MAAmC,KACtG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI;AAC9D,MAAE;AACF,MAAE,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;AAEnE;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,aAAa,GACxB,CAAC,QAAoB,EAAE,aAA0B,KACjD,CAAC,OAAoB,KACnB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa;;;;;;;;;;;"}
@@ -13,6 +13,28 @@ type ObjectType = Record<string, unknown>;
13
13
  * ```
14
14
  */
15
15
  declare const localeDatePattern: (locale: string) => string;
16
+ /**
17
+ * Gets the date time pattern based on the specified locale.
18
+ * @param locale - the locale to refer to
19
+ * @returns date time pattern
20
+ * @example
21
+ * ```ts
22
+ * localeDateTimePattern('fr') // 'dd/mm/yyyy hh:mm'
23
+ * localeDateTimePattern('en') // 'mm/dd/yyyy, hh:mm AM/PM'
24
+ * ```
25
+ */
26
+ declare const localeDateTimePattern: (locale: string) => string;
27
+ /**
28
+ * Locale date time format
29
+ * @param dateTime - local date time to format, without time zone (`yyyy-mm-ddThh:mm`)
30
+ * @param locale - locale to apply
31
+ * @returns formatted date time
32
+ * @example
33
+ * ```ts
34
+ * localeDateTime('2022-06-02T14:30', 'fr') // '02/06/2022 14:30'
35
+ * ```
36
+ */
37
+ declare const localeDateTime: (dateTime: string | undefined, locale: string) => string;
16
38
  /**
17
39
  * Format number to the locale currency
18
40
  * @param number - number to format
@@ -107,4 +129,4 @@ declare const defineLocales: (messages: ObjectType, defaultLocale: "fr" | "en")
107
129
  messages: ObjectType;
108
130
  };
109
131
 
110
- export { defineLocales, localeByte, localeCurrency, localeDate, localeDatePattern, localeNumber, localePercent, localeUnit };
132
+ export { defineLocales, localeByte, localeCurrency, localeDate, localeDatePattern, localeDateTime, localeDateTimePattern, localeNumber, localePercent, localeUnit };
@@ -7,6 +7,15 @@
7
7
  * ```
8
8
  */
9
9
  const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
10
+ /**
11
+ * Local date time RegExp, matching the `<input type="datetime-local">` value with a minute precision
12
+ * @example
13
+ * ```ts
14
+ * dateTimeLocalRegExp.test('2020-12-31') // false
15
+ * dateTimeLocalRegExp.test('2020-12-31T23:59') // true
16
+ * ```
17
+ */
18
+ const dateTimeLocalRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d$/;
10
19
 
11
20
  /**
12
21
  * Gets the date pattern based on the specified locale.
@@ -26,6 +35,63 @@ const localeDatePattern = (locale) => {
26
35
  .replace(month.value, month.pattern)
27
36
  .replace(day.value, day.pattern);
28
37
  };
38
+ const dateTimeFormatOptions = {
39
+ year: 'numeric',
40
+ month: '2-digit',
41
+ day: '2-digit',
42
+ hour: '2-digit',
43
+ minute: '2-digit',
44
+ // the value has no time zone: format its wall-clock time as UTC so no time zone, nor DST gap, shifts it
45
+ timeZone: 'UTC',
46
+ };
47
+ const dateTimePatternParts = {
48
+ year: 'yyyy',
49
+ month: 'mm',
50
+ day: 'dd',
51
+ hour: 'hh',
52
+ minute: 'mm',
53
+ dayPeriod: 'AM/PM',
54
+ };
55
+ /**
56
+ * Gets the date time pattern based on the specified locale.
57
+ * @param locale - the locale to refer to
58
+ * @returns date time pattern
59
+ * @example
60
+ * ```ts
61
+ * localeDateTimePattern('fr') // 'dd/mm/yyyy hh:mm'
62
+ * localeDateTimePattern('en') // 'mm/dd/yyyy, hh:mm AM/PM'
63
+ * ```
64
+ */
65
+ const localeDateTimePattern = (locale) => new Intl.DateTimeFormat(locale, dateTimeFormatOptions)
66
+ .formatToParts(new Date(Date.UTC(2023, 11, 24, 14, 30)))
67
+ // some engines separate the day period with a narrow no-break space
68
+ .map(({ type, value }) => dateTimePatternParts[type] ?? value.replace(/\s/g, ' '))
69
+ .join('');
70
+ /**
71
+ * Locale date time format
72
+ * @param dateTime - local date time to format, without time zone (`yyyy-mm-ddThh:mm`)
73
+ * @param locale - locale to apply
74
+ * @returns formatted date time
75
+ * @example
76
+ * ```ts
77
+ * localeDateTime('2022-06-02T14:30', 'fr') // '02/06/2022 14:30'
78
+ * ```
79
+ */
80
+ const localeDateTime = (dateTime, locale) => typeof dateTime !== 'string' || !dateTimeLocalRegExp.test(dateTime)
81
+ ? ''
82
+ : new Intl.DateTimeFormat(locale, dateTimeFormatOptions).format(new Date(`${dateTime}Z`));
83
+ /**
84
+ * Find the closest element with a lang attribute, going out of shadow roots through their host
85
+ * @param element - element to start from
86
+ * @returns the closest element with a lang attribute or null
87
+ */
88
+ const closestLangElement = (element) => {
89
+ const found = element.closest('[lang]');
90
+ if (found !== null)
91
+ return found;
92
+ const root = element.getRootNode();
93
+ return root instanceof ShadowRoot ? closestLangElement(root.host) : null;
94
+ };
29
95
  /**
30
96
  * Get locale and messages
31
97
  * We load the defined locale but for now we only support the first subtag for messages
@@ -36,7 +102,7 @@ const localeDatePattern = (locale) => {
36
102
  */
37
103
  const localeMessages = (element, messages, defaultLocale) => {
38
104
  // Get local
39
- const closestLangAttribute = element.closest('[lang]');
105
+ const closestLangAttribute = closestLangElement(element);
40
106
  const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang);
41
107
  const locale = closestLang.length > 0 && typeof closestLang[0] === 'string' ? closestLang[0] : navigator.language || defaultLocale;
42
108
  // Only keep first subtag
@@ -177,5 +243,5 @@ const localeDate = (date, locale, config) => typeof date !== 'string' || date ==
177
243
  */
178
244
  const defineLocales = (messages, defaultLocale) => (element) => localeMessages(element, messages, defaultLocale);
179
245
 
180
- export { defineLocales, localeByte, localeCurrency, localeDate, localeDatePattern, localeNumber, localePercent, localeUnit };
246
+ export { defineLocales, localeByte, localeCurrency, localeDate, localeDatePattern, localeDateTime, localeDateTimePattern, localeNumber, localePercent, localeUnit };
181
247
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/utils/date/date.ts","../../src/locale/locale.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAAA;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,+CAA+C;;ACLzE;;;;;;;;AAQG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAAc,KAAI;IAClD,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;IAC/C,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5C,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;AAC1C,IAAA,OAAO,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;SAC1F,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO;SAChC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO;SAClC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;AACpC;AAEA;;;;;;;AAOG;AACH,MAAM,cAAc,GAAG,CACrB,OAAoB,EACpB,QAAoB,EACpB,aAAqB,KACuB;;IAE5C,MAAM,oB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d,IAAsC,EACtC,WAAA,GAAuD,OAAO,EAC9D,aAAA,GAAwB,CAAC,KACf;AACV,IAAA,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;AACnC,QAAA,KAAK,EAAE,MAAM;QACb,IAAI;QACJ,WAAW;AACX,QAAA,qBAAqB,EAAE,aAAa;AACpC,QAAA,qBAAqB,EAAE,aAAa;AACrC,KAAA,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACnB;AAEA;;;;;;;;;;AAUG;AACI,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAc,EAAE,MAAmC,KACtG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI;AAC9D,MAAE;AACF,MAAE,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;AAEnE;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,aAAa,GACxB,CAAC,QAAoB,EAAE,aAA0B,KACjD,CAAC,OAAoB,KACnB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/utils/date/date.ts","../../src/locale/locale.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAAA;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,+CAA+C;AAEzE;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,uEAAuE;;ACf1G;;;;;;;;AAQG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAAc,KAAI;IAClD,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;IAC/C,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5C,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,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AE,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;AAEnE;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,aAAa,GACxB,CAAC,QAAoB,EAAE,aAA0B,KACjD,CAAC,OAAoB,KACnB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa;;"}
@@ -13,6 +13,15 @@
13
13
  * ```
14
14
  */
15
15
  const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
16
+ /**
17
+ * Local date time RegExp, matching the `<input type="datetime-local">` value with a minute precision
18
+ * @example
19
+ * ```ts
20
+ * dateTimeLocalRegExp.test('2020-12-31') // false
21
+ * dateTimeLocalRegExp.test('2020-12-31T23:59') // true
22
+ * ```
23
+ */
24
+ const dateTimeLocalRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d$/;
16
25
 
17
26
  /**
18
27
  * Gets the date pattern based on the specified locale.
@@ -32,6 +41,63 @@
32
41
  .replace(month.value, month.pattern)
33
42
  .replace(day.value, day.pattern);
34
43
  };
44
+ const dateTimeFormatOptions = {
45
+ year: 'numeric',
46
+ month: '2-digit',
47
+ day: '2-digit',
48
+ hour: '2-digit',
49
+ minute: '2-digit',
50
+ // the value has no time zone: format its wall-clock time as UTC so no time zone, nor DST gap, shifts it
51
+ timeZone: 'UTC',
52
+ };
53
+ const dateTimePatternParts = {
54
+ year: 'yyyy',
55
+ month: 'mm',
56
+ day: 'dd',
57
+ hour: 'hh',
58
+ minute: 'mm',
59
+ dayPeriod: 'AM/PM',
60
+ };
61
+ /**
62
+ * Gets the date time pattern based on the specified locale.
63
+ * @param locale - the locale to refer to
64
+ * @returns date time pattern
65
+ * @example
66
+ * ```ts
67
+ * localeDateTimePattern('fr') // 'dd/mm/yyyy hh:mm'
68
+ * localeDateTimePattern('en') // 'mm/dd/yyyy, hh:mm AM/PM'
69
+ * ```
70
+ */
71
+ const localeDateTimePattern = (locale) => new Intl.DateTimeFormat(locale, dateTimeFormatOptions)
72
+ .formatToParts(new Date(Date.UTC(2023, 11, 24, 14, 30)))
73
+ // some engines separate the day period with a narrow no-break space
74
+ .map(({ type, value }) => dateTimePatternParts[type] ?? value.replace(/\s/g, ' '))
75
+ .join('');
76
+ /**
77
+ * Locale date time format
78
+ * @param dateTime - local date time to format, without time zone (`yyyy-mm-ddThh:mm`)
79
+ * @param locale - locale to apply
80
+ * @returns formatted date time
81
+ * @example
82
+ * ```ts
83
+ * localeDateTime('2022-06-02T14:30', 'fr') // '02/06/2022 14:30'
84
+ * ```
85
+ */
86
+ const localeDateTime = (dateTime, locale) => typeof dateTime !== 'string' || !dateTimeLocalRegExp.test(dateTime)
87
+ ? ''
88
+ : new Intl.DateTimeFormat(locale, dateTimeFormatOptions).format(new Date(`${dateTime}Z`));
89
+ /**
90
+ * Find the closest element with a lang attribute, going out of shadow roots through their host
91
+ * @param element - element to start from
92
+ * @returns the closest element with a lang attribute or null
93
+ */
94
+ const closestLangElement = (element) => {
95
+ const found = element.closest('[lang]');
96
+ if (found !== null)
97
+ return found;
98
+ const root = element.getRootNode();
99
+ return root instanceof ShadowRoot ? closestLangElement(root.host) : null;
100
+ };
35
101
  /**
36
102
  * Get locale and messages
37
103
  * We load the defined locale but for now we only support the first subtag for messages
@@ -42,7 +108,7 @@
42
108
  */
43
109
  const localeMessages = (element, messages, defaultLocale) => {
44
110
  // Get local
45
- const closestLangAttribute = element.closest('[lang]');
111
+ const closestLangAttribute = closestLangElement(element);
46
112
  const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang);
47
113
  const locale = closestLang.length > 0 && typeof closestLang[0] === 'string' ? closestLang[0] : navigator.language || defaultLocale;
48
114
  // Only keep first subtag
@@ -188,6 +254,8 @@
188
254
  exports.localeCurrency = localeCurrency;
189
255
  exports.localeDate = localeDate;
190
256
  exports.localeDatePattern = localeDatePattern;
257
+ exports.localeDateTime = localeDateTime;
258
+ exports.localeDateTimePattern = localeDateTimePattern;
191
259
  exports.localeNumber = localeNumber;
192
260
  exports.localePercent = localePercent;
193
261
  exports.localeUnit = localeUnit;
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../../src/utils/date/date.ts","../../src/locale/locale.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;;;IAAA;;;;;;;IAOG;IACI,MAAM,UAAU,GAAG,+CAA+C;;ICLzE;;;;;;;;IAQG;AACI,UAAM,iBAAiB,GAAG,CAAC,MAAc,KAAI;QAClD,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;QAC/C,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5C,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC1C,IAAA,OAAO,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;aAC1F,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO;aAClC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;IACpC;IAEA;;;;;;;IAOG;IACH,MAAM,cAAc,GAAG,CACrB,OAAoB,EACpB,QAAoB,EACpB,aAAqB,KACuB;;QAE5C,MAAM,oBAAoB,GAAuB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC1E,IAAA,MAAM,WAAW,GAAa,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,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I,CAAC;IAEnE;;;;;;;;;;;;;;;;IAgBG;AACI,UAAM,aAAa,GACxB,CAAC,QAAoB,EAAE,aAA0B,KACjD,CAAC,OAAoB,KACnB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa;;;;;;;;;;;;;"}
@@ -285,7 +285,11 @@ const componentToModule = (component) => {
285
285
  name: className,
286
286
  tagName: component.tag,
287
287
  customElement: true,
288
- description: component.overview ?? '',
288
+ // The readme carries the hand-written usage notes, which agents read from the manifest.
289
+ description: [component.overview, component.readme]
290
+ .map((text) => text?.trim())
291
+ .filter(Boolean)
292
+ .join('\n\n'),
289
293
  attributes,
290
294
  members: [...fieldMembers, ...methodMembers],
291
295
  events: component.events.map((event) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../node_modules/.pnpm/htmlfy@1.1.0/node_modules/htmlfy/src/constants.js","../../../../node_modules/.pnpm/htmlfy@1.1.0/node_modules/htmlfy/src/prettify.js","../../src/storybook/stencil/stencil.ts","../../src/stencil/ide/ide.ts","../../src/stencil/ide/cem.ts","../../src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.ts","../../src/stencil/resolve-prop-value/resolve-prop-value.ts"],"sourcesContent":["/**\n * @type {import('htmlfy').Config}\n */\nexport const CONFIG = {\n content_wrap: 0,\n ignore: [],\n ignore_with: '!i-£___£%_',\n strict: false,\n tab_size: 2,\n tag_wrap: 0,\n trim: []\n}\n\nexport const VOID_ELEMENTS = [\n 'area', 'base', 'br', 'col', 'embed', 'hr', \n 'img', 'input', 'link', 'meta',\n 'param', 'source', 'track', 'wbr'\n]\n\n/**\n * Defined per formatting operation from configuration.\n * \n * CONTENT_IGNORE_PLACEHOLDER\n * SELF_CLOSING_PLACEHOLDER\n * ATTRIBUTE_IGNORE_PLACEHOLDER\n */\n","import { minifyKnownHtml } from './minify.js'\nimport { \n createConstants,\n extractIgnoredBlocks,\n finalProtectContent,\n isHtml, \n protectAttributes, \n reinsertIgnoredBlocks, \n setIgnoreAttribute, \n setSelfClosing, \n trimify, \n unprotectAttributes, \n unprotectContent, \n unsetIgnoreAttribute, \n validateConfig, \n wordWrap\n} from './utils.js'\nimport { VOID_ELEMENTS } from './constants.js'\n\nconst VOID_ELEMENT_SET = new Set(VOID_ELEMENTS)\nconst TOKEN_CLOSING = 1\nconst TOKEN_COMMENT = 2\nconst TOKEN_DOCTYPE = 4\nconst TOKEN_IGNORED = 8\nconst TOKEN_SELF_CLOSING = 16\nconst TOKEN_SYNTHETIC_SELF_CLOSING = 32\nconst TOKEN_INLINE = 64\n\n/**\n * @typedef {object} Token\n * @property {'tag' | 'text'} type\n * @property {string} value\n * @property {number} flags\n */\n\n/**\n * Isolate tags, content, and comments.\n * \n * @param {string} html The HTML string to evaluate.\n * @param {import('./utils.js').HtmlfyConstants} constants\n * @returns {Token[]}\n */\nconst enqueue = (html, constants) => {\n /** @type {Token[]} */\n const lines = []\n /* Regex to find tags OR text content between tags. */\n const regex = /<[^>]+>|[^<]+/g\n\n /* Use replace for callback iteration, but avoid constructing the old marker output. */\n html.replace(regex, (value) => {\n const type = value.startsWith('<') ? 'tag' : 'text'\n\n if (type === 'text') {\n if (value.trim().length > 0) {\n lines.push({\n type,\n value,\n flags: value.startsWith('___HTMLFY_SPECIAL_IGNORE_MARKER_') ? TOKEN_IGNORED : 0,\n })\n }\n return ''\n }\n\n const trimmed = value.trim()\n const synthetic_self_closing = trimmed.endsWith(constants.SELF_CLOSING_PLACEHOLDER)\n let flags = 0\n if (trimmed.startsWith('</')) flags |= TOKEN_CLOSING\n if (trimmed.startsWith('<!--')) flags |= TOKEN_COMMENT\n if (trimmed.startsWith('<!doctype')) flags |= TOKEN_DOCTYPE\n if (trimmed.endsWith('/>') || synthetic_self_closing) flags |= TOKEN_SELF_CLOSING\n if (synthetic_self_closing) flags |= TOKEN_SYNTHETIC_SELF_CLOSING\n\n lines.push({\n type,\n value,\n flags,\n })\n return ''\n })\n\n return lines\n}\n\n/**\n * Collapse the same simple element pairs handled by the final output regex.\n *\n * @param {Token[]} lines\n * @returns {Token[]}\n */\nconst collapseInlineTokens = (lines) => {\n /** @type {Token[]} */\n const collapsed = []\n\n for (let index = 0; index < lines.length; index++) {\n const opening = lines[index]\n\n if (opening.type === 'tag' && !(opening.flags & (\n TOKEN_CLOSING |\n TOKEN_COMMENT |\n TOKEN_DOCTYPE |\n TOKEN_SELF_CLOSING\n ))) {\n const name_match = opening.value.match(/^<([^>\\s]+)[^>]*>$/)\n const name = name_match?.[1]\n const content = lines[index + 1]\n const possible_closing = content?.type === 'text' ? lines[index + 2] : content\n\n if (name && possible_closing?.value === `</${name}>`) {\n const empty_pair = content?.type === 'tag' && /^[\\w:._-]+$/.test(name)\n const text_pair = content?.type === 'text' && /[^><\\/\\s]/.test(content.value)\n\n if (empty_pair || text_pair) {\n collapsed.push({\n type: 'tag',\n value: opening.value + (text_pair ? content.value.trim() : '') + possible_closing.value,\n flags: TOKEN_INLINE,\n })\n index += text_pair ? 2 : 1\n continue\n }\n }\n }\n\n collapsed.push(opening)\n }\n\n return collapsed\n}\n\n/**\n * Process enqueued content.\n * \n * @param {Token[]} lines\n * @param {import('htmlfy').Config} config\n * @param {import('./utils.js').HtmlfyConstants} constants\n * @returns {string}\n */\nconst process = (lines, config, constants) => {\n const step = \" \".repeat(config.tab_size)\n const tag_wrap = config.tag_wrap\n const content_wrap = config.content_wrap\n const strict = config.strict\n\n /* Track current number of indentations needed. */\n let indent_level = 0\n\n /** @type string[] */\n const output_lines = []\n const tag_regex = /<[A-Za-z]+\\b[^>]*(?:.|\\n)*?\\/?>/ /* Is opening tag or void element. */\n const attribute_regex = /\\s{1}[A-Za-z:@#*?$()\\[\\].-]+(?:=\".*?\")?/g /* Matches all tag/element attributes. */\n\n /* Process lines and indent. */\n lines.forEach((source, index) => {\n let current_line_value = source.value\n\n let subtrahend = 0\n const prev_line_data = lines[index - 1]\n\n indent_level++\n\n if (index === 0) subtrahend++\n /* We're processing a closing tag. */\n if (source.flags & TOKEN_CLOSING) subtrahend++\n /* prevLine is a doctype declaration. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_DOCTYPE)) subtrahend++\n /* prevLine is a comment. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_COMMENT)) subtrahend++\n /* prevLine is a void element. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_SELF_CLOSING)) subtrahend++\n /* prevLine is a closing tag. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_CLOSING)) subtrahend++\n /* prevLine opens and closes on the same line. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_INLINE)) subtrahend++\n /* prevLine is text. */\n if (prev_line_data?.type === \"text\") subtrahend++\n\n /* Determine offset for line indentation. */\n const offset = Math.max(0, indent_level - subtrahend)\n /* Correct indent level for *this* line's content */\n const current_indent_level = offset // Store the level for this line\n\n indent_level = current_indent_level\n\n /**\n * Starts with a single punctuation character.\n * Add punctuation to end of previous line.\n */\n if (source.type === 'text' && /^[!,;\\.]/.test(current_line_value)) {\n if (current_line_value.length === 1) {\n output_lines[output_lines.length - 1] = \n output_lines.at(-1) + current_line_value\n return\n } else {\n output_lines[output_lines.length - 1] = \n output_lines.at(-1) + current_line_value.charAt(0)\n current_line_value = current_line_value.slice(1).trim()\n\n /* If nothing left after extracting punctuation, skip this line. */\n if (current_line_value.length === 0) return\n }\n }\n\n const padding = step.repeat(current_indent_level)\n\n if (source.flags & TOKEN_IGNORED) {\n /* Stop processing this line, as it's set to be ignored. */\n output_lines.push(current_line_value)\n } else {\n /* Remove comment. */\n if (strict && (source.flags & TOKEN_COMMENT))\n return\n\n let result = current_line_value\n\n /* Remove self-closing placeholder, if needed. */\n if (source.flags & TOKEN_SYNTHETIC_SELF_CLOSING)\n result = result.replace(constants.SELF_CLOSING_PLACEHOLDER, '>')\n\n if (\n source.type === 'text' && \n content_wrap > 0 && \n result.length >= content_wrap\n ) {\n result = wordWrap(result, content_wrap, padding, constants)\n }\n /* Wrap the attributes of open tags and void elements. */\n else if (\n tag_wrap > 0 &&\n result.length > tag_wrap &&\n tag_regex.test(result)\n ) {\n attribute_regex.lastIndex = 0 // Reset stateful regex\n\n const attributes = []\n let first_attribute_start = -1\n let last_attribute_end = -1\n let attribute_match\n\n while ((attribute_match = attribute_regex.exec(result)) !== null) {\n if (first_attribute_start === -1) first_attribute_start = attribute_match.index\n last_attribute_end = attribute_regex.lastIndex\n attributes.push(attribute_match[0].trim())\n }\n\n if (attributes.length > 0) {\n const opening_part = result.slice(0, first_attribute_start)\n const closing_part = result.slice(last_attribute_end).trim()\n const inner_padding = padding + step\n const wrapped_tag = [padding + opening_part]\n\n for (const attribute of attributes) {\n wrapped_tag.push(inner_padding + attribute)\n }\n\n const tag_name_match = opening_part.match(/<([A-Za-z_:-]+)/)\n const tag_name = tag_name_match ? tag_name_match[1] : \"\"\n const is_self_closing = result.endsWith(\"/>\") && VOID_ELEMENT_SET.has(tag_name)\n const closing_padding = padding + (strict && is_self_closing ? \" \" : \"\")\n\n wrapped_tag.push(closing_padding + closing_part)\n result = wrapped_tag.join('\\n')\n } else {\n result = padding + result\n }\n } else {\n /* Apply simple indentation (if no wrapping occurred) */\n result = padding + result\n }\n\n /* Add the processed line (or lines if wordWrap creates them) to the output */\n output_lines.push(result)\n }\n })\n\n /* Join all processed lines into the final HTML string */\n let final_html = output_lines.join(\"\\n\")\n\n /* Preserve wrapped attributes. */\n if (tag_wrap > 0) final_html = protectAttributes(final_html, constants)\n\n /* Extra preserve wrapped content. */\n if (content_wrap > 0 && new RegExp(`/\\\\n[ ]*[^\\\\n]*${constants.CONTENT_IGNORE_PLACEHOLDER}[^\\\\n]*\\\\n/`).test(final_html))\n final_html = finalProtectContent(final_html, constants)\n\n /* Remove line returns, tabs, and consecutive spaces within html elements or their content. */\n if (tag_wrap > 0 || content_wrap > 0) {\n final_html = final_html.replace(\n /<(?<Element>[^>\\s]+)[^>]*>[^<]*?[^><\\/\\s][^<]*?<\\/\\k<Element>>|<script[^>]*>[\\s]*<\\/script>|<([\\w:\\._-]+)([^>]*)><\\/\\2>|<([\\w:\\._-]+)([^>]*)>[\\s]+<\\/\\4>/g,\n match => {\n // Check if this contains placeholder\n if (match.includes(constants.SELF_CLOSING_PLACEHOLDER) || match.includes(constants.CONTENT_IGNORE_PLACEHOLDER)) {\n return match // Don't modify if it contains the placeholder\n }\n\n return match.replace(/\\n|\\t|\\s{2,}/g, '')\n }\n )\n }\n\n /* Revert wrapped content. */\n if (content_wrap > 0) final_html = unprotectContent(final_html, constants)\n\n /* Revert wrapped attributes. */\n if (tag_wrap > 0) final_html = unprotectAttributes(final_html, constants)\n\n /* Remove self-closing nature of void elements. */\n if (strict) final_html = final_html.replace(/\\s\\/>|\\/>/g, '>')\n\n /* Trim leading and/or trailing line returns. */\n if (final_html.startsWith(\"\\n\")) final_html = final_html.substring(1)\n if (final_html.endsWith(\"\\n\")) final_html = final_html.substring(0, final_html.length - 1)\n\n return final_html\n}\n\n/**\n * Format HTML with line returns and indentations.\n * \n * @param {string} html The HTML string to prettify.\n * @param {import('htmlfy').UserConfig} [config] A user configuration object.\n * @returns {string} A well-formed HTML string.\n */\nexport const prettify = (html, config) => {\n /* Return content as-is if it does not contain any HTML elements. */\n if (!isHtml(html)) return html\n\n const validated_config = validateConfig(config || {})\n const constants = createConstants(validated_config.ignore_with)\n\n const ignore = validated_config.ignore.length > 0\n\n /** @type {Map<any,any> | undefined} */\n let ignore_map\n\n /* Allows you to trimify before ignoring. */\n if (validated_config.trim.length > 0) html = trimify(html, validated_config.trim)\n\n /* Extract ignored elements. */\n if (ignore) {\n const { html_with_markers, extracted_map } = extractIgnoredBlocks(html, validated_config.ignore)\n html = html_with_markers\n ignore_map = extracted_map\n }\n\n /* Preserve html text within attribute values. */\n html = setIgnoreAttribute(html, constants)\n\n /* Insert placeholder for void elements that aren't self-closing. */\n html = setSelfClosing(html, constants)\n\n html = minifyKnownHtml(html, validated_config)\n let lines = enqueue(html, constants)\n if (validated_config.tag_wrap === 0 && validated_config.content_wrap === 0)\n lines = collapseInlineTokens(lines)\n html = process(lines, validated_config, constants)\n\n /* Revert html text within attribute values. */\n html = unsetIgnoreAttribute(html, constants)\n\n /* Re-insert ignored elements. */\n if (ignore_map) {\n html = reinsertIgnoredBlocks(html, ignore_map)\n }\n\n return html\n}\n",null,null,null,null,null],"names":[],"mappings":";;AAAA;AACA;AACA;;AAWO,MAAM,aAAa,GAAG;AAC7B,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI;AAC5C,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;AAChC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNyB,IAAI,GAAG,CAAC,aAAa;;AC0I9C;;;;;AAKG;AACI,MAAM,eAAe,GAAG,CAAC,gBAAwB,EAAE,QAA4B,KAAwB;IAC5G,IAAI,CAAC,QAAQ,EAAE;QACb;IACF;IACA,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC;IACjC,OAAO,CAAA,EAAG,gBAAgB,CAAA,EAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,MAAA,CAAQ;AACjF,CAAC;;ACtKD;;;;;AAKG;AACH,MAAM,aAAa,GAAG,CAAC,cAAsB,EAAE,QAA4B,KAAwB;IACjG,IAAI,CAAC,QAAQ,EAAE;QACb;IACF;AACA,IAAA,OAAO,CAAA,EAAG,cAAc,CAAA,EAAG,QAAQ,EAAE;AACvC,CAAC;AAED;;;;;;;;;;AAUG;AACH,MAAM,qBAAqB,GAAG,CAAC,SAA4B,KAAY;AACrE,IAAA,IAAI,WAAW,GAAG,SAAS,CAAC,QAAQ,GAAG,CAAA,EAAG,SAAS,CAAC,QAAQ,CAAA,IAAA,CAAM,GAAG,EAAE;AACvE,IAAA,M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;AACP,YAAA;AACE,gBAAA,IAAI,EAAE,2BAAoC;gBAC1C,IAAI,EAAE,SAAS,CAAC,GAAG;AACnB,gBAAA,WAAW,EAAE;AACX,oBAAA,IAAI,EAAE,SAAS;AACf,oBAAA,MAAM,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;AACjC,iBAAA;AACF,aAAA;AACF,SAAA;KACF;AACH,CAAC;AAED;;;;;;;;AAQG;MACU,YAAY,GAAG,CAAC,QAAkB,MAAM;AACnD,IAAA,aAAa,EAAE,OAAO;AACtB,IAAA,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACpD,CAAA;;AC/FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACI,MAAM,0BAA0B,GAAG,CAAC,MAAgC,KAAU;AACnF,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAClF,IAAI,OAAQ,MAAkC,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;YACtE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5C;IACF;AACF;;ACvCA;;;;;;;AAOG;AACI,MAAM,gBAAgB,GAAG,CAAI,KAAgC,EAAE,QAAW,KAC/E,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,GAAG,QAAQ,GAAG;;;;;;;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../node_modules/.pnpm/htmlfy@1.1.0/node_modules/htmlfy/src/constants.js","../../../../node_modules/.pnpm/htmlfy@1.1.0/node_modules/htmlfy/src/prettify.js","../../src/storybook/stencil/stencil.ts","../../src/stencil/ide/ide.ts","../../src/stencil/ide/cem.ts","../../src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.ts","../../src/stencil/resolve-prop-value/resolve-prop-value.ts"],"sourcesContent":["/**\n * @type {import('htmlfy').Config}\n */\nexport const CONFIG = {\n content_wrap: 0,\n ignore: [],\n ignore_with: '!i-£___£%_',\n strict: false,\n tab_size: 2,\n tag_wrap: 0,\n trim: []\n}\n\nexport const VOID_ELEMENTS = [\n 'area', 'base', 'br', 'col', 'embed', 'hr', \n 'img', 'input', 'link', 'meta',\n 'param', 'source', 'track', 'wbr'\n]\n\n/**\n * Defined per formatting operation from configuration.\n * \n * CONTENT_IGNORE_PLACEHOLDER\n * SELF_CLOSING_PLACEHOLDER\n * ATTRIBUTE_IGNORE_PLACEHOLDER\n */\n","import { minifyKnownHtml } from './minify.js'\nimport { \n createConstants,\n extractIgnoredBlocks,\n finalProtectContent,\n isHtml, \n protectAttributes, \n reinsertIgnoredBlocks, \n setIgnoreAttribute, \n setSelfClosing, \n trimify, \n unprotectAttributes, \n unprotectContent, \n unsetIgnoreAttribute, \n validateConfig, \n wordWrap\n} from './utils.js'\nimport { VOID_ELEMENTS } from './constants.js'\n\nconst VOID_ELEMENT_SET = new Set(VOID_ELEMENTS)\nconst TOKEN_CLOSING = 1\nconst TOKEN_COMMENT = 2\nconst TOKEN_DOCTYPE = 4\nconst TOKEN_IGNORED = 8\nconst TOKEN_SELF_CLOSING = 16\nconst TOKEN_SYNTHETIC_SELF_CLOSING = 32\nconst TOKEN_INLINE = 64\n\n/**\n * @typedef {object} Token\n * @property {'tag' | 'text'} type\n * @property {string} value\n * @property {number} flags\n */\n\n/**\n * Isolate tags, content, and comments.\n * \n * @param {string} html The HTML string to evaluate.\n * @param {import('./utils.js').HtmlfyConstants} constants\n * @returns {Token[]}\n */\nconst enqueue = (html, constants) => {\n /** @type {Token[]} */\n const lines = []\n /* Regex to find tags OR text content between tags. */\n const regex = /<[^>]+>|[^<]+/g\n\n /* Use replace for callback iteration, but avoid constructing the old marker output. */\n html.replace(regex, (value) => {\n const type = value.startsWith('<') ? 'tag' : 'text'\n\n if (type === 'text') {\n if (value.trim().length > 0) {\n lines.push({\n type,\n value,\n flags: value.startsWith('___HTMLFY_SPECIAL_IGNORE_MARKER_') ? TOKEN_IGNORED : 0,\n })\n }\n return ''\n }\n\n const trimmed = value.trim()\n const synthetic_self_closing = trimmed.endsWith(constants.SELF_CLOSING_PLACEHOLDER)\n let flags = 0\n if (trimmed.startsWith('</')) flags |= TOKEN_CLOSING\n if (trimmed.startsWith('<!--')) flags |= TOKEN_COMMENT\n if (trimmed.startsWith('<!doctype')) flags |= TOKEN_DOCTYPE\n if (trimmed.endsWith('/>') || synthetic_self_closing) flags |= TOKEN_SELF_CLOSING\n if (synthetic_self_closing) flags |= TOKEN_SYNTHETIC_SELF_CLOSING\n\n lines.push({\n type,\n value,\n flags,\n })\n return ''\n })\n\n return lines\n}\n\n/**\n * Collapse the same simple element pairs handled by the final output regex.\n *\n * @param {Token[]} lines\n * @returns {Token[]}\n */\nconst collapseInlineTokens = (lines) => {\n /** @type {Token[]} */\n const collapsed = []\n\n for (let index = 0; index < lines.length; index++) {\n const opening = lines[index]\n\n if (opening.type === 'tag' && !(opening.flags & (\n TOKEN_CLOSING |\n TOKEN_COMMENT |\n TOKEN_DOCTYPE |\n TOKEN_SELF_CLOSING\n ))) {\n const name_match = opening.value.match(/^<([^>\\s]+)[^>]*>$/)\n const name = name_match?.[1]\n const content = lines[index + 1]\n const possible_closing = content?.type === 'text' ? lines[index + 2] : content\n\n if (name && possible_closing?.value === `</${name}>`) {\n const empty_pair = content?.type === 'tag' && /^[\\w:._-]+$/.test(name)\n const text_pair = content?.type === 'text' && /[^><\\/\\s]/.test(content.value)\n\n if (empty_pair || text_pair) {\n collapsed.push({\n type: 'tag',\n value: opening.value + (text_pair ? content.value.trim() : '') + possible_closing.value,\n flags: TOKEN_INLINE,\n })\n index += text_pair ? 2 : 1\n continue\n }\n }\n }\n\n collapsed.push(opening)\n }\n\n return collapsed\n}\n\n/**\n * Process enqueued content.\n * \n * @param {Token[]} lines\n * @param {import('htmlfy').Config} config\n * @param {import('./utils.js').HtmlfyConstants} constants\n * @returns {string}\n */\nconst process = (lines, config, constants) => {\n const step = \" \".repeat(config.tab_size)\n const tag_wrap = config.tag_wrap\n const content_wrap = config.content_wrap\n const strict = config.strict\n\n /* Track current number of indentations needed. */\n let indent_level = 0\n\n /** @type string[] */\n const output_lines = []\n const tag_regex = /<[A-Za-z]+\\b[^>]*(?:.|\\n)*?\\/?>/ /* Is opening tag or void element. */\n const attribute_regex = /\\s{1}[A-Za-z:@#*?$()\\[\\].-]+(?:=\".*?\")?/g /* Matches all tag/element attributes. */\n\n /* Process lines and indent. */\n lines.forEach((source, index) => {\n let current_line_value = source.value\n\n let subtrahend = 0\n const prev_line_data = lines[index - 1]\n\n indent_level++\n\n if (index === 0) subtrahend++\n /* We're processing a closing tag. */\n if (source.flags & TOKEN_CLOSING) subtrahend++\n /* prevLine is a doctype declaration. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_DOCTYPE)) subtrahend++\n /* prevLine is a comment. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_COMMENT)) subtrahend++\n /* prevLine is a void element. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_SELF_CLOSING)) subtrahend++\n /* prevLine is a closing tag. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_CLOSING)) subtrahend++\n /* prevLine opens and closes on the same line. */\n if (prev_line_data && (prev_line_data.flags & TOKEN_INLINE)) subtrahend++\n /* prevLine is text. */\n if (prev_line_data?.type === \"text\") subtrahend++\n\n /* Determine offset for line indentation. */\n const offset = Math.max(0, indent_level - subtrahend)\n /* Correct indent level for *this* line's content */\n const current_indent_level = offset // Store the level for this line\n\n indent_level = current_indent_level\n\n /**\n * Starts with a single punctuation character.\n * Add punctuation to end of previous line.\n */\n if (source.type === 'text' && /^[!,;\\.]/.test(current_line_value)) {\n if (current_line_value.length === 1) {\n output_lines[output_lines.length - 1] = \n output_lines.at(-1) + current_line_value\n return\n } else {\n output_lines[output_lines.length - 1] = \n output_lines.at(-1) + current_line_value.charAt(0)\n current_line_value = current_line_value.slice(1).trim()\n\n /* If nothing left after extracting punctuation, skip this line. */\n if (current_line_value.length === 0) return\n }\n }\n\n const padding = step.repeat(current_indent_level)\n\n if (source.flags & TOKEN_IGNORED) {\n /* Stop processing this line, as it's set to be ignored. */\n output_lines.push(current_line_value)\n } else {\n /* Remove comment. */\n if (strict && (source.flags & TOKEN_COMMENT))\n return\n\n let result = current_line_value\n\n /* Remove self-closing placeholder, if needed. */\n if (source.flags & TOKEN_SYNTHETIC_SELF_CLOSING)\n result = result.replace(constants.SELF_CLOSING_PLACEHOLDER, '>')\n\n if (\n source.type === 'text' && \n content_wrap > 0 && \n result.length >= content_wrap\n ) {\n result = wordWrap(result, content_wrap, padding, constants)\n }\n /* Wrap the attributes of open tags and void elements. */\n else if (\n tag_wrap > 0 &&\n result.length > tag_wrap &&\n tag_regex.test(result)\n ) {\n attribute_regex.lastIndex = 0 // Reset stateful regex\n\n const attributes = []\n let first_attribute_start = -1\n let last_attribute_end = -1\n let attribute_match\n\n while ((attribute_match = attribute_regex.exec(result)) !== null) {\n if (first_attribute_start === -1) first_attribute_start = attribute_match.index\n last_attribute_end = attribute_regex.lastIndex\n attributes.push(attribute_match[0].trim())\n }\n\n if (attributes.length > 0) {\n const opening_part = result.slice(0, first_attribute_start)\n const closing_part = result.slice(last_attribute_end).trim()\n const inner_padding = padding + step\n const wrapped_tag = [padding + opening_part]\n\n for (const attribute of attributes) {\n wrapped_tag.push(inner_padding + attribute)\n }\n\n const tag_name_match = opening_part.match(/<([A-Za-z_:-]+)/)\n const tag_name = tag_name_match ? tag_name_match[1] : \"\"\n const is_self_closing = result.endsWith(\"/>\") && VOID_ELEMENT_SET.has(tag_name)\n const closing_padding = padding + (strict && is_self_closing ? \" \" : \"\")\n\n wrapped_tag.push(closing_padding + closing_part)\n result = wrapped_tag.join('\\n')\n } else {\n result = padding + result\n }\n } else {\n /* Apply simple indentation (if no wrapping occurred) */\n result = padding + result\n }\n\n /* Add the processed line (or lines if wordWrap creates them) to the output */\n output_lines.push(result)\n }\n })\n\n /* Join all processed lines into the final HTML string */\n let final_html = output_lines.join(\"\\n\")\n\n /* Preserve wrapped attributes. */\n if (tag_wrap > 0) final_html = protectAttributes(final_html, constants)\n\n /* Extra preserve wrapped content. */\n if (content_wrap > 0 && new RegExp(`/\\\\n[ ]*[^\\\\n]*${constants.CONTENT_IGNORE_PLACEHOLDER}[^\\\\n]*\\\\n/`).test(final_html))\n final_html = finalProtectContent(final_html, constants)\n\n /* Remove line returns, tabs, and consecutive spaces within html elements or their content. */\n if (tag_wrap > 0 || content_wrap > 0) {\n final_html = final_html.replace(\n /<(?<Element>[^>\\s]+)[^>]*>[^<]*?[^><\\/\\s][^<]*?<\\/\\k<Element>>|<script[^>]*>[\\s]*<\\/script>|<([\\w:\\._-]+)([^>]*)><\\/\\2>|<([\\w:\\._-]+)([^>]*)>[\\s]+<\\/\\4>/g,\n match => {\n // Check if this contains placeholder\n if (match.includes(constants.SELF_CLOSING_PLACEHOLDER) || match.includes(constants.CONTENT_IGNORE_PLACEHOLDER)) {\n return match // Don't modify if it contains the placeholder\n }\n\n return match.replace(/\\n|\\t|\\s{2,}/g, '')\n }\n )\n }\n\n /* Revert wrapped content. */\n if (content_wrap > 0) final_html = unprotectContent(final_html, constants)\n\n /* Revert wrapped attributes. */\n if (tag_wrap > 0) final_html = unprotectAttributes(final_html, constants)\n\n /* Remove self-closing nature of void elements. */\n if (strict) final_html = final_html.replace(/\\s\\/>|\\/>/g, '>')\n\n /* Trim leading and/or trailing line returns. */\n if (final_html.startsWith(\"\\n\")) final_html = final_html.substring(1)\n if (final_html.endsWith(\"\\n\")) final_html = final_html.substring(0, final_html.length - 1)\n\n return final_html\n}\n\n/**\n * Format HTML with line returns and indentations.\n * \n * @param {string} html The HTML string to prettify.\n * @param {import('htmlfy').UserConfig} [config] A user configuration object.\n * @returns {string} A well-formed HTML string.\n */\nexport const prettify = (html, config) => {\n /* Return content as-is if it does not contain any HTML elements. */\n if (!isHtml(html)) return html\n\n const validated_config = validateConfig(config || {})\n const constants = createConstants(validated_config.ignore_with)\n\n const ignore = validated_config.ignore.length > 0\n\n /** @type {Map<any,any> | undefined} */\n let ignore_map\n\n /* Allows you to trimify before ignoring. */\n if (validated_config.trim.length > 0) html = trimify(html, validated_config.trim)\n\n /* Extract ignored elements. */\n if (ignore) {\n const { html_with_markers, extracted_map } = extractIgnoredBlocks(html, validated_config.ignore)\n html = html_with_markers\n ignore_map = extracted_map\n }\n\n /* Preserve html text within attribute values. */\n html = setIgnoreAttribute(html, constants)\n\n /* Insert placeholder for void elements that aren't self-closing. */\n html = setSelfClosing(html, constants)\n\n html = minifyKnownHtml(html, validated_config)\n let lines = enqueue(html, constants)\n if (validated_config.tag_wrap === 0 && validated_config.content_wrap === 0)\n lines = collapseInlineTokens(lines)\n html = process(lines, validated_config, constants)\n\n /* Revert html text within attribute values. */\n html = unsetIgnoreAttribute(html, constants)\n\n /* Re-insert ignored elements. */\n if (ignore_map) {\n html = reinsertIgnoredBlocks(html, ignore_map)\n }\n\n return html\n}\n",null,null,null,null,null],"names":[],"mappings":";;AAAA;AACA;AACA;;AAWO,MAAM,aAAa,GAAG;AAC7B,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI;AAC5C,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;AAChC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNyB,IAAI,GAAG,CAAC,aAAa;;AC0I9C;;;;;AAKG;AACI,MAAM,eAAe,GAAG,CAAC,gBAAwB,EAAE,QAA4B,KAAwB;IAC5G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;ACnGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACI,MAAM,0BAA0B,GAAG,CAAC,MAAgC,KAAU;AACnF,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAClF,IAAI,OAAQ,MAAkC,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;YACtE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5C;IACF;AACF;;ACvCA;;;;;;;AAOG;AACI,MAAM,gBAAgB,GAAG,CAAI,KAAgC,EAAE,QAAW,KAC/E,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,GAAG,QAAQ,GAAG;;;;;;;","x_google_ignoreList":[0,1]}
@@ -283,7 +283,11 @@ const componentToModule = (component) => {
283
283
  name: className,
284
284
  tagName: component.tag,
285
285
  customElement: true,
286
- description: component.overview ?? '',
286
+ // The readme carries the hand-written usage notes, which agents read from the manifest.
287
+ description: [component.overview, component.readme]
288
+ .map((text) => text?.trim())
289
+ .filter(Boolean)
290
+ .join('\n\n'),
287
291
  attributes,
288
292
  members: [...fieldMembers, ...methodMembers],
289
293
  events: component.events.map((event) => ({