@italia/button 0.1.0-alpha.2 → 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/custom-elements.json +20 -12
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/it-button.d.ts.map +1 -1
- package/dist/src/it-button.js +183 -122
- package/dist/src/it-button.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -5,14 +5,14 @@ This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) reco
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i
|
|
8
|
+
npm i @italia/button
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```html
|
|
14
14
|
<script type="module">
|
|
15
|
-
import '@italia/
|
|
15
|
+
import '@italia/button';
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<it-button></it-button>
|
package/custom-elements.json
CHANGED
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
"name": "ItButton",
|
|
15
15
|
"module": "./it-button.js"
|
|
16
16
|
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "js",
|
|
20
|
+
"name": "*",
|
|
21
|
+
"declaration": {
|
|
22
|
+
"name": "*",
|
|
23
|
+
"module": "src/types.js"
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
]
|
|
19
27
|
},
|
|
@@ -120,7 +128,7 @@
|
|
|
120
128
|
"type": {
|
|
121
129
|
"text": "boolean | undefined"
|
|
122
130
|
},
|
|
123
|
-
"attribute": "
|
|
131
|
+
"attribute": "disabled",
|
|
124
132
|
"reflects": true
|
|
125
133
|
},
|
|
126
134
|
{
|
|
@@ -222,7 +230,7 @@
|
|
|
222
230
|
"fieldName": "internals"
|
|
223
231
|
},
|
|
224
232
|
{
|
|
225
|
-
"name": "
|
|
233
|
+
"name": "disabled",
|
|
226
234
|
"type": {
|
|
227
235
|
"text": "boolean | undefined"
|
|
228
236
|
},
|
|
@@ -310,7 +318,7 @@
|
|
|
310
318
|
{
|
|
311
319
|
"kind": "variable",
|
|
312
320
|
"name": "meta",
|
|
313
|
-
"default": "{ title: 'Componenti/Button', tags: ['
|
|
321
|
+
"default": "{ title: 'Componenti/Button', tags: ['a11y-ok', 'web-component'], component: 'it-button', args: { slot: 'Testo del pulsante', variant: 'primary', size: undefined, block: false, outline: false, disabled: false, icon: false, type: 'button', value: '', }, argTypes: { variant: { control: 'select', description: 'Varianti di colore', options: BUTTON_VARIANTS, }, size: { control: 'select', description: 'Dimensione del pulsante', options: BUTTON_SIZES, }, block: { control: 'boolean', type: 'boolean', description: 'Quando abilitato, estende il componente Button fino a prendere tutta la larghezza disponibile', table: { defaultValue: { summary: 'false' } }, }, disabled: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, outline: { control: 'boolean', type: 'boolean', description: 'Applica il colore solamente al bordo, usando il colore di sfondo come colore interno del pulsante.', table: { defaultValue: { summary: 'false' } }, }, icon: { control: 'boolean', type: 'boolean', description: \"Se il pulsante mostra un'icona, è necessario aggiungere questo attributo.\", table: { defaultValue: { summary: 'false' } }, }, slot: { control: 'text', description: 'Testo del pulsante', }, type: { control: 'select', description: 'Tipologia di pulsante', options: ['button', 'submit', 'reset'], table: { defaultValue: { summary: 'button' } }, }, value: { control: 'text', }, }, } satisfies Meta<ButtonProps>"
|
|
314
322
|
},
|
|
315
323
|
{
|
|
316
324
|
"kind": "variable",
|
|
@@ -318,15 +326,15 @@
|
|
|
318
326
|
"type": {
|
|
319
327
|
"text": "Story"
|
|
320
328
|
},
|
|
321
|
-
"default": "{ ...meta, name: 'Esempio interattivo', args: { variant: 'primary', }, tags: ['!
|
|
329
|
+
"default": "{ ...meta, name: 'Esempio interattivo', args: { variant: 'primary', }, tags: ['!dev'], parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, render: (params) => html` ${renderComponent({ ...params, })}`, }"
|
|
322
330
|
},
|
|
323
331
|
{
|
|
324
332
|
"kind": "variable",
|
|
325
|
-
"name": "
|
|
333
|
+
"name": "Disabilitato",
|
|
326
334
|
"type": {
|
|
327
335
|
"text": "Story"
|
|
328
336
|
},
|
|
329
|
-
"default": "{ name: '
|
|
337
|
+
"default": "{ name: 'Stato disabilitato', args: { slot: '', disabled: true }, argTypes: { variant: { table: { disable: true, }, }, outline: { table: { disable: true, }, }, disabled: { table: { disable: true, }, }, }, render: (args) => html` ${renderComponent({ ...args, variant: 'primary' }, 'Primary')} ${renderComponent({ ...args, variant: 'secondary' }, 'Secondary')} ${renderComponent({ ...args, variant: 'success' }, 'Success')} ${renderComponent({ ...args, variant: 'danger' }, 'Danger')} ${renderComponent({ ...args, variant: 'warning' }, 'Warning')} ${renderComponent({ ...args, variant: 'link' }, 'Pulsante link')} `, }"
|
|
330
338
|
},
|
|
331
339
|
{
|
|
332
340
|
"kind": "variable",
|
|
@@ -334,7 +342,7 @@
|
|
|
334
342
|
"type": {
|
|
335
343
|
"text": "Story"
|
|
336
344
|
},
|
|
337
|
-
"default": "{ name: 'Varianti di colore', args: { slot: '' }, argTypes: { variant: { table: { disable: true, }, }, outline: { table: { disable: true, }, }, disabled: { table: { disable: true, }, }, },
|
|
345
|
+
"default": "{ name: 'Varianti di colore', args: { slot: '' }, argTypes: { variant: { table: { disable: true, }, }, outline: { table: { disable: true, }, }, disabled: { table: { disable: true, }, }, }, render: (args) => html` ${renderVariant({ ...args, variant: 'primary' }, 'Primary')} ${renderVariant({ ...args, variant: 'secondary' }, 'Secondary')} ${renderVariant({ ...args, variant: 'success' }, 'Success')} ${renderVariant({ ...args, variant: 'danger' }, 'Danger')} ${renderVariant({ ...args, variant: 'warning' }, 'Warning')} ${renderVariant({ ...args, variant: 'link' }, 'Pulsante link')} `, }"
|
|
338
346
|
},
|
|
339
347
|
{
|
|
340
348
|
"kind": "variable",
|
|
@@ -342,7 +350,7 @@
|
|
|
342
350
|
"type": {
|
|
343
351
|
"text": "Story"
|
|
344
352
|
},
|
|
345
|
-
"default": "{ name: 'Varianti di dimensione', args: { slot: '' }, argTypes: { variant: { table: { disable: true, }, }, size: { table: { disable: true, }, }, block: { table: { disable: true, }, }, },
|
|
353
|
+
"default": "{ name: 'Varianti di dimensione', args: { slot: '' }, argTypes: { variant: { table: { disable: true, }, }, size: { table: { disable: true, }, }, block: { table: { disable: true, }, }, }, render: (args) => html` ${renderSizeVariant({ ...args, size: 'lg' }, 'Large')} ${renderSizeVariant({ ...args }, 'Default')} ${renderSizeVariant({ ...args, size: 'xs' }, 'Extra Small')} <div class=\"flex\"> ${renderComponent( { ...args, block: true, variant: 'primary', }, 'Primary Block', )} </div> <div class=\"flex\"> ${renderComponent( { ...args, block: true, variant: 'secondary', }, 'Secondary Block', )} </div> `, }"
|
|
346
354
|
},
|
|
347
355
|
{
|
|
348
356
|
"kind": "variable",
|
|
@@ -366,7 +374,7 @@
|
|
|
366
374
|
"type": {
|
|
367
375
|
"text": "Story"
|
|
368
376
|
},
|
|
369
|
-
"default": "{ ...meta, name: 'Con icona', args: {}, argTypes: { variant: { table: { disable: true, }, }, size: { table: { disable: true, }, }, }, parameters: { docs: { description: { story: `
|
|
377
|
+
"default": "{ ...meta, name: 'Con icona', args: {}, argTypes: { variant: { table: { disable: true, }, }, size: { table: { disable: true, }, }, }, parameters: { docs: { description: { story: ` <div class=\"callout callout-success\"><div class=\"callout-inner\"><div class=\"callout-title\"><span class=\"text\">Accessibilità</span></div> <p> Le icone sono di default puramente decorative. Nel caso in cui l'icona non debba essere un elemento decorativo, è necessario utilizzare correttamente gli attributi \\`label\\`, \\`role\\` e \\`aria-hidden\\` sul componente \\`<it-icon>\\`. Per maggiori dettagli visita la [guida dedicata](?path=/docs/componenti-icon--documentazione) al componente \\`<it-icon>\\`.</p></div></div> `, }, }, }, render: (params) => { const slot = params.slot?.length > 0 ? params.slot : null; return html` <div class=\"flex align-items-center\"> <it-button variant=\"success\" size=\"lg\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <it-icon name=\"it-star-full\" color=\"inverse\" size=\"sm\"></it-icon> <span>${slot ?? 'Pulsante Large con icona'}</span> </it-button> <it-button variant=\"primary\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <it-icon name=\"it-star-full\" color=\"inverse\" size=\"sm\"></it-icon> <span>${slot ?? 'Pulsante con icona'}</span> </it-button> <it-button variant=\"danger\" size=\"xs\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <it-icon name=\"it-star-full\" color=\"inverse\" size=\"xs\"></it-icon> <span>${slot ?? 'Pulsante Extra Small con icona'}</span> </it-button> <it-button variant=\"link\" size=\"xs\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <it-icon name=\"it-star-full\" color=\"primary\" size=\"xs\"></it-icon> <span>${slot ?? 'Pulsante Link Extra Small con icona'}</span> </it-button> </div>`; }, }"
|
|
370
378
|
},
|
|
371
379
|
{
|
|
372
380
|
"kind": "variable",
|
|
@@ -374,7 +382,7 @@
|
|
|
374
382
|
"type": {
|
|
375
383
|
"text": "Story"
|
|
376
384
|
},
|
|
377
|
-
"default": "{ ...meta, name: 'Con icona cerchiata', args: {}, argTypes: { variant: { table: { disable: true, }, }, size: { table: { disable: true, }, }, },
|
|
385
|
+
"default": "{ ...meta, name: 'Con icona cerchiata', args: {}, argTypes: { variant: { table: { disable: true, }, }, size: { table: { disable: true, }, }, }, render: (params) => { const slot = params.slot?.length > 0 ? params.slot : null; return html` <div class=\"flex align-items-center\"> <it-button variant=\"success\" size=\"lg\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <span class=\"rounded-icon\"> <it-icon name=\"it-user\" color=\"success\" size=\"xs\"></it-icon> </span> <span>${slot ?? 'Pulsante Large con icona'}</span> </it-button> <it-button variant=\"primary\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <span class=\"rounded-icon\" size=\"sm\"> <it-icon name=\"it-user\" color=\"primary\" size=\"xs\"></it-icon> </span> <span>${slot ?? 'Pulsante con icona'}</span> </it-button> <it-button variant=\"danger\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <span class=\"rounded-icon\"> <it-icon name=\"it-user\" color=\"danger\" size=\"xs\"></it-icon> </span> <span>${slot ?? 'Pulsante Small con icona'}</span> </it-button> <it-button variant=\"secondary\" size=\"xs\" icon ?outline=\"${params.outline}\" ?block=\"${params.block}\" ?disabled=\"${params.disabled}\" type=\"${params.type}\" > <span class=\"rounded-icon\"> <it-icon name=\"it-user\" color=\"secondary\" size=\"xs\"></it-icon> </span> <span>${slot ?? 'Pulsante Link Extra Small con icona'}</span> </it-button> </div>`; }, }"
|
|
378
386
|
}
|
|
379
387
|
],
|
|
380
388
|
"exports": [
|
|
@@ -396,9 +404,9 @@
|
|
|
396
404
|
},
|
|
397
405
|
{
|
|
398
406
|
"kind": "js",
|
|
399
|
-
"name": "
|
|
407
|
+
"name": "Disabilitato",
|
|
400
408
|
"declaration": {
|
|
401
|
-
"name": "
|
|
409
|
+
"name": "Disabilitato",
|
|
402
410
|
"module": "stories/it-button.stories.ts"
|
|
403
411
|
}
|
|
404
412
|
},
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,cAAc,YAAY,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -3,4 +3,9 @@ import 'lit/directive.js';
|
|
|
3
3
|
import 'lit';
|
|
4
4
|
import 'lit/decorators.js';
|
|
5
5
|
import 'lit/directives/if-defined.js';
|
|
6
|
+
|
|
7
|
+
const BUTTON_SIZES = ['lg', 'sm', 'xs'];
|
|
8
|
+
const BUTTON_VARIANTS = ['primary', 'secondary', 'success', 'danger', 'warning', 'link'];
|
|
9
|
+
|
|
10
|
+
export { BUTTON_SIZES, BUTTON_VARIANTS };
|
|
6
11
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/types.ts"],"sourcesContent":["export const BUTTON_SIZES = ['lg', 'sm', 'xs'];\nexport const BUTTON_VARIANTS = ['primary', 'secondary', 'success', 'danger', 'warning', 'link'];\n\nexport type Sizes = (typeof BUTTON_SIZES)[number];\nexport type Variants = (typeof BUTTON_VARIANTS)[number] | string;\n"],"names":[],"mappings":";;;;;;AAAO,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI;AACtC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-button.d.ts","sourceRoot":"","sources":["../../src/it-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,iBAAiB,CAAC;AAI/D,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,EA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