@muonic/muon 0.0.2-experimental-123-c739cfa.0 → 0.0.2-experimental-126-4fb60a6.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.
@@ -1,15 +1,23 @@
1
1
  import { Card } from '@muonic/muon/components/card';
2
2
  import setup from '@muonic/muon/storybook/stories';
3
3
  import { StandardLink as CTALink } from '../cta/story';
4
+ import { staticHTML, unsafeStatic } from '@muonic/muon';
4
5
 
5
6
  const details = setup('card', Card);
6
7
 
7
- export default details.defaultValues;
8
+ export default {
9
+ ...details.defaultValues,
10
+ parameters: {
11
+ controls: {
12
+ exclude: ['standardTemplate']
13
+ }
14
+ }
15
+ };
8
16
 
9
- const innerDetail = (args) => `
10
- <h2 slot="header">${args.header}</h2>
11
- ${args.content}
12
- <div slot="footer">${args.footer}</div>
17
+ const innerDetail = (args) => staticHTML`
18
+ <h2 slot="header">${unsafeStatic(args.header)}</h2>
19
+ ${unsafeStatic(args.content)}
20
+ <div slot="footer">${unsafeStatic(args.footer)}</div>
13
21
  `;
14
22
 
15
23
  const StandardTemplate = (args) => details.template(args, innerDetail);
@@ -31,14 +39,14 @@ StandardWithImage.args = {
31
39
  footer: `We've even got a free <a href='#!'>smartphone app</a>.`
32
40
  };
33
41
 
34
- const innerDetailWithCTA = (args) => `
35
- <h2 slot="header">${args.header}</h2>
36
- ${args.content}
37
- <div slot="footer">${CTALink(args.footer)}</div>
42
+ const innerDetailWithCTA = (args) => staticHTML`
43
+ <h2 slot="header">${unsafeStatic(args.header)}</h2>
44
+ ${unsafeStatic(args.content)}
45
+ <div slot="footer">${CTALink(args.cta)}</div>
38
46
  `;
39
47
  export const StandardWithCTA = (args) => details.template(args, innerDetailWithCTA);
40
48
  StandardWithCTA.args = {
41
49
  header: 'Where can I buy an ice cream?',
42
50
  content: `<p>We have the most wonderful shop just in town, that sells a whole variety of different ice creams. Just pop on in and we can get you sorted with your favourite flavour!</p>`,
43
- footer: { text: 'Click Here', href: '#!' }
51
+ cta: { ...CTALink.args, text: 'Click Here', href: '#!' }
44
52
  };
@@ -1,20 +1,28 @@
1
1
  import { Cta } from '@muonic/muon/components/cta';
2
2
  import setup from '@muonic/muon/storybook/stories';
3
+ import { staticHTML } from '@muonic/muon';
3
4
 
4
5
  const details = setup('cta', Cta);
5
6
  const tag = details.getTagEl();
6
7
 
7
- export default details.defaultValues;
8
+ export default {
9
+ ...details.defaultValues,
10
+ parameters: {
11
+ controls: {
12
+ exclude: ['standardTemplate', 'submitTemplate', 'resetTemplate', 'loading-message']
13
+ }
14
+ }
15
+ };
8
16
 
9
- const StandardTemplate = (args) => details.template(args, (args) => args.text);
17
+ const StandardTemplate = (args) => staticHTML`${details.template(args, (args) => args.text)}`;
10
18
  const ButtonTemplate = (args) => {
11
19
  const dArgs = details.dynamicArgs(args);
12
20
 
13
- return `<${tag} ${dArgs} ._isButton=${true}>${args.text}</${tag}>`;
21
+ return staticHTML`<${tag} ${dArgs} ._isButton=${true}>${args.text}</${tag}>`;
14
22
  };
15
- const FormTemplate = (args) => `<form>${details.template(args, (args) => args.text)}</form>`;
16
- const WithinLinkTemplate = (args) => `<a href="${args.link}">${details.template(args, (args) => args.text)}</a>`;
17
- const WithinButtonTemplate = (args) => `<button>${details.template(args, (args) => args.text)}</button>`;
23
+ const FormTemplate = (args) => staticHTML`<form>${StandardTemplate(args)}</form>`;
24
+ const WithinLinkTemplate = (args) => staticHTML`<a href="${args.link}">${StandardTemplate(args)}</a>`;
25
+ const WithinButtonTemplate = (args) => staticHTML`<button>${StandardTemplate(args)}</button>`;
18
26
 
19
27
  export const Standard = StandardTemplate.bind({});
20
28
  Standard.args = { text: 'Highpoint' };
@@ -1,13 +1,21 @@
1
1
  import { Detail } from '@muonic/muon/components/detail';
2
2
  import setup from '@muonic/muon/storybook/stories';
3
+ import { staticHTML, unsafeStatic } from '@muonic/muon';
3
4
 
4
5
  const details = setup('detail', Detail);
5
6
 
6
- export default details.defaultValues;
7
+ export default {
8
+ ...details.defaultValues,
9
+ parameters: {
10
+ controls: {
11
+ exclude: ['standardTemplate']
12
+ }
13
+ }
14
+ };
7
15
 
8
- const innerDetail = (args) => `
9
- <div slot="heading">${args.heading}</div>
10
- ${args.content}
16
+ const innerDetail = (args) => staticHTML`
17
+ <div slot="heading">${unsafeStatic(args.heading)}</div>
18
+ ${unsafeStatic(args.content)}
11
19
  `;
