@redvars/peacock 3.4.0 → 3.5.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/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/banner.js +202 -0
- package/dist/banner.js.map +1 -0
- package/dist/bottom-sheet.js +2 -2
- package/dist/{button-COYCtuA8.js → button-DMN1dPAg.js} +58 -75
- package/dist/button-DMN1dPAg.js.map +1 -0
- package/dist/{button-group-DsXquZQn.js → button-group-CX9CUUXk.js} +9 -14
- package/dist/button-group-CX9CUUXk.js.map +1 -0
- package/dist/button-group.js +8 -5
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +7 -4
- package/dist/button.js.map +1 -1
- package/dist/card.js +15 -5
- package/dist/card.js.map +1 -1
- package/dist/chart-bar.js +2 -2
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js +2 -2
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/{class-map-3TAnCMAX.js → class-map-YU7g0o3B.js} +2 -2
- package/dist/{class-map-3TAnCMAX.js.map → class-map-YU7g0o3B.js.map} +1 -1
- package/dist/clock.js.map +1 -1
- package/dist/code-editor.js +4 -4
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +3 -3
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +2918 -1379
- package/dist/custom-elements.json +2783 -1054
- package/dist/directive-ZPhl09Yt.js +9 -0
- package/dist/directive-ZPhl09Yt.js.map +1 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js +127 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js.map +1 -0
- package/dist/fab-C5Nzxk0E.js +497 -0
- package/dist/fab-C5Nzxk0E.js.map +1 -0
- package/dist/fab.js +11 -0
- package/dist/fab.js.map +1 -0
- package/dist/index.js +17 -9
- package/dist/index.js.map +1 -1
- package/dist/{observe-theme-change-DKAIv5BB.js → is-dark-mode-DicqGkCJ.js} +6 -2
- package/dist/is-dark-mode-DicqGkCJ.js.map +1 -0
- package/dist/notification.js +417 -0
- package/dist/notification.js.map +1 -0
- package/dist/number-counter.js +2 -2
- package/dist/number-counter.js.map +1 -1
- package/dist/observe-slot-change-BGJfgg2E.js +31 -0
- package/dist/observe-slot-change-BGJfgg2E.js.map +1 -0
- package/dist/peacock-loader.js +32 -9
- package/dist/peacock-loader.js.map +1 -1
- package/dist/search.js +452 -0
- package/dist/search.js.map +1 -0
- package/dist/{select-C3XAzenC.js → select-4pl4XBj7.js} +778 -374
- package/dist/select-4pl4XBj7.js.map +1 -0
- package/dist/side-sheet.js +2 -2
- package/dist/spread-B5cgadZl.js +32 -0
- package/dist/spread-B5cgadZl.js.map +1 -0
- package/dist/src/__base_element/BaseHyperlink.d.ts +20 -0
- package/dist/src/__utils/cache-fetch.d.ts +1 -0
- package/dist/src/__utils/is-dark-mode.d.ts +1 -0
- package/dist/src/__utils/is-in-viewport.d.ts +1 -0
- package/dist/src/__utils/observe-slot-change.d.ts +1 -0
- package/dist/src/__utils/sanitize-svg.d.ts +1 -0
- package/dist/src/__utils/throttle.d.ts +4 -0
- package/dist/src/accordion/accordion-item.d.ts +33 -9
- package/dist/src/accordion/accordion.d.ts +21 -5
- package/dist/src/banner/banner.d.ts +47 -0
- package/dist/src/banner/index.d.ts +1 -0
- package/dist/src/button/BaseButton.d.ts +6 -13
- package/dist/src/button/button-group/button-group.d.ts +2 -2
- package/dist/src/empty-state/empty-state.d.ts +1 -1
- package/dist/src/fab/fab.d.ts +111 -0
- package/dist/src/fab/index.d.ts +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/link/link.d.ts +3 -10
- package/dist/src/menu/menu/menu.d.ts +3 -2
- package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
- package/dist/src/notification/index.d.ts +1 -0
- package/dist/src/notification/notification.d.ts +69 -0
- package/dist/src/pagination/pagination.d.ts +8 -1
- package/dist/src/search/index.d.ts +1 -0
- package/dist/src/search/search.d.ts +76 -0
- package/dist/src/select/select.d.ts +3 -5
- package/dist/src/slider/slider.d.ts +4 -0
- package/dist/src/snackbar/snackbar.d.ts +14 -1
- package/dist/src/toolbar/index.d.ts +1 -0
- package/dist/src/toolbar/toolbar.d.ts +86 -0
- package/dist/{style-map-CRFEoCEg.js → style-map-DVmWOuYy.js} +2 -2
- package/dist/{style-map-CRFEoCEg.js.map → style-map-DVmWOuYy.js.map} +1 -1
- package/dist/test/banner.test.d.ts +1 -0
- package/dist/test/search.test.d.ts +1 -0
- package/dist/test/toolbar.test.d.ts +1 -0
- package/dist/throttle-C7ZAPqtu.js +24 -0
- package/dist/throttle-C7ZAPqtu.js.map +1 -0
- package/dist/toolbar.js +306 -0
- package/dist/toolbar.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{unsafe-html-D3GHRaGQ.js → unsafe-html-BsGUjx94.js} +2 -2
- package/dist/{unsafe-html-D3GHRaGQ.js.map → unsafe-html-BsGUjx94.js.map} +1 -1
- package/package.json +1 -1
- package/readme.md +2 -2
- package/scss/styles.scss +4 -0
- package/src/__base_element/BaseHyperlink.ts +42 -0
- package/src/__base_element/README.md +19 -0
- package/src/__utils/cache-fetch.ts +65 -0
- package/src/__utils/is-dark-mode.ts +3 -0
- package/src/__utils/is-in-viewport.ts +6 -0
- package/src/__utils/observe-slot-change.ts +38 -0
- package/src/__utils/sanitize-svg.ts +27 -0
- package/src/__utils/throttle.ts +27 -0
- package/src/accordion/accordion-item.scss +136 -65
- package/src/accordion/accordion-item.ts +117 -44
- package/src/accordion/accordion.scss +24 -5
- package/src/accordion/accordion.ts +29 -23
- package/src/accordion/demo/index.html +74 -35
- package/src/banner/banner.scss +87 -0
- package/src/banner/banner.ts +107 -0
- package/src/banner/index.ts +1 -0
- package/src/button/BaseButton.ts +14 -27
- package/src/button/button/button-colors.scss +14 -14
- package/src/button/button/button.ts +6 -5
- package/src/button/button-group/button-group.ts +3 -3
- package/src/button/icon-button/icon-button.ts +4 -11
- package/src/card/card.ts +41 -31
- package/src/chart-bar/chart-bar.ts +1 -1
- package/src/chart-bar/chart-stacked-bar.ts +3 -1
- package/src/chart-doughnut/chart-doughnut.ts +1 -1
- package/src/chart-pie/chart-pie.ts +1 -1
- package/src/checkbox/checkbox.ts +1 -1
- package/src/clock/clock.ts +1 -1
- package/src/code-editor/code-editor.ts +4 -4
- package/src/code-highlighter/code-highlighter.ts +2 -2
- package/src/date-picker/date-picker.ts +5 -2
- package/src/divider/divider.ts +3 -1
- package/src/empty-state/empty-state.scss +7 -9
- package/src/empty-state/empty-state.ts +1 -1
- package/src/fab/fab-colors.scss +49 -0
- package/src/fab/fab-sizes.scss +47 -0
- package/src/fab/fab.scss +137 -0
- package/src/fab/fab.ts +285 -0
- package/src/fab/index.ts +1 -0
- package/src/field/field.ts +3 -1
- package/src/icon/datasource.ts +1 -1
- package/src/icon/icon.ts +3 -1
- package/src/image/image.ts +3 -2
- package/src/index.ts +5 -0
- package/src/input/input.ts +5 -2
- package/src/link/link.ts +2 -15
- package/src/menu/menu/menu.scss +7 -0
- package/src/menu/menu/menu.ts +7 -4
- package/src/menu/sub-menu/sub-menu.ts +1 -0
- package/src/notification/index.ts +1 -0
- package/src/notification/notification.scss +201 -0
- package/src/notification/notification.ts +206 -0
- package/src/number-counter/number-counter.ts +3 -1
- package/src/number-field/number-field.ts +4 -2
- package/src/pagination/pagination.scss +33 -24
- package/src/pagination/pagination.ts +113 -60
- package/src/peacock-loader.ts +20 -0
- package/src/radio/radio.ts +3 -1
- package/src/search/index.ts +1 -0
- package/src/search/search-colors.scss +14 -0
- package/src/search/search.scss +204 -0
- package/src/search/search.ts +240 -0
- package/src/select/option.ts +1 -1
- package/src/select/select.scss +5 -0
- package/src/select/select.ts +71 -37
- package/src/slider/slider.scss +19 -0
- package/src/slider/slider.ts +30 -19
- package/src/snackbar/snackbar.scss +62 -31
- package/src/snackbar/snackbar.ts +92 -12
- package/src/switch/switch.ts +3 -1
- package/src/table/table.ts +3 -1
- package/src/tabs/tab.ts +6 -3
- package/src/textarea/textarea.ts +4 -2
- package/src/time-picker/time-picker.ts +4 -2
- package/src/toolbar/index.ts +1 -0
- package/src/toolbar/toolbar-colors.scss +16 -0
- package/src/toolbar/toolbar.scss +165 -0
- package/src/toolbar/toolbar.ts +137 -0
- package/dist/button-COYCtuA8.js.map +0 -1
- package/dist/button-group-DsXquZQn.js.map +0 -1
- package/dist/directive-Cuw6h7YA.js +0 -9
- package/dist/directive-Cuw6h7YA.js.map +0 -1
- package/dist/dispatch-event-utils-B4odODQf.js +0 -277
- package/dist/dispatch-event-utils-B4odODQf.js.map +0 -1
- package/dist/observe-theme-change-DKAIv5BB.js.map +0 -1
- package/dist/select-C3XAzenC.js.map +0 -1
- package/dist/src/styleMixins.css.d.ts +0 -9
- package/dist/src/utils.d.ts +0 -9
- package/src/styleMixins.css.ts +0 -55
- package/src/utils.ts +0 -193
- /package/dist/src/{spread.d.ts → __directive/spread.d.ts} +0 -0
- /package/dist/src/{utils → __utils}/copy-to-clipboard.d.ts +0 -0
- /package/dist/src/{utils → __utils}/dispatch-event-utils.d.ts +0 -0
- /package/dist/src/{utils → __utils}/observe-theme-change.d.ts +0 -0
- /package/src/{spread.ts → __directive/spread.ts} +0 -0
- /package/src/{utils → __utils}/copy-to-clipboard.ts +0 -0
- /package/src/{utils → __utils}/dispatch-event-utils.ts +0 -0
- /package/src/{utils → __utils}/observe-theme-change.ts +0 -0
package/dist/fab.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import './IndividualComponent-DUINtMGK.js';
|
|
2
|
+
import './property-1psGvXOq.js';
|
|
3
|
+
import './state-DwbEjqVk.js';
|
|
4
|
+
import './query-QBcUV-L_.js';
|
|
5
|
+
import './class-map-YU7g0o3B.js';
|
|
6
|
+
export { F as Fab } from './fab-C5Nzxk0E.js';
|
|
7
|
+
import './dispatch-event-utils-CuEqjlPT.js';
|
|
8
|
+
import './throttle-C7ZAPqtu.js';
|
|
9
|
+
import './spread-B5cgadZl.js';
|
|
10
|
+
import './directive-ZPhl09Yt.js';
|
|
11
|
+
//# sourceMappingURL=fab.js.map
|
package/dist/fab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fab.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { A as Accordion, a as Avatar, B as Badge, b as Breadcrumb, c as BreadcrumbItem, C as Checkbox, d as Chip, e as CircularProgress, f as Container, D as DatePicker, g as Divider, E as Elevation, h as EmptyState, F as Field, i as FocusRing, I as Icon, j as Image, k as Input, L as LinearProgress, l as Link, M as Menu, m as MenuItem, N as NumberField, P as Pagination, R as Radio, n as Ripple, S as SegmentedButton, o as SegmentedButtonGroup, p as Select, q as SelectOptionElement, r as Skeleton, s as Slider, t as Snackbar, u as Spinner, v as SubMenu, w as Switch, T as Tab, x as TabGroup, y as TabPanel, z as Table, G as Tabs, H as Tag, J as Textarea, K as TimePicker, O as Tooltip, Q as TreeNode, U as TreeView } from './select-
|
|
1
|
+
export { A as Accordion, a as Avatar, B as Badge, b as Breadcrumb, c as BreadcrumbItem, C as Checkbox, d as Chip, e as CircularProgress, f as Container, D as DatePicker, g as Divider, E as Elevation, h as EmptyState, F as Field, i as FocusRing, I as Icon, j as Image, k as Input, L as LinearProgress, l as Link, M as Menu, m as MenuItem, N as NumberField, P as Pagination, R as Radio, n as Ripple, S as SegmentedButton, o as SegmentedButtonGroup, p as Select, q as SelectOptionElement, r as Skeleton, s as Slider, t as Snackbar, u as Spinner, v as SubMenu, w as Switch, T as Tab, x as TabGroup, y as TabPanel, z as Table, G as Tabs, H as Tag, J as Textarea, K as TimePicker, O as Tooltip, Q as TreeNode, U as TreeView } from './select-4pl4XBj7.js';
|
|
2
2
|
export { Clock } from './clock.js';
|
|
3
|
-
export { B as Button } from './button-
|
|
4
|
-
export { B as ButtonGroup, I as IconButton } from './button-group-
|
|
3
|
+
export { B as Button } from './button-DMN1dPAg.js';
|
|
4
|
+
export { B as ButtonGroup, I as IconButton } from './button-group-CX9CUUXk.js';
|
|
5
|
+
export { F as Fab } from './fab-C5Nzxk0E.js';
|
|
5
6
|
export { NumberCounter } from './number-counter.js';
|
|
6
7
|
export { CodeHighlighter } from './code-highlighter.js';
|
|
7
8
|
export { default as CodeEditor } from './code-editor.js';
|
|
@@ -11,18 +12,25 @@ export { ChartBar } from './chart-bar.js';
|
|
|
11
12
|
export { ChartStackedBar } from './chart-stacked-bar.js';
|
|
12
13
|
export { Card } from './card.js';
|
|
13
14
|
import './card-content.js';
|
|
15
|
+
export { Banner } from './banner.js';
|
|
16
|
+
export { Notification } from './notification.js';
|
|
14
17
|
export { BottomSheet } from './bottom-sheet.js';
|
|
15
18
|
export { SideSheet } from './side-sheet.js';
|
|
19
|
+
export { Search } from './search.js';
|
|
20
|
+
export { Toolbar } from './toolbar.js';
|
|
16
21
|
import './IndividualComponent-DUINtMGK.js';
|
|
17
22
|
import './property-1psGvXOq.js';
|
|
18
23
|
import './state-DwbEjqVk.js';
|
|
19
|
-
import './directive-
|
|
20
|
-
import './unsafe-html-
|
|
21
|
-
import './
|
|
22
|
-
import './
|
|
24
|
+
import './directive-ZPhl09Yt.js';
|
|
25
|
+
import './unsafe-html-BsGUjx94.js';
|
|
26
|
+
import './class-map-YU7g0o3B.js';
|
|
27
|
+
import './observe-slot-change-BGJfgg2E.js';
|
|
23
28
|
import './query-QBcUV-L_.js';
|
|
24
|
-
import './style-map-
|
|
25
|
-
import './
|
|
29
|
+
import './style-map-DVmWOuYy.js';
|
|
30
|
+
import './dispatch-event-utils-CuEqjlPT.js';
|
|
31
|
+
import './spread-B5cgadZl.js';
|
|
32
|
+
import './is-dark-mode-DicqGkCJ.js';
|
|
33
|
+
import './throttle-C7ZAPqtu.js';
|
|
26
34
|
import './transform-DSwFSqzD.js';
|
|
27
35
|
import './pie-Dz0IDiPt.js';
|
|
28
36
|
import './array-D5vjT2Xm.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -48,5 +48,9 @@ const observeThemeChange = (() => {
|
|
|
48
48
|
};
|
|
49
49
|
})();
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
function isDarkMode() {
|
|
52
|
+
return document.documentElement.dataset.theme === 'dark';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { BaseInput as B, isDarkMode as i, observeThemeChange as o };
|
|
56
|
+
//# sourceMappingURL=is-dark-mode-DicqGkCJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-dark-mode-DicqGkCJ.js","sources":["../../src/input/BaseInput.ts","../../src/__utils/observe-theme-change.ts","../../src/__utils/is-dark-mode.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nexport default abstract class BaseInput extends LitElement {\n value?: any;\n\n @property({ type: Boolean, reflect: true })\n disabled: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n required: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n skeleton = false;\n}\n","type ThemeChangeCallback = () => void;\n\nexport const observeThemeChange = (() => {\n const callbacks = new Set<ThemeChangeCallback>();\n\n const observer = new MutationObserver((records) => {\n const changed = records.some(\n (r) => r.type === \"attributes\" && r.attributeName === \"data-theme\"\n );\n if (!changed) return;\n\n for (const callback of callbacks) {\n try {\n callback();\n } catch (err) {\n console.error(\"[observeThemeChange] callback threw:\", err);\n }\n }\n });\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"data-theme\"],\n });\n\n return (callback: ThemeChangeCallback): (() => void) => {\n callbacks.add(callback);\n return () => callbacks.delete(callback);\n };\n})();","export function isDarkMode() {\n return document.documentElement.dataset.theme === 'dark';\n}"],"names":["LitElement","property"],"mappings":";;;AAGc,MAAgB,SAAU,SAAQA,CAAU,CAAA;AAA1D,IAAA,WAAA,GAAA;;QAIE,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGzB,IAAA,CAAA,QAAQ,GAAG,KAAK;IAClB;AAAC;AAVC,UAAA,CAAA;IADCC,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;;ACdZ,MAAM,kBAAkB,GAAG,CAAC,MAAK;AACtC,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuB;IAEhD,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,CAAC,OAAO,KAAI;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY,CACnE;AACD,QAAA,IAAI,CAAC,OAAO;YAAE;AAEd,QAAA,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;AAChC,YAAA,IAAI;AACF,gBAAA,QAAQ,EAAE;YACZ;YAAE,OAAO,GAAG,EAAE;AACZ,gBAAA,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,GAAG,CAAC;YAC5D;QACF;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE;AACzC,QAAA,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,CAAC,YAAY,CAAC;AAChC,KAAA,CAAC;IAEF,OAAO,CAAC,QAA6B,KAAkB;AACrD,QAAA,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;QACvB,OAAO,MAAM,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;AACzC,IAAA,CAAC;AACH,CAAC;;SC7Be,UAAU,GAAA;IACxB,OAAO,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM;AAC1D;;;;"}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { a as i, _ as __decorate, I as IndividualComponent, i as i$1, A, b } from './IndividualComponent-DUINtMGK.js';
|
|
2
|
+
import { n } from './property-1psGvXOq.js';
|
|
3
|
+
import { r } from './state-DwbEjqVk.js';
|
|
4
|
+
import { e } from './class-map-YU7g0o3B.js';
|
|
5
|
+
import './directive-ZPhl09Yt.js';
|
|
6
|
+
|
|
7
|
+
var css_248z = i`* {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.screen-reader-only {
|
|
12
|
+
display: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host {
|
|
16
|
+
--notification-container-color: var(--color-primary-container);
|
|
17
|
+
--notification-text-color: var(--color-on-primary-container);
|
|
18
|
+
--notification-leading-icon-color: var(--color-on-primary-container);
|
|
19
|
+
--notification-accent-color: var(--color-primary);
|
|
20
|
+
--notification-border-radius: var(--shape-corner-medium);
|
|
21
|
+
display: block;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host(:not([inline])) {
|
|
25
|
+
width: min(100%, 28rem);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.notification {
|
|
29
|
+
align-items: flex-start;
|
|
30
|
+
background: var(--notification-container-color);
|
|
31
|
+
border-inline-start: 4px solid var(--notification-accent-color);
|
|
32
|
+
border-radius: var(--notification-border-radius);
|
|
33
|
+
color: var(--notification-text-color);
|
|
34
|
+
display: grid;
|
|
35
|
+
gap: var(--spacing-100);
|
|
36
|
+
grid-template-columns: auto 1fr auto;
|
|
37
|
+
padding: var(--spacing-150) var(--spacing-100) var(--spacing-150) var(--spacing-150);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.state-icon {
|
|
41
|
+
align-items: center;
|
|
42
|
+
color: var(--notification-leading-icon-color);
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
min-height: 2rem;
|
|
46
|
+
--icon-size: 1.25rem;
|
|
47
|
+
--icon-color: var(--notification-leading-icon-color);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.content {
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
gap: var(--spacing-100);
|
|
54
|
+
min-width: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.content-text {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: var(--spacing-025);
|
|
61
|
+
min-width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.title {
|
|
65
|
+
font-family: var(--typography-label-large-font-family) !important;
|
|
66
|
+
font-size: var(--typography-label-large-font-size) !important;
|
|
67
|
+
font-weight: var(--typography-label-large-font-weight) !important;
|
|
68
|
+
line-height: var(--typography-label-large-line-height) !important;
|
|
69
|
+
letter-spacing: var(--typography-label-large-letter-spacing) !important;
|
|
70
|
+
color: var(--notification-text-color);
|
|
71
|
+
overflow-wrap: anywhere;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.subtitle {
|
|
75
|
+
font-family: var(--typography-body-medium-font-family) !important;
|
|
76
|
+
font-size: var(--typography-body-medium-font-size) !important;
|
|
77
|
+
font-weight: var(--typography-body-medium-font-weight) !important;
|
|
78
|
+
line-height: var(--typography-body-medium-line-height) !important;
|
|
79
|
+
letter-spacing: var(--typography-body-medium-letter-spacing) !important;
|
|
80
|
+
color: var(--notification-text-color);
|
|
81
|
+
opacity: 0.88;
|
|
82
|
+
overflow-wrap: anywhere;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.title ::slotted(*),
|
|
86
|
+
.subtitle ::slotted(*) {
|
|
87
|
+
margin: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.actions {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
gap: var(--spacing-100);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.action {
|
|
96
|
+
--outlined-button-label-text-color: var(--notification-text-color);
|
|
97
|
+
--outlined-button-outline-color: color-mix(in srgb, var(--notification-text-color) 40%, transparent);
|
|
98
|
+
--text-button-label-text-color: var(--notification-text-color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.close-button-container {
|
|
102
|
+
display: inline-flex;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.close-button {
|
|
106
|
+
--text-button-label-text-color: var(--notification-text-color);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.notification.inline {
|
|
110
|
+
align-items: center;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.notification.inline .content {
|
|
114
|
+
align-items: center;
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: row;
|
|
117
|
+
gap: var(--spacing-150);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.notification.inline .content-text {
|
|
121
|
+
display: inline;
|
|
122
|
+
flex: 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.notification.inline .title,
|
|
126
|
+
.notification.inline .subtitle,
|
|
127
|
+
.notification.inline .title ::slotted(*),
|
|
128
|
+
.notification.inline .subtitle ::slotted(*) {
|
|
129
|
+
display: inline;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.notification:not(.has-subtitle) {
|
|
133
|
+
align-items: center;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.notification:not(.has-subtitle) .content {
|
|
137
|
+
gap: 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.notification.variant-info {
|
|
141
|
+
--notification-container-color: var(--color-primary-container);
|
|
142
|
+
--notification-text-color: var(--color-on-primary-container);
|
|
143
|
+
--notification-leading-icon-color: var(--color-on-primary-container);
|
|
144
|
+
--notification-accent-color: var(--color-primary);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.notification.variant-success {
|
|
148
|
+
--notification-container-color: var(--color-success-container);
|
|
149
|
+
--notification-text-color: var(--color-on-success-container);
|
|
150
|
+
--notification-leading-icon-color: var(--color-on-success-container);
|
|
151
|
+
--notification-accent-color: var(--color-success);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.notification.variant-warning {
|
|
155
|
+
--notification-container-color: var(--color-warning-container);
|
|
156
|
+
--notification-text-color: var(--color-on-warning-container);
|
|
157
|
+
--notification-leading-icon-color: var(--color-on-warning-container);
|
|
158
|
+
--notification-accent-color: var(--color-warning);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.notification.variant-error {
|
|
162
|
+
--notification-container-color: var(--color-error-container);
|
|
163
|
+
--notification-text-color: var(--color-on-error-container);
|
|
164
|
+
--notification-leading-icon-color: var(--color-on-error-container);
|
|
165
|
+
--notification-accent-color: var(--color-error);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.notification.high-contrast {
|
|
169
|
+
--notification-container-color: var(--color-inverse-surface);
|
|
170
|
+
--notification-text-color: var(--color-inverse-on-surface);
|
|
171
|
+
--notification-leading-icon-color: var(--color-inverse-on-surface);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.notification.high-contrast.variant-info {
|
|
175
|
+
--notification-accent-color: var(--color-primary);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.notification.high-contrast.variant-success {
|
|
179
|
+
--notification-accent-color: var(--color-success);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.notification.high-contrast.variant-warning {
|
|
183
|
+
--notification-accent-color: var(--color-warning);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.notification.high-contrast.variant-error {
|
|
187
|
+
--notification-accent-color: var(--color-error);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@media (max-width: 640px) {
|
|
191
|
+
:host(:not([inline])) {
|
|
192
|
+
width: 100%;
|
|
193
|
+
}
|
|
194
|
+
.notification.inline {
|
|
195
|
+
align-items: flex-start;
|
|
196
|
+
}
|
|
197
|
+
.notification.inline .content {
|
|
198
|
+
align-items: flex-start;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: var(--spacing-100);
|
|
201
|
+
}
|
|
202
|
+
.notification.inline .content-text {
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
gap: var(--spacing-025);
|
|
206
|
+
}
|
|
207
|
+
.notification.inline .title,
|
|
208
|
+
.notification.inline .subtitle,
|
|
209
|
+
.notification.inline .title ::slotted(*),
|
|
210
|
+
.notification.inline .subtitle ::slotted(*) {
|
|
211
|
+
display: initial;
|
|
212
|
+
}
|
|
213
|
+
}`;
|
|
214
|
+
|
|
215
|
+
const VARIANT_LABELS = {
|
|
216
|
+
success: 'Success',
|
|
217
|
+
error: 'Error',
|
|
218
|
+
info: 'Information',
|
|
219
|
+
warning: 'Warning',
|
|
220
|
+
};
|
|
221
|
+
const VARIANT_ICONS = {
|
|
222
|
+
success: 'check_circle',
|
|
223
|
+
error: 'error',
|
|
224
|
+
info: 'info',
|
|
225
|
+
warning: 'warning',
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* @label Notification
|
|
229
|
+
* @tag wc-notification
|
|
230
|
+
* @rawTag notification
|
|
231
|
+
* @summary Notifications communicate contextual status, errors, warnings, and success messages.
|
|
232
|
+
*
|
|
233
|
+
* @cssprop --notification-container-color - Surface color for the notification container.
|
|
234
|
+
* @cssprop --notification-text-color - Label and supporting text color.
|
|
235
|
+
* @cssprop --notification-leading-icon-color - Leading state icon color.
|
|
236
|
+
* @cssprop --notification-accent-color - Start border color for status emphasis.
|
|
237
|
+
* @cssprop --notification-border-radius - Border radius of the notification container.
|
|
238
|
+
*
|
|
239
|
+
* @fires {CustomEvent} notification-dismiss - Fired when the notification is dismissed.
|
|
240
|
+
* @fires {CustomEvent} notification-action-click - Fired when the action button is clicked.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```html
|
|
244
|
+
* <wc-notification variant="success" action="Undo" dismissible>
|
|
245
|
+
* <span slot="title">Record saved</span>
|
|
246
|
+
* </wc-notification>
|
|
247
|
+
* ```
|
|
248
|
+
* @tags display, feedback
|
|
249
|
+
*/
|
|
250
|
+
let Notification = class Notification extends i$1 {
|
|
251
|
+
constructor() {
|
|
252
|
+
super(...arguments);
|
|
253
|
+
/**
|
|
254
|
+
* If true, content and actions are laid out in a single row.
|
|
255
|
+
*/
|
|
256
|
+
this.inline = false;
|
|
257
|
+
/**
|
|
258
|
+
* The visual variant of the notification.
|
|
259
|
+
*/
|
|
260
|
+
this.variant = 'info';
|
|
261
|
+
/**
|
|
262
|
+
* Enables a high contrast appearance.
|
|
263
|
+
*/
|
|
264
|
+
this.highContrast = false;
|
|
265
|
+
/**
|
|
266
|
+
* If true, renders a dismiss icon button.
|
|
267
|
+
*/
|
|
268
|
+
this.dismissible = false;
|
|
269
|
+
/**
|
|
270
|
+
* Action label text. When provided, an action button is shown.
|
|
271
|
+
*/
|
|
272
|
+
this.action = '';
|
|
273
|
+
/**
|
|
274
|
+
* If true, the host controls visibility when dismissed.
|
|
275
|
+
*/
|
|
276
|
+
this.managed = false;
|
|
277
|
+
this.isHidden = false;
|
|
278
|
+
this.hasSubtitle = false;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Programmatically reveals the notification.
|
|
282
|
+
*/
|
|
283
|
+
show() {
|
|
284
|
+
this.isHidden = false;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Programmatically dismisses the notification.
|
|
288
|
+
*/
|
|
289
|
+
dismiss() {
|
|
290
|
+
this.hideAndEmitDismiss('programmatic');
|
|
291
|
+
}
|
|
292
|
+
get variantIcon() {
|
|
293
|
+
return VARIANT_ICONS[this.variant];
|
|
294
|
+
}
|
|
295
|
+
get variantLabel() {
|
|
296
|
+
return VARIANT_LABELS[this.variant];
|
|
297
|
+
}
|
|
298
|
+
emitActionClick() {
|
|
299
|
+
this.dispatchEvent(new CustomEvent('notification-action-click', {
|
|
300
|
+
bubbles: true,
|
|
301
|
+
composed: true,
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
hideAndEmitDismiss(reason) {
|
|
305
|
+
if (!this.managed) {
|
|
306
|
+
this.isHidden = true;
|
|
307
|
+
}
|
|
308
|
+
this.dispatchEvent(new CustomEvent('notification-dismiss', {
|
|
309
|
+
detail: { reason },
|
|
310
|
+
bubbles: true,
|
|
311
|
+
composed: true,
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
handleSubtitleSlotChange(event) {
|
|
315
|
+
const slot = event.target;
|
|
316
|
+
this.hasSubtitle = slot
|
|
317
|
+
.assignedNodes({ flatten: true })
|
|
318
|
+
.some(node => node.textContent?.trim());
|
|
319
|
+
}
|
|
320
|
+
render() {
|
|
321
|
+
if (this.isHidden) {
|
|
322
|
+
return A;
|
|
323
|
+
}
|
|
324
|
+
return b `
|
|
325
|
+
<div
|
|
326
|
+
class=${e({
|
|
327
|
+
notification: true,
|
|
328
|
+
inline: this.inline,
|
|
329
|
+
'high-contrast': this.highContrast,
|
|
330
|
+
'has-subtitle': this.hasSubtitle,
|
|
331
|
+
[`variant-${this.variant}`]: true,
|
|
332
|
+
})}
|
|
333
|
+
role="alert"
|
|
334
|
+
aria-live="polite"
|
|
335
|
+
aria-label=${this.variantLabel}
|
|
336
|
+
>
|
|
337
|
+
<div class="state-icon" aria-hidden="true">
|
|
338
|
+
<slot name="icon">
|
|
339
|
+
<wc-icon name=${this.variantIcon}></wc-icon>
|
|
340
|
+
</slot>
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
<div class="content">
|
|
344
|
+
<div class="content-text">
|
|
345
|
+
<div class="title">
|
|
346
|
+
<slot name="title"></slot>
|
|
347
|
+
<slot></slot>
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
<div class="subtitle">
|
|
351
|
+
<slot name="subtitle" @slotchange=${this.handleSubtitleSlotChange}></slot>
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
|
|
355
|
+
${this.action
|
|
356
|
+
? b `<div class="actions">
|
|
357
|
+
<wc-button
|
|
358
|
+
class="action"
|
|
359
|
+
size="sm"
|
|
360
|
+
variant=${this.inline ? 'text' : 'outlined'}
|
|
361
|
+
@click=${this.emitActionClick}
|
|
362
|
+
>
|
|
363
|
+
${this.action}
|
|
364
|
+
</wc-button>
|
|
365
|
+
</div>`
|
|
366
|
+
: A}
|
|
367
|
+
</div>
|
|
368
|
+
|
|
369
|
+
${this.dismissible
|
|
370
|
+
? b `<div class="close-button-container">
|
|
371
|
+
<wc-icon-button
|
|
372
|
+
class="close-button"
|
|
373
|
+
variant="text"
|
|
374
|
+
size="sm"
|
|
375
|
+
aria-label="Close notification"
|
|
376
|
+
name="close"
|
|
377
|
+
@click=${() => {
|
|
378
|
+
this.hideAndEmitDismiss('dismiss');
|
|
379
|
+
}}
|
|
380
|
+
></wc-icon-button>
|
|
381
|
+
</div>`
|
|
382
|
+
: A}
|
|
383
|
+
</div>
|
|
384
|
+
`;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
Notification.styles = [css_248z];
|
|
388
|
+
__decorate([
|
|
389
|
+
n({ type: Boolean, reflect: true })
|
|
390
|
+
], Notification.prototype, "inline", void 0);
|
|
391
|
+
__decorate([
|
|
392
|
+
n({ type: String, reflect: true })
|
|
393
|
+
], Notification.prototype, "variant", void 0);
|
|
394
|
+
__decorate([
|
|
395
|
+
n({ type: Boolean, reflect: true, attribute: 'high-contrast' })
|
|
396
|
+
], Notification.prototype, "highContrast", void 0);
|
|
397
|
+
__decorate([
|
|
398
|
+
n({ type: Boolean, reflect: true })
|
|
399
|
+
], Notification.prototype, "dismissible", void 0);
|
|
400
|
+
__decorate([
|
|
401
|
+
n({ type: String })
|
|
402
|
+
], Notification.prototype, "action", void 0);
|
|
403
|
+
__decorate([
|
|
404
|
+
n({ type: Boolean, reflect: true })
|
|
405
|
+
], Notification.prototype, "managed", void 0);
|
|
406
|
+
__decorate([
|
|
407
|
+
r()
|
|
408
|
+
], Notification.prototype, "isHidden", void 0);
|
|
409
|
+
__decorate([
|
|
410
|
+
r()
|
|
411
|
+
], Notification.prototype, "hasSubtitle", void 0);
|
|
412
|
+
Notification = __decorate([
|
|
413
|
+
IndividualComponent
|
|
414
|
+
], Notification);
|
|
415
|
+
|
|
416
|
+
export { Notification };
|
|
417
|
+
//# sourceMappingURL=notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.js","sources":["../../src/notification/notification.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './notification.scss';\n\ntype NotificationVariant = 'success' | 'error' | 'info' | 'warning';\n\nconst VARIANT_LABELS: Record<NotificationVariant, string> = {\n success: 'Success',\n error: 'Error',\n info: 'Information',\n warning: 'Warning',\n};\n\nconst VARIANT_ICONS: Record<NotificationVariant, string> = {\n success: 'check_circle',\n error: 'error',\n info: 'info',\n warning: 'warning',\n};\n\n/**\n * @label Notification\n * @tag wc-notification\n * @rawTag notification\n * @summary Notifications communicate contextual status, errors, warnings, and success messages.\n *\n * @cssprop --notification-container-color - Surface color for the notification container.\n * @cssprop --notification-text-color - Label and supporting text color.\n * @cssprop --notification-leading-icon-color - Leading state icon color.\n * @cssprop --notification-accent-color - Start border color for status emphasis.\n * @cssprop --notification-border-radius - Border radius of the notification container.\n *\n * @fires {CustomEvent} notification-dismiss - Fired when the notification is dismissed.\n * @fires {CustomEvent} notification-action-click - Fired when the action button is clicked.\n *\n * @example\n * ```html\n * <wc-notification variant=\"success\" action=\"Undo\" dismissible>\n * <span slot=\"title\">Record saved</span>\n * </wc-notification>\n * ```\n * @tags display, feedback\n */\n@IndividualComponent\nexport class Notification extends LitElement {\n static styles = [styles];\n\n /**\n * If true, content and actions are laid out in a single row.\n */\n @property({ type: Boolean, reflect: true }) inline = false;\n\n /**\n * The visual variant of the notification.\n */\n @property({ type: String, reflect: true })\n variant: NotificationVariant = 'info';\n\n /**\n * Enables a high contrast appearance.\n */\n @property({ type: Boolean, reflect: true, attribute: 'high-contrast' })\n highContrast = false;\n\n /**\n * If true, renders a dismiss icon button.\n */\n @property({ type: Boolean, reflect: true }) dismissible = false;\n\n /**\n * Action label text. When provided, an action button is shown.\n */\n @property({ type: String }) action = '';\n\n /**\n * If true, the host controls visibility when dismissed.\n */\n @property({ type: Boolean, reflect: true }) managed = false;\n\n @state() private isHidden = false;\n \n @state() private hasSubtitle = false;\n\n /**\n * Programmatically reveals the notification.\n */\n show() {\n this.isHidden = false;\n }\n\n /**\n * Programmatically dismisses the notification.\n */\n dismiss() {\n this.hideAndEmitDismiss('programmatic');\n }\n\n private get variantIcon() {\n return VARIANT_ICONS[this.variant];\n }\n\n private get variantLabel() {\n return VARIANT_LABELS[this.variant];\n }\n\n private emitActionClick() {\n this.dispatchEvent(\n new CustomEvent('notification-action-click', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private hideAndEmitDismiss(reason: 'dismiss' | 'programmatic') {\n if (!this.managed) {\n this.isHidden = true;\n }\n\n this.dispatchEvent(\n new CustomEvent('notification-dismiss', {\n detail: { reason },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleSubtitleSlotChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasSubtitle = slot\n .assignedNodes({ flatten: true })\n .some(node => node.textContent?.trim());\n }\n\n render() {\n if (this.isHidden) {\n return nothing;\n }\n\n return html`\n <div\n class=${classMap({\n notification: true,\n inline: this.inline,\n 'high-contrast': this.highContrast,\n 'has-subtitle': this.hasSubtitle,\n [`variant-${this.variant}`]: true,\n })}\n role=\"alert\"\n aria-live=\"polite\"\n aria-label=${this.variantLabel}\n >\n <div class=\"state-icon\" aria-hidden=\"true\">\n <slot name=\"icon\">\n <wc-icon name=${this.variantIcon}></wc-icon>\n </slot>\n </div>\n\n <div class=\"content\">\n <div class=\"content-text\">\n <div class=\"title\">\n <slot name=\"title\"></slot>\n <slot></slot>\n </div>\n\n <div class=\"subtitle\">\n <slot name=\"subtitle\" @slotchange=${this.handleSubtitleSlotChange}></slot>\n </div>\n </div>\n\n ${this.action\n ? html`<div class=\"actions\">\n <wc-button\n class=\"action\"\n size=\"sm\"\n variant=${this.inline ? 'text' : 'outlined'}\n @click=${this.emitActionClick}\n >\n ${this.action}\n </wc-button>\n </div>`\n : nothing}\n </div>\n\n ${this.dismissible\n ? html`<div class=\"close-button-container\">\n <wc-icon-button\n class=\"close-button\"\n variant=\"text\"\n size=\"sm\"\n aria-label=\"Close notification\"\n name=\"close\"\n @click=${() => {\n this.hideAndEmitDismiss('dismiss');\n }}\n ></wc-icon-button>\n </div>`\n : nothing}\n </div>\n `;\n }\n}\n"],"names":["LitElement","nothing","html","classMap","sty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,CAAA;IAA3CA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAAsB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAKpC,UAAA,CAAA;AAA3B,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AAAc,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAKI,UAAA,CAAA;IAA3CA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAAkB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAE3C,UAAA,CAAA;AAAhB,IAAAC,CAAK;AAA4B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAEjB,UAAA,CAAA;AAAhB,IAAAA,CAAK;AAA+B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AArC1B,YAAY,GAAA,UAAA,CAAA;IADxB;AACY,CAAA,EAAA,YAAY,CA8JxB;;;;"}
|
package/dist/number-counter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as i, _ as __decorate, I as IndividualComponent, i as i$1, b, A } from './IndividualComponent-DUINtMGK.js';
|
|
2
2
|
import { n } from './property-1psGvXOq.js';
|
|
3
|
-
import { o } from './style-map-
|
|
4
|
-
import './directive-
|
|
3
|
+
import { o } from './style-map-DVmWOuYy.js';
|
|
4
|
+
import './directive-ZPhl09Yt.js';
|
|
5
5
|
|
|
6
6
|
var css_248z = i`* {
|
|
7
7
|
box-sizing: border-box;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-counter.js","sources":["../../src/number-counter/number-counter.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport IndividualComponent from '
|
|
1
|
+
{"version":3,"file":"number-counter.js","sources":["../../src/number-counter/number-counter.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nimport IndividualComponent from '@/IndividualComponent.js';\n\nimport styles from './number-counter.scss';\n\n/**\n * @label Number Counter\n * @tag wc-number-counter\n * @rawTag number-counter\n * @summary Displays a number with commas for thousands.\n *\n * @example\n * ```html\n * <wc-number-counter id=\"number-counter\" value=\"123456789\"></wc-number-counter>\n * <script>\n * customElements.whenDefined('wc-number-counter').then(() => {\n const $counter = document.querySelector('#number-counter');\n\n setInterval(() => {\n $counter.value = $counter.value + Math.floor(Math.random() * 1000);\n }, 1000);\n });\n * </script>\n * ```\n * @tags display\n */\n@IndividualComponent\nexport class NumberCounter extends LitElement {\n static styles = [styles];\n\n @property({ type: Number }) value = 0;\n\n /**\n * Optional: Allow users to pass a locale, defaulting to 'en-US' for commas.\n */\n @property() locale = 'en-US';\n\n render() {\n return html`<div class=\"number-counter\">${this.renderDigits()}</div>`;\n }\n\n renderDigits() {\n if (this.value === undefined || this.value === null) return nothing;\n\n // 1. Format the number with commas (e.g., 1234 -> \"1,234\")\n const formattedValue = new Intl.NumberFormat(this.locale).format(\n this.value,\n );\n\n // 2. Split the string into individual characters\n const chars = formattedValue.split('');\n\n return html`${chars.map(char => {\n // 3. Check if the character is a digit or a separator (comma/dot)\n const digit = parseInt(char, 10);\n\n // eslint-disable-next-line no-restricted-globals\n if (isNaN(digit)) {\n return html`<div class=\"digit-separator\">${char}</div>`;\n }\n\n return this.renderDigit(digit);\n })}`;\n }\n\n // eslint-disable-next-line class-methods-use-this\n renderDigit(digit: number) {\n // Each 'each-digit' is 10% of the 'digit-content' height (since there are 10 numbers)\n const offset = digit * 10;\n const style = {\n transform: `translateY(-${offset}%)`,\n };\n\n return html` <div class=\"digit\">\n <div class=\"digit-content\" style=${styleMap(style)}>\n ${[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(\n n => html`<div class=\"each-digit\">${n}</div>`,\n )}\n </div>\n </div>`;\n }\n}\n"],"names":["LitElement","html","nothing","styleMap","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;;;;;AAoBG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQA,GAAU,CAAA;AAAtC,IAAA,WAAA,GAAA;;QAGuB,IAAA,CAAA,KAAK,GAAG,CAAC;AAErC;;AAEG;QACS,IAAA,CAAA,MAAM,GAAG,OAAO;IA8C9B;IA5CE,MAAM,GAAA;QACJ,OAAOC,CAAI,CAAA,CAAA,4BAAA,EAA+B,IAAI,CAAC,YAAY,EAAE,QAAQ;IACvE;IAEA,YAAY,GAAA;QACV,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI;AAAE,YAAA,OAAOC,CAAO;;AAGnE,QAAA,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAC9D,IAAI,CAAC,KAAK,CACX;;QAGD,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAEtC,OAAOD,CAAI,CAAA,CAAA,EAAG,KAAK,CAAC,GAAG,CAAC,IAAI,IAAG;;YAE7B,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;;AAGhC,YAAA,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;AAChB,gBAAA,OAAOA,CAAI,CAAA,CAAA,6BAAA,EAAgC,IAAI,QAAQ;YACzD;AAEA,YAAA,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAChC,CAAC,CAAC,EAAE;IACN;;AAGA,IAAA,WAAW,CAAC,KAAa,EAAA;;AAEvB,QAAA,MAAM,MAAM,GAAG,KAAK,GAAG,EAAE;AACzB,QAAA,MAAM,KAAK,GAAG;YACZ,SAAS,EAAE,CAAA,YAAA,EAAe,MAAM,CAAA,EAAA,CAAI;SACrC;AAED,QAAA,OAAOA,CAAI,CAAA,CAAA;yCAC0BE,CAAQ,CAAC,KAAK,CAAC,CAAA;AAC9C,QAAA,EAAA,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAClC,CAAC,IAAIF,CAAI,CAAA,CAAA,wBAAA,EAA2B,CAAC,QAAQ,CAC9C;;WAEE;IACT;;AApDO,aAAA,CAAA,MAAM,GAAG,CAACG,QAAM,CAAC;AAEI,UAAA,CAAA;AAA3B,IAAAC,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AAAY,CAAA,EAAA,aAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAK1B,UAAA,CAAA;AAAX,IAAAA,CAAQ;AAAoB,CAAA,EAAA,aAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AARlB,aAAa,GAAA,UAAA,CAAA;IADzB;AACY,CAAA,EAAA,aAAa,CAsDzB;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function hasMeaningfulContent(slotElement) {
|
|
2
|
+
const nodes = slotElement?.assignedNodes({ flatten: true }) || [];
|
|
3
|
+
for (const node of nodes) {
|
|
4
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (node.nodeType === Node.TEXT_NODE &&
|
|
8
|
+
(node.textContent?.trim().length || 0) > 0) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
function observerSlotChangesWithCallback(slot, callback) {
|
|
15
|
+
const observer = new MutationObserver(() => {
|
|
16
|
+
callback(hasMeaningfulContent(slot));
|
|
17
|
+
});
|
|
18
|
+
const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
19
|
+
assignedNodes.forEach(node => {
|
|
20
|
+
observer.observe(node, {
|
|
21
|
+
attributes: true,
|
|
22
|
+
childList: true,
|
|
23
|
+
characterData: true,
|
|
24
|
+
subtree: true,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
callback(hasMeaningfulContent(slot));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { observerSlotChangesWithCallback as o };
|
|
31
|
+
//# sourceMappingURL=observe-slot-change-BGJfgg2E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-slot-change-BGJfgg2E.js","sources":["../../src/__utils/observe-slot-change.ts"],"sourcesContent":["function hasMeaningfulContent(slotElement: HTMLSlotElement | null) {\n const nodes = slotElement?.assignedNodes({ flatten: true }) || [];\n\n for (const node of nodes) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n return true;\n }\n if (\n node.nodeType === Node.TEXT_NODE &&\n (node.textContent?.trim().length || 0) > 0\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function observerSlotChangesWithCallback(\n slot: HTMLSlotElement | null,\n callback: (hasContent: boolean) => void,\n) {\n const observer = new MutationObserver(() => {\n callback(hasMeaningfulContent(slot));\n });\n\n const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];\n assignedNodes.forEach(node => {\n observer.observe(node, {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true,\n });\n });\n\n callback(hasMeaningfulContent(slot));\n}"],"names":[],"mappings":"AAAA,SAAS,oBAAoB,CAAC,WAAmC,EAAA;AAC/D,IAAA,MAAM,KAAK,GAAG,WAAW,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAEjE,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE;AACvC,YAAA,OAAO,IAAI;QACb;AACA,QAAA,IACE,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS;AAChC,YAAA,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,EAC1C;AACA,YAAA,OAAO,IAAI;QACb;IACF;AAEA,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,+BAA+B,CAC7C,IAA4B,EAC5B,QAAuC,EAAA;AAEvC,IAAA,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAK;AACzC,QAAA,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,aAAa,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAClE,IAAA,aAAa,CAAC,OAAO,CAAC,IAAI,IAAG;AAC3B,QAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;AACrB,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACtC;;;;"}
|