@lion/ui 0.0.1 → 0.0.3
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/components/core/test/SlotMixin.test.js +28 -21
- package/components/drawer/src/LionDrawer.js +217 -0
- package/components/drawer/src/drawerStyle.js +59 -0
- package/components/drawer/test/lion-drawer.test.js +109 -0
- package/components/localize/src/number/parseNumber.js +15 -36
- package/components/localize/test/number/parseNumber.test.js +3 -12
- package/custom-elements.json +743 -0
- package/dist-types/components/drawer/src/LionDrawer.d.ts +67 -0
- package/dist-types/components/drawer/src/LionDrawer.d.ts.map +1 -0
- package/dist-types/components/drawer/src/drawerStyle.d.ts +2 -0
- package/dist-types/components/drawer/src/drawerStyle.d.ts.map +1 -0
- package/dist-types/components/drawer/test/lion-drawer.test.d.ts +3 -0
- package/dist-types/components/drawer/test/lion-drawer.test.d.ts.map +1 -0
- package/dist-types/components/localize/src/number/parseNumber.d.ts.map +1 -1
- package/dist-types/exports/define/lion-drawer.d.ts +2 -0
- package/dist-types/exports/define/lion-drawer.d.ts.map +1 -0
- package/dist-types/exports/drawer.d.ts +2 -0
- package/dist-types/exports/drawer.d.ts.map +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/accordion/index.md +3 -0
- package/docs/components/accordion/overview.md +129 -0
- package/docs/components/accordion/reference.md +47 -0
- package/docs/components/accordion/use-cases.md +252 -0
- package/docs/components/button/examples.md +30 -0
- package/docs/components/button/index.md +3 -0
- package/docs/components/button/overview.md +30 -0
- package/docs/components/button/src/icon.svg.js +5 -0
- package/docs/components/button/use-cases.md +106 -0
- package/docs/components/calendar/index.md +3 -0
- package/docs/components/calendar/overview.md +49 -0
- package/docs/components/calendar/use-cases.md +192 -0
- package/docs/components/checkbox-group/index.md +3 -0
- package/docs/components/checkbox-group/overview.md +40 -0
- package/docs/components/checkbox-group/use-cases.md +256 -0
- package/docs/components/collapsible/assets/CustomCollapsible.js +113 -0
- package/docs/components/collapsible/assets/applyDemoCollapsibleStyles.js +37 -0
- package/docs/components/collapsible/examples.md +83 -0
- package/docs/components/collapsible/index.md +3 -0
- package/docs/components/collapsible/overview.md +39 -0
- package/docs/components/collapsible/use-cases.md +79 -0
- package/docs/components/combobox/examples.md +153 -0
- package/docs/components/combobox/index.md +3 -0
- package/docs/components/combobox/overview.md +51 -0
- package/docs/components/combobox/src/LinkMixin.js +60 -0
- package/docs/components/combobox/src/demo-selection-display.js +191 -0
- package/docs/components/combobox/src/gh-combobox/gh-button.js +69 -0
- package/docs/components/combobox/src/gh-combobox/gh-combobox.js +508 -0
- package/docs/components/combobox/src/google-combobox/assets/google-clear-icon.js +9 -0
- package/docs/components/combobox/src/google-combobox/assets/google-search-icon.js +9 -0
- package/docs/components/combobox/src/google-combobox/assets/google-voice-search-icon.js +19 -0
- package/docs/components/combobox/src/google-combobox/assets/googlelogo_color_272x92dp.png +0 -0
- package/docs/components/combobox/src/google-combobox/google-combobox.js +460 -0
- package/docs/components/combobox/src/lazyRender.js +29 -0
- package/docs/components/combobox/src/levenshtein.js +95 -0
- package/docs/components/combobox/src/md-combobox/MdFieldMixin.js +341 -0
- package/docs/components/combobox/src/md-combobox/md-combobox.js +89 -0
- package/docs/components/combobox/src/md-combobox/md-input.js +5 -0
- package/docs/components/combobox/src/md-combobox/style/load-roboto.js +6 -0
- package/docs/components/combobox/src/md-combobox/style/md-ripple.js +81 -0
- package/docs/components/combobox/src/wa-combobox/wa-combobox.js +368 -0
- package/docs/components/combobox/use-cases.md +377 -0
- package/docs/components/dialog/index.md +3 -0
- package/docs/components/dialog/overview.md +63 -0
- package/docs/components/dialog/src/demo-dialog-style.js +3 -0
- package/docs/components/dialog/src/demoStyle.js +39 -0
- package/docs/components/dialog/src/slots-dialog-content.js +32 -0
- package/docs/components/dialog/src/styled-dialog-content.js +38 -0
- package/docs/components/dialog/use-cases.md +154 -0
- package/docs/components/drawer/index.md +3 -0
- package/docs/components/drawer/overview.md +68 -0
- package/docs/components/drawer/src/demoStyle.js +71 -0
- package/docs/components/drawer/use-cases.md +194 -0
- package/docs/components/fieldset/index.md +3 -0
- package/docs/components/fieldset/overview.md +49 -0
- package/docs/components/fieldset/use-cases.md +185 -0
- package/docs/components/form/index.md +3 -0
- package/docs/components/form/overview.md +43 -0
- package/docs/components/form/use-cases.md +72 -0
- package/docs/components/icon/assets/bugs/bug01.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug02.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug05.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug06.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug08.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug12.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug19.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug23.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug24.svg.js +2 -0
- package/docs/components/icon/assets/iconset-bugs.js +11 -0
- package/docs/components/icon/assets/iconset-misc.js +3 -0
- package/docs/components/icon/assets/iconset-space.js +31 -0
- package/docs/components/icon/assets/misc/arrowLeft.svg.js +6 -0
- package/docs/components/icon/assets/space/aliens-spaceship.svg.js +2 -0
- package/docs/components/icon/assets/space/meteor.svg.js +2 -0
- package/docs/components/icon/assets/space/moon-flag.svg.js +2 -0
- package/docs/components/icon/assets/space/moon.svg.js +2 -0
- package/docs/components/icon/assets/space/night.svg.js +2 -0
- package/docs/components/icon/assets/space/orbit.svg.js +2 -0
- package/docs/components/icon/assets/space/planet.svg.js +2 -0
- package/docs/components/icon/assets/space/robot.svg.js +2 -0
- package/docs/components/icon/assets/space/rocket.svg.js +2 -0
- package/docs/components/icon/assets/space/satellite.svg.js +2 -0
- package/docs/components/icon/assets/space/signal.svg.js +2 -0
- package/docs/components/icon/assets/space/space-helmet.svg.js +2 -0
- package/docs/components/icon/assets/space/sun.svg.js +2 -0
- package/docs/components/icon/assets/space/telescope.svg.js +2 -0
- package/docs/components/icon/index.md +3 -0
- package/docs/components/icon/overview.md +40 -0
- package/docs/components/icon/use-cases.md +93 -0
- package/docs/components/index.md +7 -0
- package/docs/components/input/index.md +3 -0
- package/docs/components/input/overview.md +36 -0
- package/docs/components/input/use-cases.md +77 -0
- package/docs/components/input-amount/index.md +3 -0
- package/docs/components/input-amount/overview.md +49 -0
- package/docs/components/input-amount/use-cases.md +122 -0
- package/docs/components/input-date/index.md +3 -0
- package/docs/components/input-date/overview.md +39 -0
- package/docs/components/input-date/use-cases.md +83 -0
- package/docs/components/input-datepicker/index.md +3 -0
- package/docs/components/input-datepicker/overview.md +42 -0
- package/docs/components/input-datepicker/use-cases.md +78 -0
- package/docs/components/input-email/index.md +3 -0
- package/docs/components/input-email/overview.md +32 -0
- package/docs/components/input-email/use-cases.md +48 -0
- package/docs/components/input-iban/index.md +3 -0
- package/docs/components/input-iban/overview.md +37 -0
- package/docs/components/input-iban/use-cases.md +102 -0
- package/docs/components/input-range/index.md +3 -0
- package/docs/components/input-range/overview.md +34 -0
- package/docs/components/input-range/use-cases.md +108 -0
- package/docs/components/input-stepper/index.md +3 -0
- package/docs/components/input-stepper/overview.md +36 -0
- package/docs/components/input-stepper/use-cases.md +41 -0
- package/docs/components/input-tel/index.md +3 -0
- package/docs/components/input-tel/overview.md +62 -0
- package/docs/components/input-tel/src/h-region-code-table.js +109 -0
- package/docs/components/input-tel/use-cases.md +307 -0
- package/docs/components/input-tel-dropdown/examples.md +32 -0
- package/docs/components/input-tel-dropdown/index.md +3 -0
- package/docs/components/input-tel-dropdown/overview.md +38 -0
- package/docs/components/input-tel-dropdown/src/intl-input-tel-dropdown.js +127 -0
- package/docs/components/input-tel-dropdown/use-cases.md +159 -0
- package/docs/components/listbox/index.md +3 -0
- package/docs/components/listbox/overview.md +42 -0
- package/docs/components/listbox/src/listboxData.js +65 -0
- package/docs/components/listbox/use-cases.md +147 -0
- package/docs/components/pagination/index.md +3 -0
- package/docs/components/pagination/overview.md +29 -0
- package/docs/components/pagination/use-cases.md +99 -0
- package/docs/components/progress-indicator/assets/my-determinate-progress-bar.js +30 -0
- package/docs/components/progress-indicator/assets/my-indeterminate-progress-spinner.js +55 -0
- package/docs/components/progress-indicator/examples.md +125 -0
- package/docs/components/progress-indicator/index.md +3 -0
- package/docs/components/progress-indicator/overview.md +36 -0
- package/docs/components/radio-group/index.md +3 -0
- package/docs/components/radio-group/overview.md +46 -0
- package/docs/components/radio-group/use-cases.md +140 -0
- package/docs/components/select/index.md +3 -0
- package/docs/components/select/overview.md +44 -0
- package/docs/components/select/use-cases.md +55 -0
- package/docs/components/select-rich/examples.md +31 -0
- package/docs/components/select-rich/index.md +3 -0
- package/docs/components/select-rich/overview.md +46 -0
- package/docs/components/select-rich/src/flagStyles.js +1250 -0
- package/docs/components/select-rich/src/flags.png +0 -0
- package/docs/components/select-rich/src/flags@2x.png +0 -0
- package/docs/components/select-rich/src/intl-select-rich.js +194 -0
- package/docs/components/select-rich/src/regionMetaList.js +1717 -0
- package/docs/components/select-rich/use-cases.md +370 -0
- package/docs/components/steps/index.md +3 -0
- package/docs/components/steps/overview.md +63 -0
- package/docs/components/steps/use-cases.md +163 -0
- package/docs/components/switch/index.md +3 -0
- package/docs/components/switch/overview.md +75 -0
- package/docs/components/switch/reference.md +39 -0
- package/docs/components/switch/use-cases.md +76 -0
- package/docs/components/tabs/examples.md +23 -0
- package/docs/components/tabs/index.md +3 -0
- package/docs/components/tabs/overview.md +48 -0
- package/docs/components/tabs/src/lea-tab-panel.js +24 -0
- package/docs/components/tabs/src/lea-tab.js +45 -0
- package/docs/components/tabs/src/lea-tabs.js +28 -0
- package/docs/components/tabs/use-cases.md +219 -0
- package/docs/components/textarea/index.md +3 -0
- package/docs/components/textarea/overview.md +35 -0
- package/docs/components/textarea/use-cases.md +95 -0
- package/docs/components/tooltip/examples.md +39 -0
- package/docs/components/tooltip/index.md +3 -0
- package/docs/components/tooltip/overview.md +44 -0
- package/docs/components/tooltip/use-cases.md +208 -0
- package/docs/fundamentals/index.md +19 -0
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/overview.md +233 -0
- package/docs/fundamentals/node-tools/index.md +1 -0
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +68 -0
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +111 -0
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +69 -0
- package/docs/fundamentals/node-tools/providence-analytics/assets/_mermaid.svg.js +1202 -0
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +22 -0
- package/docs/fundamentals/node-tools/providence-analytics/index.md +1 -0
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +192 -0
- package/docs/fundamentals/node-tools/publish-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/publish-docs/overview.md +136 -0
- package/docs/fundamentals/node-tools/remark-extend/index.md +1 -0
- package/docs/fundamentals/node-tools/remark-extend/overview.md +274 -0
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +285 -0
- package/docs/fundamentals/rationales/TypeScript.md +18 -0
- package/docs/fundamentals/rationales/index.md +1 -0
- package/docs/fundamentals/rationales/side-effects.md +203 -0
- package/docs/fundamentals/rationales/versioning.md +35 -0
- package/docs/fundamentals/systems/core/index.md +3 -0
- package/docs/fundamentals/systems/core/overview.md +85 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-1.svg +1 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-2.svg +1 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-3.svg +84 -0
- package/docs/fundamentals/systems/form/assets/h-output.js +155 -0
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +245 -0
- package/docs/fundamentals/systems/form/index.md +3 -0
- package/docs/fundamentals/systems/form/interaction-states.md +177 -0
- package/docs/fundamentals/systems/form/model-value.md +35 -0
- package/docs/fundamentals/systems/form/overview.md +82 -0
- package/docs/fundamentals/systems/form/styling.md +101 -0
- package/docs/fundamentals/systems/form/use-cases.md +156 -0
- package/docs/fundamentals/systems/form/validate.md +929 -0
- package/docs/fundamentals/systems/icon/index.md +3 -0
- package/docs/fundamentals/systems/icon/overview.md +124 -0
- package/docs/fundamentals/systems/index.md +1 -0
- package/docs/fundamentals/systems/localize/assets/all-locales.js +437 -0
- package/docs/fundamentals/systems/localize/assets/en-AU.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en-GB.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en-US.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en.js +4 -0
- package/docs/fundamentals/systems/localize/assets/nl-BE.js +6 -0
- package/docs/fundamentals/systems/localize/assets/nl-NL.js +6 -0
- package/docs/fundamentals/systems/localize/assets/nl.js +4 -0
- package/docs/fundamentals/systems/localize/dates.md +195 -0
- package/docs/fundamentals/systems/localize/index.md +3 -0
- package/docs/fundamentals/systems/localize/numbers.md +217 -0
- package/docs/fundamentals/systems/localize/overview.md +48 -0
- package/docs/fundamentals/systems/localize/rationale.md +62 -0
- package/docs/fundamentals/systems/localize/text.md +125 -0
- package/docs/fundamentals/systems/localize/use-cases.md +319 -0
- package/docs/fundamentals/systems/overlays/assets/applyDemoOverlayStyles.js +22 -0
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-backdrop.js +48 -0
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-system.js +42 -0
- package/docs/fundamentals/systems/overlays/assets/umbrella-form.js +133 -0
- package/docs/fundamentals/systems/overlays/configuration.md +453 -0
- package/docs/fundamentals/systems/overlays/form-integration.md +65 -0
- package/docs/fundamentals/systems/overlays/index.md +3 -0
- package/docs/fundamentals/systems/overlays/overview.md +118 -0
- package/docs/fundamentals/systems/overlays/rationale.md +232 -0
- package/docs/fundamentals/systems/overlays/scope.md +176 -0
- package/docs/fundamentals/systems/overlays/use-cases.md +699 -0
- package/docs/fundamentals/tools/ajax/assets/naga.json +9 -0
- package/docs/fundamentals/tools/ajax/assets/pabu.json +9 -0
- package/docs/fundamentals/tools/ajax/index.md +3 -0
- package/docs/fundamentals/tools/ajax/overview.md +128 -0
- package/docs/fundamentals/tools/ajax/use-cases.md +456 -0
- package/docs/fundamentals/tools/helpers/action-logger.md +165 -0
- package/docs/fundamentals/tools/helpers/index.md +3 -0
- package/docs/fundamentals/tools/helpers/overview.md +30 -0
- package/docs/fundamentals/tools/index.md +1 -0
- package/docs/fundamentals/tools/singleton-manager/index.md +3 -0
- package/docs/fundamentals/tools/singleton-manager/overview.md +304 -0
- package/docs/guides/how-to/create-a-custom-field.md +200 -0
- package/docs/guides/how-to/extend-a-native-input.md +66 -0
- package/docs/guides/how-to/get-started.md +77 -0
- package/docs/guides/how-to/index.md +1 -0
- package/docs/guides/index.md +34 -0
- package/docs/guides/principles/definitions-and-terms.md +41 -0
- package/docs/guides/principles/index.md +26 -0
- package/docs/guides/principles/scoped-elements.md +103 -0
- package/docs/guides/principles/styling.md +32 -0
- package/docs/guides/principles/subclasser-apis.md +28 -0
- package/docs/override.js +15 -0
- package/exports/define/lion-drawer.js +3 -0
- package/exports/drawer.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Tools >> Helpers >> Action Logger ||20
|
|
2
|
+
|
|
3
|
+
A visual element to show action logs in demos `sb-action-logger`
|
|
4
|
+
|
|
5
|
+
```js script
|
|
6
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
7
|
+
import '@lion/ui/define-helpers/sb-action-logger.js';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```js preview-story
|
|
11
|
+
export const main = () => {
|
|
12
|
+
const uid = Math.random().toString(36).substr(2, 10);
|
|
13
|
+
return html`
|
|
14
|
+
<p>To log: <code>Hello, World!</code></p>
|
|
15
|
+
<button
|
|
16
|
+
@click=${e => {
|
|
17
|
+
e.target.parentElement.querySelector(`#logger-${uid}`).log('Hello, World!');
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
Click this button
|
|
21
|
+
</button>
|
|
22
|
+
<p>Or to log: <code>What's up, Planet!</code></p>
|
|
23
|
+
<button
|
|
24
|
+
@click=${e => {
|
|
25
|
+
e.target.parentElement.querySelector(`#logger-${uid}`).log(`What's up, Planet!`);
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
Click this button
|
|
29
|
+
</button>
|
|
30
|
+
<sb-action-logger id="logger-${uid}"></sb-action-logger>
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You need some reference to your logger. Above example shows this by using a unique ID.
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const uid = Math.random().toString(36).substr(2, 10);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This connects the logger element to the trigger.
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<div>To log: <code>Hello, World!</code></div>
|
|
45
|
+
<button
|
|
46
|
+
@click=${e => {
|
|
47
|
+
e.target.parentElement.querySelector('#logger-${uid}').log('Hello, World!')
|
|
48
|
+
}}
|
|
49
|
+
>Click this button</button>
|
|
50
|
+
<sb-action-logger id="logger-${uid}"></sb-action-logger>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**This is a demonstrative tool**, not a debugging tool (although it may help initially).
|
|
54
|
+
If you try logging complex values such as arrays, objects or promises,
|
|
55
|
+
you should expect to get only the string interpretation as the output in this logger.
|
|
56
|
+
|
|
57
|
+
## Features:
|
|
58
|
+
|
|
59
|
+
- A public method `log` to log things to the action logger.
|
|
60
|
+
- Overridable `title` property.
|
|
61
|
+
- Clear button to clear logs
|
|
62
|
+
- A counter to count the total amount of logs
|
|
63
|
+
- Stacks consecutive duplicate logs and shows a counter
|
|
64
|
+
- `simple` property/attribute to only show a single log
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm i @lion/helpers
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Variations
|
|
74
|
+
|
|
75
|
+
### Simple mode
|
|
76
|
+
|
|
77
|
+
Simple mode essentially means there is only ever 1 log.
|
|
78
|
+
Duplicates are not counted or stacked, but you will still see the visual cue.
|
|
79
|
+
|
|
80
|
+
```js preview-story
|
|
81
|
+
export const simpleMode = () => {
|
|
82
|
+
const uid = Math.random().toString(36).substr(2, 10);
|
|
83
|
+
return html`
|
|
84
|
+
<div>To log: <code>Hello, World!</code></div>
|
|
85
|
+
<button
|
|
86
|
+
@click=${e => {
|
|
87
|
+
e.target.parentElement.querySelector(`#logger-${uid}`).log('Hello, World!');
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
Click this button
|
|
91
|
+
</button>
|
|
92
|
+
<div>Or to log: <code>What's up, Planet!</code></div>
|
|
93
|
+
<button
|
|
94
|
+
@click=${e => {
|
|
95
|
+
e.target.parentElement.querySelector(`#logger-${uid}`).log(`What's up, Planet!`);
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
Click this button
|
|
99
|
+
</button>
|
|
100
|
+
<sb-action-logger simple id="logger-${uid}"></sb-action-logger>
|
|
101
|
+
`;
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<sb-action-logger simple></sb-action-logger>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Custom Title
|
|
110
|
+
|
|
111
|
+
You can customize the action logger title with the `.title` property.
|
|
112
|
+
|
|
113
|
+
```js preview-story
|
|
114
|
+
export const customTitle = () => {
|
|
115
|
+
const uid = Math.random().toString(36).substr(2, 10);
|
|
116
|
+
return html`
|
|
117
|
+
<button
|
|
118
|
+
@click=${e => e.target.parentElement.querySelector(`#logger-${uid}`).log('Hello, World!')}
|
|
119
|
+
>
|
|
120
|
+
Log
|
|
121
|
+
</button>
|
|
122
|
+
<sb-action-logger id="logger-${uid}" .title=${'Hello World'}></sb-action-logger>
|
|
123
|
+
`;
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<sb-action-logger .title=${'Hello World'}></sb-action-logger>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Rationale
|
|
132
|
+
|
|
133
|
+
This component was created due to a need for a nice visual action logger in Storybook Docs mode.
|
|
134
|
+
|
|
135
|
+
In docs mode, you do not have access to the action logger addon component, and it is nice to be able to show actions inline in your demos and documentation.
|
|
136
|
+
|
|
137
|
+
### Opinionated
|
|
138
|
+
|
|
139
|
+
I added quite a bit of styling on this component to make it look decent.
|
|
140
|
+
There are a bunch of styles that you can easily override to make it fit your design system which I believe should be enough in most cases.
|
|
141
|
+
If you need more control you can always:
|
|
142
|
+
|
|
143
|
+
- Override the host styles, there's a few custom CSS props that you can override as well.
|
|
144
|
+
- Extend the component and apply your overrides
|
|
145
|
+
- Open an issue if you believe it would be good to make something more flexible / configurable
|
|
146
|
+
|
|
147
|
+
Maybe in the future I will abstract this component to a more generic (ugly) one with no styles, so it's more friendly as a shared component.
|
|
148
|
+
|
|
149
|
+
### Plugin
|
|
150
|
+
|
|
151
|
+
If you use an action logger inside your Story in Storybook, you will also see it in your canvas, and this may not be your intention.
|
|
152
|
+
|
|
153
|
+
One idea is to simplify the usage further by making this a Storybook (docs-)plugin or decorator or whatever.
|
|
154
|
+
It would be cool if someone can simply enable an action logger option on a particular Story inside their .mdx,
|
|
155
|
+
and then actions are automatically logged to the visual logger below it.
|
|
156
|
+
Would need to figure out how to catch the action and pass it to the visual logger element.
|
|
157
|
+
|
|
158
|
+
Isn't investigated yet on the how, but that is the rough idea.
|
|
159
|
+
|
|
160
|
+
## Future
|
|
161
|
+
|
|
162
|
+
New planned features can be found in the test folder where they are specified as skipped tests.
|
|
163
|
+
If the feature you'd like is not in the tests, feel free to make an issue so we can add it.
|
|
164
|
+
|
|
165
|
+
See our [CONTRIBUTING.md](https://github.com/ing-bank/lion/blob/master/CONTRIBUTING.md) for more guidelines on how to contribute.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Tools >> Helpers >> Overview ||10
|
|
2
|
+
|
|
3
|
+
A helpers package that contains several helpers that are used inside lion but can be used outside as well.
|
|
4
|
+
|
|
5
|
+
These helpers are considered developer tools, not actual things to use in production.
|
|
6
|
+
Therefore, they may not have the same quality standards as our other packages.
|
|
7
|
+
|
|
8
|
+
## Packages
|
|
9
|
+
|
|
10
|
+
| Package | Description |
|
|
11
|
+
| -------------------------------------- | ----------------------- |
|
|
12
|
+
| [sb-action-logger](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/fundamentals/tools/helpers/action-logger.md) | Storybook action logger |
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm i @lion/helpers
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Example using the sb-action-logger helper component.
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script type="module">
|
|
26
|
+
import '@lion/ui/define-helpers/sb-action-logger.js';
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<sb-action-logger></sb-action-logger>
|
|
30
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Tools ||20
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Tools >> Singleton Manager >> Overview ||10
|
|
2
|
+
|
|
3
|
+
A singleton manager provides a way to make sure a singleton instance loaded from multiple file locations stays a singleton.
|
|
4
|
+
Primarily useful if two major version of a package with a singleton is used.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i --save singleton-manager
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
⚠️ You need to make SURE that only ONE version of `singleton-manager` is installed. For how see [Non Goals](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/fundamentals/tools/singleton-manager/#non-goals).
|
|
13
|
+
|
|
14
|
+
### Example Singleton Users
|
|
15
|
+
|
|
16
|
+
Use the same singleton for both versions (as we don't use any of the breaking features)
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
// managed-my-singleton.js
|
|
20
|
+
import { singletonManager } from 'singleton-manager';
|
|
21
|
+
import { mySingleton } from 'my-singleton'; // is available as 1.x and 2.x via node resolution
|
|
22
|
+
|
|
23
|
+
singletonManager.set('my-singleton::index.js::1.x', mySingleton);
|
|
24
|
+
singletonManager.set('my-singleton::index.js::2.x', mySingleton);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
OR create a special compatible version of the singleton
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
// managed-my-singleton.js
|
|
31
|
+
import { singletonManager } from 'singleton-manager';
|
|
32
|
+
import { MySingleton } from 'my-singleton'; // is available as 1.x and 2.x via node resolution
|
|
33
|
+
|
|
34
|
+
class CompatibleSingleton extends MySingleton {
|
|
35
|
+
// add forward or backward compatibility code
|
|
36
|
+
}
|
|
37
|
+
const compatibleSingleton = new CompatibleSingleton();
|
|
38
|
+
|
|
39
|
+
singletonManager.set('my-singleton::index.js::1.x', compatibleSingleton);
|
|
40
|
+
singletonManager.set('my-singleton::index.js::2.x', compatibleSingleton);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
AND in you App then you need to load the above code BEFORE loading the singleton or any feature using it.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import './managed-my-singleton.js';
|
|
47
|
+
|
|
48
|
+
import { mySingleton } from 'my-singleton'; // will no always be what is "defined" in managed-my-singleton.js
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Warning
|
|
52
|
+
|
|
53
|
+
Overriding version is an App level concern hence components or "features" are not allowed to use it.
|
|
54
|
+
If you try to call it multiple times for the same key then it will be ignored.
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
// on app level
|
|
58
|
+
singletonManager.set('my-singleton/index.js::1.x', compatibleSingleton);
|
|
59
|
+
|
|
60
|
+
// somewhere in a dependency
|
|
61
|
+
singletonManager.set('my-singleton/index.js::1.x', otherSingleton);
|
|
62
|
+
|
|
63
|
+
// .get('my-singleton/index.js::1.x') will always return the first set value
|
|
64
|
+
// e.g. the app can set it and no one can later override it
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Example Singleton Maintainers
|
|
68
|
+
|
|
69
|
+
If you are a maintainer of a singleton be sure to check if a singleton manager version is set.
|
|
70
|
+
If that is the case return it instead of your default instance.
|
|
71
|
+
|
|
72
|
+
It could look something like this:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
// my-singleton.js
|
|
76
|
+
import { singletonManager } from 'singleton-manager';
|
|
77
|
+
import { MySingleton } from './src/MySingleton.js';
|
|
78
|
+
|
|
79
|
+
export const overlays =
|
|
80
|
+
singletonManager.get('my-singleton/my-singleton.js::1.x') || new MySingleton();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Convention Singleton Key
|
|
84
|
+
|
|
85
|
+
The key for a singleton needs to be "unique" for the package.
|
|
86
|
+
Hence the following convention helps maintaining this.
|
|
87
|
+
|
|
88
|
+
As a key use the `<package>::<unique-variable>::<semver-range>`.
|
|
89
|
+
|
|
90
|
+
Examples Do:
|
|
91
|
+
|
|
92
|
+
- `overlays::overlays::1.x` - instance created in index.js
|
|
93
|
+
- `@scope/overlays::overlays::1.x` - with scope
|
|
94
|
+
- `overlays::overlays::1.x` - version 1.x.x (> 1.0.0 you do 1.x, 2.x)
|
|
95
|
+
- `overlays::overlays::2.x` - version 2.x.x (> 1.0.0 you do 1.x, 2.x)
|
|
96
|
+
- `overlays::overlays::0.10.x` - version 0.10.x (< 1.0.0 you do 0.1.x, 0.2.x)
|
|
97
|
+
|
|
98
|
+
Examples Don't:
|
|
99
|
+
|
|
100
|
+
- `overlays` - too generic
|
|
101
|
+
- `overlays::overlays` - you should include a version
|
|
102
|
+
- `overlays::1.x` - you should include a package name & unique var
|
|
103
|
+
- `./index.js::1.x` - it should start with a package name
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Singleton Manager Rationale
|
|
108
|
+
|
|
109
|
+
We have an app with 2 pages.
|
|
110
|
+
|
|
111
|
+
- page-a uses overlays 1.x
|
|
112
|
+
- page-b uses overlays 2.x (gets installed nested)
|
|
113
|
+
|
|
114
|
+
```markdown
|
|
115
|
+
my-app (node_modules)
|
|
116
|
+
├── overlays (1.x)
|
|
117
|
+
├── page-a
|
|
118
|
+
│ └── page-a.js
|
|
119
|
+
└── page-b
|
|
120
|
+
├── node_modules
|
|
121
|
+
│ └── overlays (2.x)
|
|
122
|
+
└── page-b.js
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The tough part in this case is the OverlaysManager within the overlays package as it needs to be a singleton.
|
|
126
|
+
|
|
127
|
+
It starts of simplified like this
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
export class OverlaysManager {
|
|
131
|
+
name = 'OverlayManager 1.x';
|
|
132
|
+
blockBody = false;
|
|
133
|
+
constructor() {
|
|
134
|
+
this._setupBlocker();
|
|
135
|
+
}
|
|
136
|
+
_setupBlocker() {
|
|
137
|
+
/* ... */
|
|
138
|
+
}
|
|
139
|
+
block() {
|
|
140
|
+
this.blockBody = true; // ...
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
unBlock() {
|
|
144
|
+
this.blockBody = false; // ...
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Example A (fail)
|
|
150
|
+
|
|
151
|
+
See it "fail" e.g. 2 separate OverlaysManager are at work and are "fighting" over the way to block the body.
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npm run start:fail
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Steps to reproduce:
|
|
158
|
+
|
|
159
|
+
1. Page A click on block
|
|
160
|
+
2. Page B => "Blocked: false" (even when hitting the refresh button)
|
|
161
|
+
|
|
162
|
+
➡️ See [it on the example page](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/fundamentals/tools/singleton-manager/example-fail/index.md). <br>
|
|
163
|
+
➡️ See [the code](https://github.com/ing-bank/lion/tree/master/docs/fundamentals/tools/singleton-manager/example-fail/demo-app.js).
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Example B (singleton manager)
|
|
168
|
+
|
|
169
|
+
The breaking change in `OverlayManager` was renaming of 2 function (which has been deprecated before).
|
|
170
|
+
|
|
171
|
+
- `block()` => `blockingBody()`
|
|
172
|
+
- `unBlock()` => `unBlockingBody()`
|
|
173
|
+
|
|
174
|
+
knowing that we can create a Manager that is compatible with both via
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
import { OverlaysManager } from 'overlays';
|
|
178
|
+
|
|
179
|
+
class CompatibleOverlaysManager extends OverlaysManager {
|
|
180
|
+
blockingBody() {
|
|
181
|
+
this.block();
|
|
182
|
+
}
|
|
183
|
+
unBlockingBody() {
|
|
184
|
+
this.unBlock();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
all that is left is a to "override" the default instance of the "users"
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
import { singletonManager } from 'singleton-manager';
|
|
193
|
+
|
|
194
|
+
const compatibleOverlaysManager = new CompatibleOverlaysManager();
|
|
195
|
+
singletonManager.set('overlays::overlays::1.x', compatibleOverlaysManager);
|
|
196
|
+
singletonManager.set('overlays::overlays::2.x', compatibleOverlaysManager);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
See it in action
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm run start:singleton
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
➡️ See [it on the example page](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/fundamentals/tools/singleton-manager/example-success/index.md). <br>
|
|
206
|
+
➡️ See [the code](https://github.com/ing-bank/lion/tree/master/docs/fundamentals/tools/singleton-manager/example-success/demo-app.js).
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Example C (singleton and complex patching on app level)
|
|
211
|
+
|
|
212
|
+
The breaking change in `OverlayManager` was converting a property to a function and a rename of a function.
|
|
213
|
+
|
|
214
|
+
- `blockBody` => `_blockBody`
|
|
215
|
+
- `block()` => `blockBody()`
|
|
216
|
+
- `unBlock()` => `unBlockBody()`
|
|
217
|
+
|
|
218
|
+
e.g. what is impossible to make compatible with a single instance is to have `blockBody` act as a property for 1.x and as a function `blockBody()` for 2.x.
|
|
219
|
+
|
|
220
|
+
So how do we solve it then?
|
|
221
|
+
|
|
222
|
+
We will make 2 separate instances of the `OverlayManager`.
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
compatibleManager1 = new CompatibleManager1(); // 1.x
|
|
226
|
+
compatibleManager2 = new CompatibleManager2(); // 2.x
|
|
227
|
+
console.log(typeof compatibleManager1.blockBody); // Boolean
|
|
228
|
+
console.log(typeof compatibleManager2.blockBody); // Function
|
|
229
|
+
|
|
230
|
+
// and override
|
|
231
|
+
singletonManager.set('overlays::overlays::1.x', compatibleManager1);
|
|
232
|
+
singletonManager.set('overlays::overlays::2.x', compatibleManager2);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
and they are "compatible" to each other because they sync the important data to each other.
|
|
236
|
+
e.g. even though there are 2 instances there is only `one` dom element inserted which both can write to.
|
|
237
|
+
When syncing data only the initiator will update the dom.
|
|
238
|
+
This makes sure even though functions and data is separate it will be always consistent.
|
|
239
|
+
|
|
240
|
+
See it in action
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npm run start:singleton-complex
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
➡️ See [it on the example page](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/fundamentals/tools/singleton-manager/example-complex/index.md). <br>
|
|
247
|
+
➡️ See [the code](https://github.com/ing-bank/lion/tree/master/docs/fundamentals/tools/singleton-manager/example-complex/demo-app.js).
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## How does it work?
|
|
252
|
+
|
|
253
|
+
As a user you can override what the import of `overlays/instance.js` provides.
|
|
254
|
+
You do this via a singletonManager and a "magic" string.
|
|
255
|
+
|
|
256
|
+
- Reason be that you can target ranges of versions
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
singletonManager.set('overlays::overlays::1.x', compatibleManager1);
|
|
260
|
+
singletonManager.set('overlays::overlays::2.x', compatibleManager2);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Potential Improvements
|
|
264
|
+
|
|
265
|
+
Potentially we could have "range", "exacts version" and symbol for unique filename.
|
|
266
|
+
So you can override with increasing specificity.
|
|
267
|
+
If you have a use case for that please open an issue.
|
|
268
|
+
|
|
269
|
+
## Non Goals
|
|
270
|
+
|
|
271
|
+
Making sure that there are only 2 major versions of a specific packages.
|
|
272
|
+
npm is not meant to handle it - and it never will
|
|
273
|
+
|
|
274
|
+
```markdown
|
|
275
|
+
my-app
|
|
276
|
+
├─┬ feat-a@x
|
|
277
|
+
│ └── foo@2.x
|
|
278
|
+
├─┬ feat-a@x
|
|
279
|
+
│ └── foo@2.x
|
|
280
|
+
└── foo@1.x
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Dedupe works by moving dependencies up the tree
|
|
284
|
+
|
|
285
|
+
```markdown
|
|
286
|
+
// this app
|
|
287
|
+
my-app
|
|
288
|
+
my-app/node_modules/feat-a/node_modules/foo
|
|
289
|
+
my-app/node_modules/foo
|
|
290
|
+
|
|
291
|
+
// can become if versions match
|
|
292
|
+
my-app
|
|
293
|
+
my-app/node_modules/foo
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
in there `feat-a` will grab the version of it's "parent" because of the node resolution system.
|
|
297
|
+
If however the versions do not match or there is no "common" folder to move it up to then it needs to be "duplicated" by npm/yarn.
|
|
298
|
+
|
|
299
|
+
Only by using a more controlled way like
|
|
300
|
+
|
|
301
|
+
- [import-maps](https://github.com/WICG/import-maps)
|
|
302
|
+
- [yarn resolutions](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/)
|
|
303
|
+
|
|
304
|
+
you can "hard" code it to the same versions.
|