12
20
 
13
21
  const StandardTemplate = (args) => details.template(args, innerDetail);
@@ -1,38 +1,57 @@
1
1
  import { Form } from '@muonic/muon/components/form';
2
2
  import setup from '@muonic/muon/storybook/stories';
3
- import { Text, Email, Checkbox } from '../inputter/story';
3
+ import * as InputterStories from '../inputter/story';
4
4
  import { Standard as SubmitCTA } from '../cta/story';
5
+ import { staticHTML } from '@muonic/muon';
5
6
 
6
7
  const details = setup('form', Form);
7
8
 
8
- export default details.defaultValues;
9
+ export default {
10
+ ...details.defaultValues,
11
+ parameters: {
12
+ controls: {
13
+ exclude: ['standardTemplate', 'submit']
14
+ }
15
+ }
16
+ };
9
17
 
10
- const innerDetail = () => `
11
- <form>
12
- ${Text({ ...Text.args,
18
+ const innerDetail = (args) => staticHTML`
19
+ <form>
20
+ ${InputterStories.Text(args.Text)}
21
+ ${InputterStories.Email(args.Email)}
22
+
23
+ <label for="user-id">User ID<label>
24
+ <input type="text" id="user-id" name="user-id" required/>
25
+
26
+ ${InputterStories.Checkbox(args.Checkbox)}
27
+
28
+ <input type="reset" />
29
+ ${SubmitCTA(args.Submit)}
30
+ <form>`;
31
+
32
+ export const Standard = (args) => details.template(args, innerDetail);
33
+
34
+ Standard.args = {
35
+ Text: {
36
+ ...InputterStories.Text.args,
13
37
  name: 'username',
14
38
  label: 'Name'
15
- })}
16
- ${Email({ ...Email.args,
39
+ },
40
+ Email: {
41
+ ...InputterStories.Email.args,
17
42
  name: 'useremail'
18
- })}
19
-
20
- <label for="user-id">User ID<label>
21
- <input type="text" id="user-id" name="user-id" required/>
22
-
23
- ${Checkbox({ ...Checkbox.args,
43
+ },
44
+ Checkbox: {
45
+ ...InputterStories.Checkbox.args,
24
46
  value: 'b',
25
47
  options: [
26
48
  { label: 'Option A', value: 'a' },
27
49
  { label: 'Option B', value: 'b' }
28
50
  ]
29
- })}
30
-
31
- <input type="reset" />
32
- ${SubmitCTA({ ...SubmitCTA.args,
51
+ },
52
+ Submit: {
53
+ ...SubmitCTA.args,
33
54
  type: 'submit',
34
55
  text: 'Submit'
35
- })}
36
- <form>`;
37
-
38
- export const Standard = (args) => details.template(args, innerDetail);
56
+ }
57
+ };
@@ -6,22 +6,21 @@ import {
6
6
 
7
7
  const details = setup('icon', Icon);
8
8
 
9
- details.defaultValues.argTypes = {
10
- ...details.defaultValues.argTypes,
11
- iconSize: {
12
- table: {
13
- disable: true
9
+ export default {
10
+ ...details.defaultValues,
11
+ parameters: {
12
+ controls: {
13
+ exclude: ['standardTemplate', 'sizes', 'iconSize', 'allSizes']
14
14
  }
15
15
  },
16
- size: {
17
- control: {
18
- type: 'select',
19
- options: [...ICON_CONFIG_SIZES]
16
+ argTypes: {
17
+ ...details.defaultValues.argTypes,
18
+ size: {
19
+ control:
20
+ { type: 'range', min: 1, max: ICON_CONFIG_SIZES.length, step: 1 }
20
21
  }
21
22
  }
22
23
  };
23
24
 
24
- export default details.defaultValues;
25
-
26
25
  export const Standard = (args) => details.template(args);
27
26
  Standard.args = { name: 'arrow-right' };
@@ -1,9 +1,26 @@
1
1
  import { Image } from '@muonic/muon/components/image';
2
2
  import setup from '@muonic/muon/storybook/stories';
3
+ import { IMAGE_CONFIG_RATIOS } from '@muonic/muon/build/tokens/es6/muon-tokens.mjs';
3
4
 
4
5
  const details = setup('image', Image);
5
6
 
6
- export default details.defaultValues;
7
+ export default {
8
+ ...details.defaultValues,
9
+ parameters: {
10
+ controls: {
11
+ exclude: ['standardTemplate', 'placeholderImage']
12
+ }
13
+ },
14
+ argTypes: {
15
+ ...details.defaultValues.argTypes,
16
+ ratio: {
17
+ options: IMAGE_CONFIG_RATIOS,
18
+ control: {
19
+ type: 'inline-radio'
20
+ }
21
+ }
22
+ }
23
+ };
7
24
 
8
25
  const StandardTemplate = (args) => details.template(args, (args) => args.text);
9
26
 
@@ -1,53 +1,56 @@
1
1
  import { Inputter } from '@muonic/muon/components/inputter';
2
2
  import setup from '@muonic/muon/storybook/stories';
3
3
  import customValidation from '@muon/utils/validation/index.js';
4
+ import { staticHTML, unsafeStatic } from '@muonic/muon';
5
+
4
6
  const details = setup('inputter', Inputter);
5
7
 
6
- details.defaultValues.argTypes = {
7
- ...details.defaultValues.argTypes,
8
- validation: {
9
- control: {
10
- type: 'multi-select',
11
- options: [...Object.keys(customValidation)]
8
+ export default {
9
+ ...details.defaultValues,
10
+ parameters: {
11
+ controls: {
12
+ exclude: ['standardTemplate']
13
+ }
14
+ },
15
+ argTypes: {
16
+ ...details.defaultValues.argTypes,
17
+ validation: {
18
+ control: {
19
+ type: 'multi-select',
20
+ options: [...Object.keys(customValidation)]
21
+ }
12
22
  }
13
23
  }
14
24
  };
15
25
 
16
- export default details.defaultValues;
26
+ const autoCompleteTemplate = (args) => args.autocomplete ? unsafeStatic(`autocomplete="${args.autocomplete}"`) : '';
17
27
 
18
- const labelTemplate = (args) => `
19
- <label slot="label">${args.label}</label>
20
- `;
28
+ const placeHolderTemplate = (args) => args.placeholder ? unsafeStatic(`placeholder="${args.placeholder}"`) : '';
21
29
 
22
- const tipDetailsTemplate = (args) => `
23
- <div slot="tip-details">${args.tip}</div>
24
- `;
30
+ const disabledTemplate = (args) => args.disabled ? unsafeStatic(`disabled`) : '';
25
31
 
26
- const autoCompleteTemplate = (args) => `
27
- ${args.autocomplete ? `autocomplete="${args.autocomplete}"` : ''}
28
- `;
32
+ const labelTemplate = (args) => staticHTML`
33
+ <label slot="label">${args.label}</label>`;
29
34
 
30
- const placeHolderTemplate = (args) => `
31
- ${args.placeholder ? `placeholder="${args.placeholder}"` : ''}
32
- `;
35
+ const tipDetailsTemplate = (args) => staticHTML`
36
+ <div slot="tip-details">${args.tip}</div>`;
33
37
 
34
- const disabledTemplate = (args) => `
35
- ${args.disabled ? `disabled` : ''}
36
- `;
38
+ const inputTemplate = (args) => staticHTML`
39
+ <input type="${args.inputtype}" ${placeHolderTemplate(args)} ${autoCompleteTemplate(args)} ${disabledTemplate(args)}>`;
37
40
 
38
- const slottedContent = (args) => `
41
+ const singleTemplate = (args) => staticHTML`
39
42
  ${args.label ? labelTemplate(args) : ''}
40
- <input type="${args.inputtype}" ${placeHolderTemplate(args)} ${autoCompleteTemplate(args)} ${disabledTemplate(args)}>
41
- ${args.tip ? tipDetailsTemplate(args) : ''}
42
- `;
43
+ ${args.inputtype ? inputTemplate(args) : ''}
44
+ ${args.tip ? tipDetailsTemplate(args) : ''}`;
43
45
 
44
- const InputterStandardTemplate = (args) => details.template(args, slottedContent);
46
+ const InputterStandardTemplate = (args) => details.template(args, singleTemplate);
45
47
  export const Text = InputterStandardTemplate.bind({});
46
48
  Text.args = {
47
49
  inputtype: 'text',
48
50
  label: 'Text',
49
51
  value: '',
50
52
  helper: 'Useful information to help populate this field.',
53
+ tip: '',
51
54
  validation: ['isRequired'],
52
55
  placeholder: 'e.g. Placeholder'
53
56
  };
@@ -138,7 +141,7 @@ Separator.args = {
138
141
  separator: '-'
139
142
  };
140
143
 
141
- const innerNumber = (args) => `
144
+ const innerNumber = (args) => staticHTML`
142
145
  ${args.label ? labelTemplate(args) : ''}
143
146
  <input type="${args.inputtype}" min="${args.min}" max="${args.max}">
144
147
  ${args.tip ? tipDetailsTemplate(args) : ''}
@@ -153,7 +156,7 @@ Number.args = {
153
156
  max: 10
154
157
  };
155
158
 
156
- const innerTextarea = (args) => `
159
+ const innerTextarea = (args) => staticHTML`
157
160
  <label slot="label">${args.label}</label>
158
161
  <textarea placeholder="${args.placeholder}"></textarea>
159
162
  `;
@@ -166,19 +169,25 @@ Textarea.args = {
166
169
  placeholder: 'e.g. Provide information'
167
170
  };
168
171
 
169
- const innerMultiple = (args) => `
172
+ const innerMultiple = (args) => staticHTML`
173
+ <input type="${args.inputtype}" name="${args.name}" value="${args.value}" ${unsafeStatic(args.states?.join(' ') ?? '')} id="${args.id}">
174
+ <label for="${args.id}">${unsafeStatic(args.label)}</label>
175
+ `;
176
+ const multiTemplate = (args) => staticHTML`
170
177
  ${args.options?.map((option, i) => {
171
- const states = option.states?.join(' ') ?? '';
172
178
  const id = `${args.inputtype}-${i + 1}`;
173
- return `
174
- <input type="${args.inputtype}" name="${args.name}" value="${option.value}" ${states} id="${id}">
175
- <label for="${id}">${option.label}</label>
176
- `;
177
- }).join(' ')}
179
+ return staticHTML`${innerMultiple({
180
+ ...args,
181
+ value: option.value,
182
+ label: option.label,
183
+ id,
184
+ states: option.states
185
+ })}`;
186
+ })}
178
187
  ${args.tip ? tipDetailsTemplate(args) : ''}
179
188
  `;
180
189
 
181
- const InputterMultipleTemplate = (args) => details.template(args, innerMultiple);
190
+ const InputterMultipleTemplate = (args) => details.template(args, multiTemplate);
182
191
  export const Checkbox = InputterMultipleTemplate.bind({});
183
192
  Checkbox.args = {
184
193
  inputtype: 'checkbox',
@@ -211,14 +220,14 @@ Radio.args = {
211
220
  ]
212
221
  };
213
222
 
214
- const innerSelect = (args) => `
223
+ const selectTemplate = (args) => staticHTML`
215
224
  <label slot="label">${args.label}</label>
216
225
  <select name="${args.name}">
217
- ${args.options?.map((option) => `<option value="${option.value}">${option.label}</option>`).join(' ')}
226
+ ${args.options?.map((option) => staticHTML`<option value="${option.value}">${option.label}</option>`)}
218
227
  </select>
219
228
  `;
220
229
 
221
- export const Select = (args) => details.template(args, innerSelect);
230
+ export const Select = (args) => details.template(args, selectTemplate);
222
231
  Select.args = {
223
232
  label: 'Select',
224
233
  value: '',
package/index.js CHANGED
@@ -18,7 +18,7 @@ import { cache } from 'lit/directives/cache.js';
18
18
  import { AsyncDirective } from 'lit/async-directive.js';
19
19
  import { ScopedElementsMixin } from '@open-wc/scoped-elements';
20
20
  import { dedupeMixin } from '@open-wc/dedupe-mixin';
21
- import { literal, html as staticHTML } from 'lit/static-html.js';
21
+ import { literal, html as staticHTML, unsafeStatic } from 'lit/static-html.js';
22
22
  import { until } from 'lit/directives/until.js';
23
23
  import { repeat } from 'lit/directives/repeat.js';
24
24
  import { MuonElement } from '@muonic/muon/muon-element';
@@ -43,6 +43,7 @@ export {
43
43
  dedupeMixin,
44
44
  literal,
45
45
  staticHTML,
46
+ unsafeStatic,
46
47
  until,
47
48
  noChange,
48
49
  repeat,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-123-c739cfa.0",
3
+ "version": "0.0.2-experimental-126-4fb60a6.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,3 +1,4 @@
1
+ import { staticHTML, unsafeStatic } from '@muonic/muon';
1
2
  export default (name, el) => {
2
3
  const prefix = process.env.MUON_PREFIX;
3
4
  const element = `${prefix}-${name}`;
@@ -40,7 +41,7 @@ export default (name, el) => {
40
41
  };
41
42
 
42
43
  const getTagEl = () => {
43
- return element;
44
+ return unsafeStatic(element);
44
45
  };
45
46
 
46
47
  const dynamicArgs = (args) => {
@@ -63,14 +64,14 @@ export default (name, el) => {
63
64
  }
64
65
  }).filter((arg) => arg).join(' ');
65
66
 
66
- return dArgs;
67
+ return unsafeStatic(dArgs);
67
68
  };
68
69
 
69
70
  const template = (args, inner) => {
70
71
  const tag = getTagEl();
71
72
  const dArgs = dynamicArgs(args);
72
-
73
- return `<${tag} ${dArgs}>${inner ? inner(args) : ''}</${tag}>`;
73
+ return staticHTML`
74
+ <${tag} ${dArgs}>${inner ? inner(args) : ''}</${tag}>`;
74
75
  };
75
76
 
76
77
  return {