@nordhealth/components 2.16.1-alpha.0 → 2.16.1-alpha.2
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/custom-elements.json +216 -221
- package/lib/Button.js +1 -1
- package/lib/Button.js.map +1 -1
- package/lib/{Calendar-2cc56879.js → Calendar-88644376.js} +1 -1
- package/lib/{Calendar-2cc56879.js.map → Calendar-88644376.js.map} +1 -1
- package/lib/Calendar.js +1 -1
- package/lib/DatePicker.js +1 -1
- package/lib/Layout.js +1 -1
- package/lib/Layout.js.map +1 -1
- package/lib/NavGroup.js +1 -1
- package/lib/NavGroup.js.map +1 -1
- package/lib/Navigation.js +1 -1
- package/lib/Navigation.js.map +1 -1
- package/lib/bundle.js +3 -3
- package/lib/bundle.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/src/button/Button.d.ts +0 -1
- package/package.json +2 -2
package/custom-elements.json
CHANGED
|
@@ -674,128 +674,6 @@
|
|
|
674
674
|
}
|
|
675
675
|
]
|
|
676
676
|
},
|
|
677
|
-
{
|
|
678
|
-
"kind": "javascript-module",
|
|
679
|
-
"path": "src/button-group/ButtonGroup.ts",
|
|
680
|
-
"declarations": [
|
|
681
|
-
{
|
|
682
|
-
"kind": "class",
|
|
683
|
-
"description": "Button groups are designed to bring together button controls that are of a similar nature. For example text formatting controls.",
|
|
684
|
-
"name": "ButtonGroup",
|
|
685
|
-
"cssProperties": [
|
|
686
|
-
{
|
|
687
|
-
"description": "Controls the rounded corners of the button, using [border radius tokens](/tokens/#border-radius).",
|
|
688
|
-
"name": "--n-button-group-border-radius",
|
|
689
|
-
"default": "var(--n-border-radius-s)"
|
|
690
|
-
},
|
|
691
|
-
{
|
|
692
|
-
"description": "Controls the surrounding shadow, using [box shadow tokens](/tokens/#box-shadow).",
|
|
693
|
-
"name": "--n-button-group-box-shadow",
|
|
694
|
-
"default": "var(--n-box-shadow)"
|
|
695
|
-
}
|
|
696
|
-
],
|
|
697
|
-
"slots": [
|
|
698
|
-
{
|
|
699
|
-
"description": "The button group content",
|
|
700
|
-
"name": ""
|
|
701
|
-
}
|
|
702
|
-
],
|
|
703
|
-
"members": [
|
|
704
|
-
{
|
|
705
|
-
"kind": "field",
|
|
706
|
-
"name": "direction",
|
|
707
|
-
"type": {
|
|
708
|
-
"text": "\"vertical\" | \"horizontal\""
|
|
709
|
-
},
|
|
710
|
-
"default": "\"horizontal\"",
|
|
711
|
-
"description": "The direction of the button group.",
|
|
712
|
-
"attribute": "direction",
|
|
713
|
-
"reflects": true
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
"kind": "field",
|
|
717
|
-
"name": "role",
|
|
718
|
-
"type": {
|
|
719
|
-
"text": "string"
|
|
720
|
-
},
|
|
721
|
-
"default": "\"group\"",
|
|
722
|
-
"description": "The appropriate role for the containing element.",
|
|
723
|
-
"attribute": "role",
|
|
724
|
-
"reflects": true
|
|
725
|
-
},
|
|
726
|
-
{
|
|
727
|
-
"kind": "field",
|
|
728
|
-
"name": "_warningLogged",
|
|
729
|
-
"type": {
|
|
730
|
-
"text": "boolean"
|
|
731
|
-
},
|
|
732
|
-
"privacy": "private",
|
|
733
|
-
"static": true,
|
|
734
|
-
"default": "false",
|
|
735
|
-
"inheritedFrom": {
|
|
736
|
-
"name": "DraftComponentMixin",
|
|
737
|
-
"module": "src/common/mixins/DraftComponentMixin.ts"
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
],
|
|
741
|
-
"attributes": [
|
|
742
|
-
{
|
|
743
|
-
"name": "direction",
|
|
744
|
-
"type": {
|
|
745
|
-
"text": "\"vertical\" | \"horizontal\""
|
|
746
|
-
},
|
|
747
|
-
"default": "\"horizontal\"",
|
|
748
|
-
"description": "The direction of the button group.",
|
|
749
|
-
"fieldName": "direction"
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
"name": "role",
|
|
753
|
-
"type": {
|
|
754
|
-
"text": "string"
|
|
755
|
-
},
|
|
756
|
-
"default": "\"group\"",
|
|
757
|
-
"description": "The appropriate role for the containing element.",
|
|
758
|
-
"fieldName": "role"
|
|
759
|
-
}
|
|
760
|
-
],
|
|
761
|
-
"mixins": [
|
|
762
|
-
{
|
|
763
|
-
"name": "DraftComponentMixin",
|
|
764
|
-
"module": "/src/common/mixins/DraftComponentMixin.js"
|
|
765
|
-
}
|
|
766
|
-
],
|
|
767
|
-
"superclass": {
|
|
768
|
-
"name": "LitElement",
|
|
769
|
-
"package": "lit"
|
|
770
|
-
},
|
|
771
|
-
"localization": [],
|
|
772
|
-
"status": "draft",
|
|
773
|
-
"category": "structure",
|
|
774
|
-
"readme": "## Usage\n\nThis section includes guidelines for designers and developers about the usage of this component in different contexts.\n\n<div class=\"n-usage n-usage-do\">\n\n### Do\n\n- Use to group together buttons, or dropdowns, of a similar nature or purpose.\n- Use the appropriate `role` attribute on the button group to provide additional semantics.\n- Use an `aria-labelledby` attribute referencing another element to best explain the contents of the button group.\n\n</div>\n<div class=\"n-usage n-usage-dont\">\n\n### Don’t\n\n- Don’t add components other than buttons, dropdowns and in some instances visually hidden components to the button group.\n- Don’t skip the addition of an appropriate label if the added `role` attribute value calls for it.\n- Don’t use for building grid based layouts.\n\n</div>\n\n---\n\n## Content guidelines\n\nButton group labels should be accurate and predictable.\n",
|
|
775
|
-
"examples": [],
|
|
776
|
-
"tagName": "nord-button-group",
|
|
777
|
-
"customElement": true
|
|
778
|
-
}
|
|
779
|
-
],
|
|
780
|
-
"exports": [
|
|
781
|
-
{
|
|
782
|
-
"kind": "js",
|
|
783
|
-
"name": "default",
|
|
784
|
-
"declaration": {
|
|
785
|
-
"name": "ButtonGroup",
|
|
786
|
-
"module": "src/button-group/ButtonGroup.ts"
|
|
787
|
-
}
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
"kind": "custom-element-definition",
|
|
791
|
-
"name": "nord-button-group",
|
|
792
|
-
"declaration": {
|
|
793
|
-
"name": "ButtonGroup",
|
|
794
|
-
"module": "src/button-group/ButtonGroup.ts"
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
]
|
|
798
|
-
},
|
|
799
677
|
{
|
|
800
678
|
"kind": "javascript-module",
|
|
801
679
|
"path": "src/banner/Banner.ts",
|
|
@@ -946,11 +824,6 @@
|
|
|
946
824
|
"description": "Controls the minimum block size, or height, of the button using our [spacing tokens](/tokens/#space).",
|
|
947
825
|
"name": "--n-button-min-block-size",
|
|
948
826
|
"default": "var(--n-space-xl)"
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
"description": "Controls the color of the dropdown icon, using our [color tokens](/tokens/#color).",
|
|
952
|
-
"name": "--n-button-dropdown-icon-color",
|
|
953
|
-
"default": "var(--n-color-icon)"
|
|
954
827
|
}
|
|
955
828
|
],
|
|
956
829
|
"slots": [
|
|
@@ -1423,6 +1296,128 @@
|
|
|
1423
1296
|
}
|
|
1424
1297
|
]
|
|
1425
1298
|
},
|
|
1299
|
+
{
|
|
1300
|
+
"kind": "javascript-module",
|
|
1301
|
+
"path": "src/button-group/ButtonGroup.ts",
|
|
1302
|
+
"declarations": [
|
|
1303
|
+
{
|
|
1304
|
+
"kind": "class",
|
|
1305
|
+
"description": "Button groups are designed to bring together button controls that are of a similar nature. For example text formatting controls.",
|
|
1306
|
+
"name": "ButtonGroup",
|
|
1307
|
+
"cssProperties": [
|
|
1308
|
+
{
|
|
1309
|
+
"description": "Controls the rounded corners of the button, using [border radius tokens](/tokens/#border-radius).",
|
|
1310
|
+
"name": "--n-button-group-border-radius",
|
|
1311
|
+
"default": "var(--n-border-radius-s)"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
"description": "Controls the surrounding shadow, using [box shadow tokens](/tokens/#box-shadow).",
|
|
1315
|
+
"name": "--n-button-group-box-shadow",
|
|
1316
|
+
"default": "var(--n-box-shadow)"
|
|
1317
|
+
}
|
|
1318
|
+
],
|
|
1319
|
+
"slots": [
|
|
1320
|
+
{
|
|
1321
|
+
"description": "The button group content",
|
|
1322
|
+
"name": ""
|
|
1323
|
+
}
|
|
1324
|
+
],
|
|
1325
|
+
"members": [
|
|
1326
|
+
{
|
|
1327
|
+
"kind": "field",
|
|
1328
|
+
"name": "direction",
|
|
1329
|
+
"type": {
|
|
1330
|
+
"text": "\"vertical\" | \"horizontal\""
|
|
1331
|
+
},
|
|
1332
|
+
"default": "\"horizontal\"",
|
|
1333
|
+
"description": "The direction of the button group.",
|
|
1334
|
+
"attribute": "direction",
|
|
1335
|
+
"reflects": true
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
"kind": "field",
|
|
1339
|
+
"name": "role",
|
|
1340
|
+
"type": {
|
|
1341
|
+
"text": "string"
|
|
1342
|
+
},
|
|
1343
|
+
"default": "\"group\"",
|
|
1344
|
+
"description": "The appropriate role for the containing element.",
|
|
1345
|
+
"attribute": "role",
|
|
1346
|
+
"reflects": true
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
"kind": "field",
|
|
1350
|
+
"name": "_warningLogged",
|
|
1351
|
+
"type": {
|
|
1352
|
+
"text": "boolean"
|
|
1353
|
+
},
|
|
1354
|
+
"privacy": "private",
|
|
1355
|
+
"static": true,
|
|
1356
|
+
"default": "false",
|
|
1357
|
+
"inheritedFrom": {
|
|
1358
|
+
"name": "DraftComponentMixin",
|
|
1359
|
+
"module": "src/common/mixins/DraftComponentMixin.ts"
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
],
|
|
1363
|
+
"attributes": [
|
|
1364
|
+
{
|
|
1365
|
+
"name": "direction",
|
|
1366
|
+
"type": {
|
|
1367
|
+
"text": "\"vertical\" | \"horizontal\""
|
|
1368
|
+
},
|
|
1369
|
+
"default": "\"horizontal\"",
|
|
1370
|
+
"description": "The direction of the button group.",
|
|
1371
|
+
"fieldName": "direction"
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
"name": "role",
|
|
1375
|
+
"type": {
|
|
1376
|
+
"text": "string"
|
|
1377
|
+
},
|
|
1378
|
+
"default": "\"group\"",
|
|
1379
|
+
"description": "The appropriate role for the containing element.",
|
|
1380
|
+
"fieldName": "role"
|
|
1381
|
+
}
|
|
1382
|
+
],
|
|
1383
|
+
"mixins": [
|
|
1384
|
+
{
|
|
1385
|
+
"name": "DraftComponentMixin",
|
|
1386
|
+
"module": "/src/common/mixins/DraftComponentMixin.js"
|
|
1387
|
+
}
|
|
1388
|
+
],
|
|
1389
|
+
"superclass": {
|
|
1390
|
+
"name": "LitElement",
|
|
1391
|
+
"package": "lit"
|
|
1392
|
+
},
|
|
1393
|
+
"localization": [],
|
|
1394
|
+
"status": "draft",
|
|
1395
|
+
"category": "structure",
|
|
1396
|
+
"readme": "## Usage\n\nThis section includes guidelines for designers and developers about the usage of this component in different contexts.\n\n<div class=\"n-usage n-usage-do\">\n\n### Do\n\n- Use to group together buttons, or dropdowns, of a similar nature or purpose.\n- Use the appropriate `role` attribute on the button group to provide additional semantics.\n- Use an `aria-labelledby` attribute referencing another element to best explain the contents of the button group.\n\n</div>\n<div class=\"n-usage n-usage-dont\">\n\n### Don’t\n\n- Don’t add components other than buttons, dropdowns and in some instances visually hidden components to the button group.\n- Don’t skip the addition of an appropriate label if the added `role` attribute value calls for it.\n- Don’t use for building grid based layouts.\n\n</div>\n\n---\n\n## Content guidelines\n\nButton group labels should be accurate and predictable.\n",
|
|
1397
|
+
"examples": [],
|
|
1398
|
+
"tagName": "nord-button-group",
|
|
1399
|
+
"customElement": true
|
|
1400
|
+
}
|
|
1401
|
+
],
|
|
1402
|
+
"exports": [
|
|
1403
|
+
{
|
|
1404
|
+
"kind": "js",
|
|
1405
|
+
"name": "default",
|
|
1406
|
+
"declaration": {
|
|
1407
|
+
"name": "ButtonGroup",
|
|
1408
|
+
"module": "src/button-group/ButtonGroup.ts"
|
|
1409
|
+
}
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
"kind": "custom-element-definition",
|
|
1413
|
+
"name": "nord-button-group",
|
|
1414
|
+
"declaration": {
|
|
1415
|
+
"name": "ButtonGroup",
|
|
1416
|
+
"module": "src/button-group/ButtonGroup.ts"
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
]
|
|
1420
|
+
},
|
|
1426
1421
|
{
|
|
1427
1422
|
"kind": "javascript-module",
|
|
1428
1423
|
"path": "src/calendar/Calendar.ts",
|
|
@@ -12612,6 +12607,100 @@
|
|
|
12612
12607
|
}
|
|
12613
12608
|
]
|
|
12614
12609
|
},
|
|
12610
|
+
{
|
|
12611
|
+
"kind": "javascript-module",
|
|
12612
|
+
"path": "src/tab/Tab.ts",
|
|
12613
|
+
"declarations": [
|
|
12614
|
+
{
|
|
12615
|
+
"kind": "class",
|
|
12616
|
+
"description": "The interactive tab button for use within the tab group component.",
|
|
12617
|
+
"name": "Tab",
|
|
12618
|
+
"cssProperties": [
|
|
12619
|
+
{
|
|
12620
|
+
"description": "Controls the text color of the tab, using our [color tokens](/tokens/#color).",
|
|
12621
|
+
"name": "--n-tab-color",
|
|
12622
|
+
"default": "var(--n-color-text-weak)"
|
|
12623
|
+
},
|
|
12624
|
+
{
|
|
12625
|
+
"description": "Controls the font weight of the tab, using our [font tokens](/tokens/#font).",
|
|
12626
|
+
"name": "--n-tab-font-weight",
|
|
12627
|
+
"default": "var(--n-font-weight)"
|
|
12628
|
+
}
|
|
12629
|
+
],
|
|
12630
|
+
"slots": [
|
|
12631
|
+
{
|
|
12632
|
+
"description": "The tab button content.",
|
|
12633
|
+
"name": ""
|
|
12634
|
+
}
|
|
12635
|
+
],
|
|
12636
|
+
"members": [
|
|
12637
|
+
{
|
|
12638
|
+
"kind": "field",
|
|
12639
|
+
"name": "defaultSlot",
|
|
12640
|
+
"privacy": "private",
|
|
12641
|
+
"default": "new SlotController(this)"
|
|
12642
|
+
},
|
|
12643
|
+
{
|
|
12644
|
+
"kind": "field",
|
|
12645
|
+
"name": "selected",
|
|
12646
|
+
"type": {
|
|
12647
|
+
"text": "boolean"
|
|
12648
|
+
},
|
|
12649
|
+
"default": "false",
|
|
12650
|
+
"description": "Whether the tab item is selected",
|
|
12651
|
+
"attribute": "selected",
|
|
12652
|
+
"reflects": true
|
|
12653
|
+
},
|
|
12654
|
+
{
|
|
12655
|
+
"kind": "method",
|
|
12656
|
+
"name": "handleSelectionChange",
|
|
12657
|
+
"privacy": "protected",
|
|
12658
|
+
"description": "Apply accessible attributes and values to the tab button.\nObserve the selected property if it changes"
|
|
12659
|
+
}
|
|
12660
|
+
],
|
|
12661
|
+
"attributes": [
|
|
12662
|
+
{
|
|
12663
|
+
"name": "selected",
|
|
12664
|
+
"type": {
|
|
12665
|
+
"text": "boolean"
|
|
12666
|
+
},
|
|
12667
|
+
"default": "false",
|
|
12668
|
+
"description": "Whether the tab item is selected",
|
|
12669
|
+
"fieldName": "selected"
|
|
12670
|
+
}
|
|
12671
|
+
],
|
|
12672
|
+
"superclass": {
|
|
12673
|
+
"name": "LitElement",
|
|
12674
|
+
"package": "lit"
|
|
12675
|
+
},
|
|
12676
|
+
"localization": [],
|
|
12677
|
+
"status": "ready",
|
|
12678
|
+
"category": "navigation",
|
|
12679
|
+
"readme": "## Usage\n\nThis section includes guidelines for designers and developers about the usage of this component in different contexts.\n\n<div class=\"n-usage n-usage-do\">\n\n### Do\n\n- Use the tab component within the tab group component.\n- Use the `selected` option to signify if the tab is selected.\n- Use text, icons and other non-interactive content within the tab.\n\n</div>\n<div class=\"n-usage n-usage-dont\">\n\n### Don’t\n\n- Don’t use tabs to navigate to other pages. Use navigation or links instead.\n- Don't use the tab component outside of the tab group component.\n- Don't add interactive elements, such as buttons and links, inside the tab component.\n\n</div>\n\n---\n\n## Content guidelines\n\nWhen writing tab labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):\n\n<div class=\"n-usage n-usage-do\">My tasks</div>\n<div class=\"n-usage n-usage-dont\">My Tasks</div>\n\nAvoid unnecessary words and articles in tab labels, such as “the”, “an” or “a”:\n\n<div class=\"n-usage n-usage-do\">Dashboard</div>\n<div class=\"n-usage n-usage-dont\">The dashboard</div>\n\nAvoid ending tab labels in punctuation:\n\n<div class=\"n-usage n-usage-do\">Patients</div>\n<div class=\"n-usage n-usage-dont\">Patients.</div>\n\nUse as few words as possible to describe each tab label:\n\n<div class=\"n-usage n-usage-do\">Payments</div>\n<div class=\"n-usage n-usage-dont\">Payments in your clinic</div>\n\nAvoid all caps for tab labels:\n\n<div class=\"n-usage n-usage-do\">Dashboard</div>\n<div class=\"n-usage n-usage-dont\">DASHBOARD</div>\n\n---\n\n## Additional considerations\n\n- If the content contained within the tabs UI has significance or is important for the user to see, consider using a different form of presentation that doesn't obscure it.\n- If there is a particular section you wish to show out of order of the tabs UI itself consider using the `selected` option to select the tab but prevent the order of the tabs being affected.\n",
|
|
12680
|
+
"examples": [],
|
|
12681
|
+
"tagName": "nord-tab",
|
|
12682
|
+
"customElement": true
|
|
12683
|
+
}
|
|
12684
|
+
],
|
|
12685
|
+
"exports": [
|
|
12686
|
+
{
|
|
12687
|
+
"kind": "js",
|
|
12688
|
+
"name": "default",
|
|
12689
|
+
"declaration": {
|
|
12690
|
+
"name": "Tab",
|
|
12691
|
+
"module": "src/tab/Tab.ts"
|
|
12692
|
+
}
|
|
12693
|
+
},
|
|
12694
|
+
{
|
|
12695
|
+
"kind": "custom-element-definition",
|
|
12696
|
+
"name": "nord-tab",
|
|
12697
|
+
"declaration": {
|
|
12698
|
+
"name": "Tab",
|
|
12699
|
+
"module": "src/tab/Tab.ts"
|
|
12700
|
+
}
|
|
12701
|
+
}
|
|
12702
|
+
]
|
|
12703
|
+
},
|
|
12615
12704
|
{
|
|
12616
12705
|
"kind": "javascript-module",
|
|
12617
12706
|
"path": "src/tab-group/TabGroup.ts",
|
|
@@ -12854,100 +12943,6 @@
|
|
|
12854
12943
|
}
|
|
12855
12944
|
]
|
|
12856
12945
|
},
|
|
12857
|
-
{
|
|
12858
|
-
"kind": "javascript-module",
|
|
12859
|
-
"path": "src/tab/Tab.ts",
|
|
12860
|
-
"declarations": [
|
|
12861
|
-
{
|
|
12862
|
-
"kind": "class",
|
|
12863
|
-
"description": "The interactive tab button for use within the tab group component.",
|
|
12864
|
-
"name": "Tab",
|
|
12865
|
-
"cssProperties": [
|
|
12866
|
-
{
|
|
12867
|
-
"description": "Controls the text color of the tab, using our [color tokens](/tokens/#color).",
|
|
12868
|
-
"name": "--n-tab-color",
|
|
12869
|
-
"default": "var(--n-color-text-weak)"
|
|
12870
|
-
},
|
|
12871
|
-
{
|
|
12872
|
-
"description": "Controls the font weight of the tab, using our [font tokens](/tokens/#font).",
|
|
12873
|
-
"name": "--n-tab-font-weight",
|
|
12874
|
-
"default": "var(--n-font-weight)"
|
|
12875
|
-
}
|
|
12876
|
-
],
|
|
12877
|
-
"slots": [
|
|
12878
|
-
{
|
|
12879
|
-
"description": "The tab button content.",
|
|
12880
|
-
"name": ""
|
|
12881
|
-
}
|
|
12882
|
-
],
|
|
12883
|
-
"members": [
|
|
12884
|
-
{
|
|
12885
|
-
"kind": "field",
|
|
12886
|
-
"name": "defaultSlot",
|
|
12887
|
-
"privacy": "private",
|
|
12888
|
-
"default": "new SlotController(this)"
|
|
12889
|
-
},
|
|
12890
|
-
{
|
|
12891
|
-
"kind": "field",
|
|
12892
|
-
"name": "selected",
|
|
12893
|
-
"type": {
|
|
12894
|
-
"text": "boolean"
|
|
12895
|
-
},
|
|
12896
|
-
"default": "false",
|
|
12897
|
-
"description": "Whether the tab item is selected",
|
|
12898
|
-
"attribute": "selected",
|
|
12899
|
-
"reflects": true
|
|
12900
|
-
},
|
|
12901
|
-
{
|
|
12902
|
-
"kind": "method",
|
|
12903
|
-
"name": "handleSelectionChange",
|
|
12904
|
-
"privacy": "protected",
|
|
12905
|
-
"description": "Apply accessible attributes and values to the tab button.\nObserve the selected property if it changes"
|
|
12906
|
-
}
|
|
12907
|
-
],
|
|
12908
|
-
"attributes": [
|
|
12909
|
-
{
|
|
12910
|
-
"name": "selected",
|
|
12911
|
-
"type": {
|
|
12912
|
-
"text": "boolean"
|
|
12913
|
-
},
|
|
12914
|
-
"default": "false",
|
|
12915
|
-
"description": "Whether the tab item is selected",
|
|
12916
|
-
"fieldName": "selected"
|
|
12917
|
-
}
|
|
12918
|
-
],
|
|
12919
|
-
"superclass": {
|
|
12920
|
-
"name": "LitElement",
|
|
12921
|
-
"package": "lit"
|
|
12922
|
-
},
|
|
12923
|
-
"localization": [],
|
|
12924
|
-
"status": "ready",
|
|
12925
|
-
"category": "navigation",
|
|
12926
|
-
"readme": "## Usage\n\nThis section includes guidelines for designers and developers about the usage of this component in different contexts.\n\n<div class=\"n-usage n-usage-do\">\n\n### Do\n\n- Use the tab component within the tab group component.\n- Use the `selected` option to signify if the tab is selected.\n- Use text, icons and other non-interactive content within the tab.\n\n</div>\n<div class=\"n-usage n-usage-dont\">\n\n### Don’t\n\n- Don’t use tabs to navigate to other pages. Use navigation or links instead.\n- Don't use the tab component outside of the tab group component.\n- Don't add interactive elements, such as buttons and links, inside the tab component.\n\n</div>\n\n---\n\n## Content guidelines\n\nWhen writing tab labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):\n\n<div class=\"n-usage n-usage-do\">My tasks</div>\n<div class=\"n-usage n-usage-dont\">My Tasks</div>\n\nAvoid unnecessary words and articles in tab labels, such as “the”, “an” or “a”:\n\n<div class=\"n-usage n-usage-do\">Dashboard</div>\n<div class=\"n-usage n-usage-dont\">The dashboard</div>\n\nAvoid ending tab labels in punctuation:\n\n<div class=\"n-usage n-usage-do\">Patients</div>\n<div class=\"n-usage n-usage-dont\">Patients.</div>\n\nUse as few words as possible to describe each tab label:\n\n<div class=\"n-usage n-usage-do\">Payments</div>\n<div class=\"n-usage n-usage-dont\">Payments in your clinic</div>\n\nAvoid all caps for tab labels:\n\n<div class=\"n-usage n-usage-do\">Dashboard</div>\n<div class=\"n-usage n-usage-dont\">DASHBOARD</div>\n\n---\n\n## Additional considerations\n\n- If the content contained within the tabs UI has significance or is important for the user to see, consider using a different form of presentation that doesn't obscure it.\n- If there is a particular section you wish to show out of order of the tabs UI itself consider using the `selected` option to select the tab but prevent the order of the tabs being affected.\n",
|
|
12927
|
-
"examples": [],
|
|
12928
|
-
"tagName": "nord-tab",
|
|
12929
|
-
"customElement": true
|
|
12930
|
-
}
|
|
12931
|
-
],
|
|
12932
|
-
"exports": [
|
|
12933
|
-
{
|
|
12934
|
-
"kind": "js",
|
|
12935
|
-
"name": "default",
|
|
12936
|
-
"declaration": {
|
|
12937
|
-
"name": "Tab",
|
|
12938
|
-
"module": "src/tab/Tab.ts"
|
|
12939
|
-
}
|
|
12940
|
-
},
|
|
12941
|
-
{
|
|
12942
|
-
"kind": "custom-element-definition",
|
|
12943
|
-
"name": "nord-tab",
|
|
12944
|
-
"declaration": {
|
|
12945
|
-
"name": "Tab",
|
|
12946
|
-
"module": "src/tab/Tab.ts"
|
|
12947
|
-
}
|
|
12948
|
-
}
|
|
12949
|
-
]
|
|
12950
|
-
},
|
|
12951
12946
|
{
|
|
12952
12947
|
"kind": "javascript-module",
|
|
12953
12948
|
"path": "src/tab-panel/TabPanel.ts",
|
package/lib/Button.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as t,y as n,b as o,_ as r,e as a,s as e}from"./query-assigned-elements-cf502539.js";import{e as i}from"./property-03f59dce.js";import{e as s,n as b}from"./ref-c44e9f3c.js";import{E as l}from"./EventController-d99ebeef.js";import{L as d}from"./LightDomController-052f446a.js";import{c}from"./cond-2da54107.js";import"./Spinner.js";import{F as u}from"./FocusableMixin-32631bff.js";import{I as v}from"./InputMixin-7fa755e1.js";import{s as h}from"./Component-449e40fb.js";import{S as p}from"./SlotController-d733c575.js";import"./directive-de55b00a.js";import"./if-defined-720964c0.js";const g=t`:host{--_n-button-border-radius:var(--n-button-border-radius, var(--n-border-radius-s));--_n-button-gap:var(--n-button-gap, var(--n-space-s));--_n-button-gradient:var(--n-button-gradient, linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.013) 100%));--_n-button-background-color:var(--n-button-background-color, var(--n-color-button));--_n-button-border-color:var(--n-button-border-color, var(--n-color-border-strong));--_n-button-text-align:var(--n-button-text-align, center);--_n-button-box-shadow:var(--n-button-box-shadow, var(--n-box-shadow));--_n-button-color:var(--n-button-color, var(--n-color-text));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-m) / 1.2));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-m));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight));--_n-button-min-block-size:var(--n-button-min-block-size, var(--n-space-xl));--_n-button-dropdown-icon-color:var(--n-button-dropdown-icon-color, var(--n-color-icon));--_n-button-opacity:1;--_n-button-border-style:solid;--_n-button-inline-size:fit-content;--_n-button-padding-block:calc(var(--n-space-s) / 1.6);--_n-button-icon-size:var(--n-size-icon-s);display:inline-block}.n-button{-webkit-appearance:none;align-items:center;appearance:none;background:var(--_n-button-background-color);opacity:var(--_n-button-opacity);border-radius:var(--_n-button-border-radius);border:1px var(--_n-button-border-style) var(--_n-button-border-color);box-shadow:var(--_n-button-box-shadow);color:var(--_n-button-color);cursor:pointer;display:flex;gap:var(--_n-button-gap);font-family:var(--n-font-family);font-feature-settings:var(--n-font-features);font-size:var(--_n-button-font-size);font-weight:var(--_n-button-font-weight);line-height:var(--n-line-height-form);margin:0;min-block-size:var(--_n-button-min-block-size);padding:var(--_n-button-padding-block) var(--_n-button-padding-inline);text-align:var(--_n-button-text-align);text-decoration:none;transition:.1s ease;transition-property:background-color,opacity,color,box-shadow,border-color;-webkit-user-select:none;user-select:none;position:relative;inline-size:var(--_n-button-inline-size)}.n-button::after{content:"";position:absolute;background:0 0;background-image:var(--_n-button-gradient);border-radius:var(--_n-button-border-radius);background-repeat:repeat-x;inline-size:100%;inset-inline:0;block-size:100%;inset-block-start:0}:host([expand]){--_n-button-inline-size:100%;display:block}.n-content{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;position:relative}.n-button:hover{--_n-button-border-color:var(--n-button-border-color, var(--n-color-border-hover));--_n-button-background-color:var(--n-button-background-color, var(--n-color-button-hover))}.n-button:focus{--_n-button-border-color:var(--n-button-border-color, var(--n-color-accent));--_n-button-border-style:solid;--_n-button-box-shadow:0 0 0 1px var(--n-color-accent),var(--n-box-shadow);outline:0}.n-button:active{opacity:.8;transform:translateY(1px);transition:none}:host([variant=primary]){--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-on-accent));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-active))}:host([variant=primary]),:host([variant=primary]) .n-button:hover{--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-background-color:var(--n-button-background-color, var(--n-color-accent))}:host([variant=primary]) .n-button:hover{filter:brightness(93%)}:host([variant=primary]) .n-button:focus{--_n-button-box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--_n-button-border-color)}:host([variant=dashed]){--_n-button-border-color:var(--n-button-border-color, var(--n-color-border-hover));--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-weaker));--_n-button-border-style:dashed}:host([variant=dashed]) .n-button:hover{--_n-button-color:var(--n-button-color, var(--n-color-text))}:host([variant=dashed]) .n-button::after{display:none}:host([variant=plain]){--_n-button-box-shadow:var(--n-button-box-shadow, none)}:host([variant=plain]),:host([variant=plain]) .n-button:hover{--_n-button-border-color:var(--n-button-border-color, transparent)}:host([variant=plain]) .n-button::after{display:none}:host([variant=danger]){--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-on-accent));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-active))}:host([variant=danger]),:host([variant=danger]) .n-button:hover{--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-background-color:var(--n-button-background-color, var(--n-color-status-danger))}:host([variant=danger]) .n-button:hover{filter:brightness(93%)}:host([variant=danger]) .n-button:focus{--_n-button-border-color:var(--n-button-border-color, var(--n-color-status-danger));--_n-button-box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--n-color-status-danger)}:host([variant=switch]){--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-text-align:var(--n-button-text-align, start);--_n-button-background-color:var(--n-button-background-color, transparent);--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-gradient:var(--n-button-gradient, none);--_n-button-color:var(--n-button-color, var(--n-color-text));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-s) / 2));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-heading));--_n-button-font-size:var(--n-button-font-size, var(--n-n-font-size-l));--_n-button-min-block-size:var(--n-button-min-block-size, calc(var(--n-space-xxl) - 1px));--_n-button-icon-size:var(--n-size-icon-s);display:flex;align-items:center}:host([variant=switch][size="l"]){--_n-button-border-radius:var(--n-button-border-radius, var(--n-border-radius-sharp));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-l) / 2));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-heading));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-l));--_n-button-min-block-size:var(--n-button-min-block-size, calc(var(--n-space-xxl) - 1px))}:host([variant=switch]) .n-button *{pointer-events:none}:host([variant=switch]) .n-button::after{display:none}:host([variant=switch]) .n-button:hover,:host([variant=switch][aria-expanded=true]) .n-button{--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-background-color:var(--n-button-background-color, var(--n-color-nav-hover))}:host([variant=switch]) .n-button:focus{--_n-button-box-shadow:inset 0 0 0 1px var(--_n-button-border-color)}:host([variant=switch]) slot[name=end] nord-icon{color:var(--_n-button-dropdown-icon-color);margin-inline-end:var(--n-space-s)}:host([disabled]){--_n-button-border-color:var(--n-button-border-color, var(--_n-button-background-color));--_n-button-background-color:var(--n-button-background-color, var(--n-color-border));--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-weaker));--_n-button-opacity:0.5;pointer-events:none}:host([disabled]) .n-button::after{display:none}.n-button-spinner{position:absolute;transform:translateX(-50%) translateY(-50%);inset-block-start:50%;inset-inline-start:50%}:host([loading]:not([href])){pointer-events:none}:host([loading]:not([href])) .n-content,:host([loading]:not([href])) ::slotted([slot=end]),:host([loading]:not([href])) ::slotted([slot=start]){opacity:0}:host([size="s"]){--_n-button-gap:var(--n-button-gap, calc(var(--n-space-s) / 2));--_n-button-padding-inline:var(--n-button-padding-inline, var(--n-space-s));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-s));--_n-button-min-block-size:var(--n-button-min-block-size, var(--n-space-l));--_n-button-padding-block:calc(var(--n-space-s) / 1.5);--_n-button-icon-size:var(--n-size-icon-xs)}:host([size="s"]) .n-button{line-height:var(--n-line-height-tight)}:host([size="l"]){--_n-button-border-radius:var(--n-button-border-radius, var(--n-border-radius));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-l) / 1.3));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-l));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-active));--_n-button-min-block-size:var(--n-button-min-block-size, calc(var(--n-space-xxl) - var(--n-space-l)));--_n-button-icon-size:var(--n-size-icon-m)}::slotted(*){color:inherit;pointer-events:none}::slotted(svg){color:var(--n-color-icon)}::slotted(button[slot=proxy]){display:none}:host(:not([variant=primary],[variant=danger])) ::slotted(nord-icon),:host(:not([variant=primary],[variant=danger])) nord-icon{color:var(--n-color-icon)}slot:not([name])::slotted(nord-icon){transform:translateY(1px)}:host([size="s"]) slot:not([name])::slotted(nord-icon:not([size])),slot:not([name])::slotted(nord-icon[size=xs]){transform:translateY(0)}::slotted(nord-icon:not([size])),nord-icon{--_n-icon-size:var(--_n-button-icon-size)}`;let f=class extends(v(u(e))){constructor(){super(...arguments),this.defaultSlot=new p(this),this.buttonRef=s(),this.events=new l(this),this.lightDom=new d(this,{render:()=>this.renderLightDom()}),this.variant="default",this.type="submit",this.size="m",this.download=!1,this.target="_self",this.expand=!1,this.loading=!1,this.handleOuterClick=t=>{t.composedPath().some((t=>t===this.focusableRef.value||t===this.buttonRef.value))||t.stopPropagation()}}connectedCallback(){super.connectedCallback(),this.events.listen(this,"click",this.handleOuterClick,!0)}render(){var t;const r="switch"===this.variant,a="toggle"===(null===(t=this.assignedSlot)||void 0===t?void 0:t.name),e=this.defaultSlot.assigned.some((t=>"nord-icon"===t.localName)),i=(r||a&&!e)&&!this.href,s=n`<slot name="start"></slot><div class="n-content"><slot></slot></div><nord-spinner class="n-button-spinner" color="currentColor" ?hidden="${!this.loading||Boolean(this.href)}"></nord-spinner><slot name="end">${i?n`<nord-icon name="interface-dropdown-small"></nord-icon>`:o}</slot>`;return this.href?this.renderLink(s):this.renderButton(s)}renderLink(t){return n`<a ${b(this.focusableRef)} class="n-button" target="${this.target}" ?download="${this.download}" href="${c(this.disabled,o,this.href)}" tabindex="${c(this.disabled,"-1")}" aria-disabled="${c(this.disabled,"true")}" role="${c(this.disabled,"link")}">${t}</a>`}renderButton(t){return n`<slot name="proxy" @slotchange="${this.handleProxyChange}"></slot><button ${b(this.focusableRef)} class="n-button" ?disabled="${this.disabled}" name="${c(this.name)}" value="${c(this.value)}" @click="${this.handleClick}" aria-disabled="${c(this.loading,"true")}" aria-expanded="${c(this.accessibleExpanded)}" aria-haspopup="${c(this.accessibleHasPopup)}">${t}</button>`}renderLightDom(){return this.href||!this.form?o:n`<button ${b(this.buttonRef)} slot="proxy" name="${c(this.name)}" value="${c(this.value)}" ?disabled="${this.disabled}" form="${c(this.getAttribute("form"))}" type="${this.type}"></button>`}handleClick(t){this.buttonRef.value&&(t.stopPropagation(),this.buttonRef.value.click())}handleProxyChange(t){const n=t.target,o=this.buttonRef.value;o&&o.assignedSlot!==n&&this.appendChild(o)}};f.styles=[h,g],r([i({reflect:!0})],f.prototype,"variant",void 0),r([i({reflect:!0})],f.prototype,"type",void 0),r([i({reflect:!0})],f.prototype,"size",void 0),r([i({attribute:"aria-expanded"})],f.prototype,"accessibleExpanded",void 0),r([i({attribute:"aria-haspopup"})],f.prototype,"accessibleHasPopup",void 0),r([i({reflect:!0})],f.prototype,"href",void 0),r([i({type:Boolean})],f.prototype,"download",void 0),r([i()],f.prototype,"target",void 0),r([i({reflect:!0,type:Boolean})],f.prototype,"expand",void 0),r([i({reflect:!0,type:Boolean})],f.prototype,"loading",void 0),f=r([a("nord-button")],f);var _=f;export{_ as default};
|
|
1
|
+
import{i as t,y as n,b as o,_ as r,e as a,s as e}from"./query-assigned-elements-cf502539.js";import{e as i}from"./property-03f59dce.js";import{e as s,n as b}from"./ref-c44e9f3c.js";import{E as l}from"./EventController-d99ebeef.js";import{L as d}from"./LightDomController-052f446a.js";import{c}from"./cond-2da54107.js";import"./Spinner.js";import{F as u}from"./FocusableMixin-32631bff.js";import{I as v}from"./InputMixin-7fa755e1.js";import{s as h}from"./Component-449e40fb.js";import{S as p}from"./SlotController-d733c575.js";import"./directive-de55b00a.js";import"./if-defined-720964c0.js";const g=t`:host{--_n-button-border-radius:var(--n-button-border-radius, var(--n-border-radius-s));--_n-button-gap:var(--n-button-gap, var(--n-space-s));--_n-button-gradient:var(--n-button-gradient, linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.013) 100%));--_n-button-background-color:var(--n-button-background-color, var(--n-color-button));--_n-button-border-color:var(--n-button-border-color, var(--n-color-border-strong));--_n-button-text-align:var(--n-button-text-align, center);--_n-button-box-shadow:var(--n-button-box-shadow, var(--n-box-shadow));--_n-button-color:var(--n-button-color, var(--n-color-text));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-m) / 1.2));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-m));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight));--_n-button-min-block-size:var(--n-button-min-block-size, var(--n-space-xl));--_n-button-opacity:1;--_n-button-border-style:solid;--_n-button-inline-size:fit-content;--_n-button-padding-block:calc(var(--n-space-s) / 1.6);--_n-button-icon-size:var(--n-size-icon-s);display:inline-block}.n-button{-webkit-appearance:none;align-items:center;appearance:none;background:var(--_n-button-background-color);opacity:var(--_n-button-opacity);border-radius:var(--_n-button-border-radius);border:1px var(--_n-button-border-style) var(--_n-button-border-color);box-shadow:var(--_n-button-box-shadow);color:var(--_n-button-color);cursor:pointer;display:flex;gap:var(--_n-button-gap);font-family:var(--n-font-family);font-feature-settings:var(--n-font-features);font-size:var(--_n-button-font-size);font-weight:var(--_n-button-font-weight);line-height:var(--n-line-height-form);margin:0;min-block-size:var(--_n-button-min-block-size);padding:var(--_n-button-padding-block) var(--_n-button-padding-inline);text-align:var(--_n-button-text-align);text-decoration:none;transition:.1s ease;transition-property:background-color,opacity,color,box-shadow,border-color;-webkit-user-select:none;user-select:none;position:relative;inline-size:var(--_n-button-inline-size)}.n-button::after{content:"";position:absolute;background:0 0;background-image:var(--_n-button-gradient);border-radius:var(--_n-button-border-radius);background-repeat:repeat-x;inline-size:100%;inset-inline:0;block-size:100%;inset-block-start:0}:host([expand]){--_n-button-inline-size:100%;display:block}.n-content{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;position:relative}.n-button:hover{--_n-button-border-color:var(--n-button-border-color, var(--n-color-border-hover));--_n-button-background-color:var(--n-button-background-color, var(--n-color-button-hover))}.n-button:focus{--_n-button-border-color:var(--n-button-border-color, var(--n-color-accent));--_n-button-border-style:solid;--_n-button-box-shadow:0 0 0 1px var(--n-color-accent),var(--n-box-shadow);outline:0}.n-button:active{opacity:.8;transform:translateY(1px);transition:none}:host([variant=primary]){--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-on-accent));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-active))}:host([variant=primary]),:host([variant=primary]) .n-button:hover{--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-background-color:var(--n-button-background-color, var(--n-color-accent))}:host([variant=primary]) .n-button:hover{filter:brightness(93%)}:host([variant=primary]) .n-button:focus{--_n-button-box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--_n-button-border-color)}:host([variant=dashed]){--_n-button-border-color:var(--n-button-border-color, var(--n-color-border-hover));--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-weaker));--_n-button-border-style:dashed}:host([variant=dashed]) .n-button:hover{--_n-button-color:var(--n-button-color, var(--n-color-text))}:host([variant=dashed]) .n-button::after{display:none}:host([variant=plain]){--_n-button-box-shadow:var(--n-button-box-shadow, none)}:host([variant=plain]),:host([variant=plain]) .n-button:hover{--_n-button-border-color:var(--n-button-border-color, transparent)}:host([variant=plain]) .n-button::after{display:none}:host([variant=danger]){--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-on-accent));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-active))}:host([variant=danger]),:host([variant=danger]) .n-button:hover{--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-background-color:var(--n-button-background-color, var(--n-color-status-danger))}:host([variant=danger]) .n-button:hover{filter:brightness(93%)}:host([variant=danger]) .n-button:focus{--_n-button-border-color:var(--n-button-border-color, var(--n-color-status-danger));--_n-button-box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--n-color-status-danger)}:host([variant=switch]){--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-text-align:var(--n-button-text-align, start);--_n-button-background-color:var(--n-button-background-color, transparent);--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-gradient:var(--n-button-gradient, none);--_n-button-color:var(--n-button-color, var(--n-color-text));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-s) / 2));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-heading));--_n-button-font-size:var(--n-button-font-size, var(--n-n-font-size-l));--_n-button-min-block-size:var(--n-button-min-block-size, calc(var(--n-space-xxl) - 1px));--_n-button-icon-size:var(--n-size-icon-s);display:flex;align-items:center}:host([variant=switch][size="l"]){--_n-button-border-radius:var(--n-button-border-radius, var(--n-border-radius-sharp));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-l) / 2));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-heading));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-l));--_n-button-min-block-size:var(--n-button-min-block-size, calc(var(--n-space-xxl) - 1px))}:host([variant=switch]) .n-button *{pointer-events:none}:host([variant=switch]) .n-button::after{display:none}:host([variant=switch]) .n-button:hover,:host([variant=switch][aria-expanded=true]) .n-button{--_n-button-border-color:var(--n-button-border-color, transparent);--_n-button-background-color:var(--n-button-background-color, var(--n-color-nav-hover))}:host([variant=switch]) .n-button:focus{--_n-button-box-shadow:inset 0 0 0 1px var(--_n-button-border-color)}:host([variant=switch]) slot[name=end] nord-icon{color:var(--n-color-icon);margin-inline-end:var(--n-space-s)}:host([disabled]){--_n-button-border-color:var(--n-button-border-color, var(--_n-button-background-color));--_n-button-background-color:var(--n-button-background-color, var(--n-color-border));--_n-button-box-shadow:var(--n-button-box-shadow, none);--_n-button-color:var(--n-button-color, var(--n-color-text-weaker));--_n-button-opacity:0.5;pointer-events:none}:host([disabled]) .n-button::after{display:none}.n-button-spinner{position:absolute;transform:translateX(-50%) translateY(-50%);inset-block-start:50%;inset-inline-start:50%}:host([loading]:not([href])){pointer-events:none}:host([loading]:not([href])) .n-content,:host([loading]:not([href])) ::slotted([slot=end]),:host([loading]:not([href])) ::slotted([slot=start]){opacity:0}:host([size="s"]){--_n-button-gap:var(--n-button-gap, calc(var(--n-space-s) / 2));--_n-button-padding-inline:var(--n-button-padding-inline, var(--n-space-s));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-s));--_n-button-min-block-size:var(--n-button-min-block-size, var(--n-space-l));--_n-button-padding-block:calc(var(--n-space-s) / 1.5);--_n-button-icon-size:var(--n-size-icon-xs)}:host([size="s"]) .n-button{line-height:var(--n-line-height-tight)}:host([size="l"]){--_n-button-border-radius:var(--n-button-border-radius, var(--n-border-radius));--_n-button-padding-inline:var(--n-button-padding-inline, calc(var(--n-space-l) / 1.3));--_n-button-font-size:var(--n-button-font-size, var(--n-font-size-l));--_n-button-font-weight:var(--n-button-font-weight, var(--n-font-weight-active));--_n-button-min-block-size:var(--n-button-min-block-size, calc(var(--n-space-xxl) - var(--n-space-l)));--_n-button-icon-size:var(--n-size-icon-m)}::slotted(*){color:inherit;pointer-events:none}::slotted(svg){color:var(--n-color-icon)}::slotted(button[slot=proxy]){display:none}:host(:not([variant=primary],[variant=danger])) ::slotted(nord-icon),:host(:not([variant=primary],[variant=danger])) nord-icon{color:var(--n-color-icon)}slot:not([name])::slotted(nord-icon){transform:translateY(1px)}:host([size="s"]) slot:not([name])::slotted(nord-icon:not([size])),slot:not([name])::slotted(nord-icon[size=xs]){transform:translateY(0)}::slotted(nord-icon:not([size])),nord-icon{--_n-icon-size:var(--_n-button-icon-size)}`;let f=class extends(v(u(e))){constructor(){super(...arguments),this.defaultSlot=new p(this),this.buttonRef=s(),this.events=new l(this),this.lightDom=new d(this,{render:()=>this.renderLightDom()}),this.variant="default",this.type="submit",this.size="m",this.download=!1,this.target="_self",this.expand=!1,this.loading=!1,this.handleOuterClick=t=>{t.composedPath().some((t=>t===this.focusableRef.value||t===this.buttonRef.value))||t.stopPropagation()}}connectedCallback(){super.connectedCallback(),this.events.listen(this,"click",this.handleOuterClick,!0)}render(){var t;const r="switch"===this.variant,a="toggle"===(null===(t=this.assignedSlot)||void 0===t?void 0:t.name),e=this.defaultSlot.assigned.some((t=>"nord-icon"===t.localName)),i=(r||a&&!e)&&!this.href,s=n`<slot name="start"></slot><div class="n-content"><slot></slot></div><nord-spinner class="n-button-spinner" color="currentColor" ?hidden="${!this.loading||Boolean(this.href)}"></nord-spinner><slot name="end">${i?n`<nord-icon name="interface-dropdown-small"></nord-icon>`:o}</slot>`;return this.href?this.renderLink(s):this.renderButton(s)}renderLink(t){return n`<a ${b(this.focusableRef)} class="n-button" target="${this.target}" ?download="${this.download}" href="${c(this.disabled,o,this.href)}" tabindex="${c(this.disabled,"-1")}" aria-disabled="${c(this.disabled,"true")}" role="${c(this.disabled,"link")}">${t}</a>`}renderButton(t){return n`<slot name="proxy" @slotchange="${this.handleProxyChange}"></slot><button ${b(this.focusableRef)} class="n-button" ?disabled="${this.disabled}" name="${c(this.name)}" value="${c(this.value)}" @click="${this.handleClick}" aria-disabled="${c(this.loading,"true")}" aria-expanded="${c(this.accessibleExpanded)}" aria-haspopup="${c(this.accessibleHasPopup)}">${t}</button>`}renderLightDom(){return this.href||!this.form?o:n`<button ${b(this.buttonRef)} slot="proxy" name="${c(this.name)}" value="${c(this.value)}" ?disabled="${this.disabled}" form="${c(this.getAttribute("form"))}" type="${this.type}"></button>`}handleClick(t){this.buttonRef.value&&(t.stopPropagation(),this.buttonRef.value.click())}handleProxyChange(t){const n=t.target,o=this.buttonRef.value;o&&o.assignedSlot!==n&&this.appendChild(o)}};f.styles=[h,g],r([i({reflect:!0})],f.prototype,"variant",void 0),r([i({reflect:!0})],f.prototype,"type",void 0),r([i({reflect:!0})],f.prototype,"size",void 0),r([i({attribute:"aria-expanded"})],f.prototype,"accessibleExpanded",void 0),r([i({attribute:"aria-haspopup"})],f.prototype,"accessibleHasPopup",void 0),r([i({reflect:!0})],f.prototype,"href",void 0),r([i({type:Boolean})],f.prototype,"download",void 0),r([i()],f.prototype,"target",void 0),r([i({reflect:!0,type:Boolean})],f.prototype,"expand",void 0),r([i({reflect:!0,type:Boolean})],f.prototype,"loading",void 0),f=r([a("nord-button")],f);var _=f;export{_ as default};
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
package/lib/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../src/button/Button.ts"],"sourcesContent":["import { LitElement, html, nothing, TemplateResult } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { createRef, ref } from \"lit/directives/ref.js\"\nimport { EventController } from \"../common/controllers/EventController.js\"\nimport { LightDomController } from \"../common/controllers/LightDomController.js\"\nimport { cond } from \"../common/directives/cond.js\"\n\nimport \"../spinner/Spinner.js\"\n\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\nimport componentStyle from \"../common/styles/Component.css\"\nimport style from \"./Button.css\"\nimport { SlotController } from \"../common/controllers/SlotController.js\"\n\n/**\n * Buttons are used for interface actions. Primary style should be\n * used only once per section for main call-to-action, while other\n * styles can appear more frequently.\n *\n * @status ready\n * @category action\n * @slot - The button content\n * @slot start - Used to place content at the start of button text. Typically used for icons.\n * @slot end - Used to place content at the end of button text. Typically used for icons.\n *\n * @cssprop [--n-button-border-radius=var(--n-border-radius-s)] - Controls the rounded corners of the button, using [border radius tokens](/tokens/#border-radius).\n * @cssprop [--n-button-gap=var(--n-space-s)] - Controls the spacing between items within the button, using our [spacing tokens](/tokens/#space).\n * @cssprop [--n-button-gradient=linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.013) 100%))] - Controls the overlayed gradient background on the button.\n * @cssprop [--n-button-background-color=var(--n-color-button)] - Controls the background color of the button, using our [color tokens](/tokens/#color).\n * @cssprop [--n-button-border-color=var(--n-color-border-strong)] - Controls the border color of the button, using our [color tokens](/tokens/#color).\n * @cssprop [--n-button-text-align=center] - Controls the text alignment for the text in the button.\n * @cssprop [--n-button-box-shadow=var(--n-box-shadow)] - Controls the surrounding shadow, using our [box shadow tokens](/tokens/#box-shadow).\n * @cssprop [--n-button-color=var(--n-color-text)] - Controls the color of the text within the button, using our [color tokens](/tokens/#color).\n * @cssprop [--n-button-padding-inline=calc(var(--n-space-m) / 1.2)] - Controls the inline, or left and right, padding of the button.\n * @cssprop [--n-button-font-size=var(--n-font-size-m)] - Controls the size of the text within the button, using our [font tokens](/tokens/#font).\n * @cssprop [--n-button-font-weight=var(--n-font-weight)] - Controls the weight of the text within the button, using our [font tokens](/tokens/#font).\n * @cssprop [--n-button-min-block-size=var(--n-space-xl)] - Controls the minimum block size, or height, of the button using our [spacing tokens](/tokens/#space).\n * @cssprop [--n-button-dropdown-icon-color=var(--n-color-icon)] - Controls the color of the dropdown icon, using our [color tokens](/tokens/#color).\n */\n@customElement(\"nord-button\")\nexport default class Button extends InputMixin(FocusableMixin(LitElement)) {\n static styles = [componentStyle, style]\n\n private defaultSlot = new SlotController(this)\n private buttonRef = createRef<HTMLButtonElement>()\n private events = new EventController(this)\n private lightDom = new LightDomController(this, {\n render: () => this.renderLightDom(),\n })\n\n /**\n * The style variant of the button.\n *\n * **Variant `switch` has been deprecated.**\n */\n @property({ reflect: true }) variant: \"default\" | \"primary\" | \"dashed\" | \"plain\" | \"danger\" | \"switch\" = \"default\"\n\n /**\n * The type of the button.\n */\n @property({ reflect: true }) type: \"button\" | \"submit\" | \"reset\" = \"submit\"\n\n /**\n * The size of the button.\n * This affects font-size and padding.\n */\n @property({ reflect: true }) size: \"s\" | \"m\" | \"l\" = \"m\"\n\n /**\n * @private\n * This does not need to be documented,\n * since it is only for forwarding the aria-expanded attribute\n * to the internal button element.\n */\n @property({ attribute: \"aria-expanded\" }) accessibleExpanded?: \"true\" | \"false\"\n\n /**\n * @private\n * This does not need to be documented,\n * since it is only for forwarding the aria-haspopup attribute\n * to the internal button element.\n */\n @property({ attribute: \"aria-haspopup\" }) accessibleHasPopup?:\n | \"false\"\n | \"true\"\n | \"menu\"\n | \"listbox\"\n | \"tree\"\n | \"grid\"\n | \"dialog\"\n\n /**\n * When provided, renders the button as a link,\n * with its href attribute set to the given value.\n */\n @property({ reflect: true }) href?: string\n\n /**\n * When provided together with a href property, the button will\n * trigger a file download instead of a page visit.\n */\n @property({ type: Boolean }) download = false\n\n /**\n * When provided together with a href property, determines where\n * to open the linked URL. The keywords have special meanings for\n * where to load the URL: “_self” means the current browsing context,\n * “_blank” usually a new tab but users can configure browsers this to\n * open a new window instead, “_parent” means the parent browsing\n * context of the current one, but if no parent exists, behaves as\n * _self, and finally “top” means the topmost browsing context.\n */\n @property() target: \"_self\" | \"_blank\" | \"_parent\" | \"_top\" = \"_self\"\n\n /**\n * Controls whether the button expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n /**\n * Controls whether the button is in loading state. Please note that the spinner\n * is hidden from assistive technologies, so you need to make sure to announce\n * the loading state to e.g. screen reader users. We also recommend disabling\n * all user interactions on the button itself while in loading state.\n */\n @property({ reflect: true, type: Boolean }) loading = false\n\n connectedCallback() {\n super.connectedCallback()\n this.events.listen(this, \"click\", this.handleOuterClick, true)\n }\n\n render() {\n const isSwitch = this.variant === \"switch\"\n const isDropdownToggle = this.assignedSlot?.name === \"toggle\"\n const isIconButton = this.defaultSlot.assigned.some(node => node.localName === \"nord-icon\")\n const shouldShowDropdownIcon = (isSwitch || (isDropdownToggle && !isIconButton)) && !this.href\n\n const innards = html`\n <slot name=\"start\"></slot>\n <div class=\"n-content\">\n <slot></slot>\n </div>\n <nord-spinner\n class=\"n-button-spinner\"\n color=\"currentColor\"\n ?hidden=${!this.loading || Boolean(this.href)}\n ></nord-spinner>\n <slot name=\"end\">\n ${shouldShowDropdownIcon ? html`<nord-icon name=\"interface-dropdown-small\"></nord-icon>` : nothing}\n </slot>\n `\n\n return this.href ? this.renderLink(innards) : this.renderButton(innards)\n }\n\n /**\n * We jump through some hoops here to ensure the link is treated correctly when \"disabled\".\n * Links cannot be disabled natively, so we need to rely on some aria magic to get the correct semantics.\n * Along with the advice in the article below, we also set tabindex to \"-1\", so it is taken out of tab order.\n *\n * @see https://www.scottohara.me/blog/2021/05/28/disabled-links.html\n */\n private renderLink(innards: TemplateResult) {\n return html`\n <a\n ${ref(this.focusableRef)}\n class=\"n-button\"\n target=${this.target}\n ?download=${this.download}\n href=${cond(this.disabled, nothing, this.href)}\n tabindex=${cond(this.disabled, \"-1\")}\n aria-disabled=${cond(this.disabled, \"true\")}\n role=${cond(this.disabled, \"link\")}\n >${innards}\n </a>\n `\n }\n\n private renderButton(innards: TemplateResult) {\n return html`\n <slot name=\"proxy\" @slotchange=${this.handleProxyChange}></slot>\n <button\n ${ref(this.focusableRef)}\n class=\"n-button\"\n ?disabled=${this.disabled}\n name=${cond(this.name)}\n value=${cond(this.value)}\n @click=${this.handleClick}\n aria-disabled=${cond(this.loading, \"true\")}\n aria-expanded=${cond(this.accessibleExpanded)}\n aria-haspopup=${cond(this.accessibleHasPopup)}\n >\n ${innards}\n </button>\n `\n }\n\n private renderLightDom() {\n if (this.href || !this.form) {\n return nothing\n }\n\n return html`\n <button\n ${ref(this.buttonRef)}\n slot=\"proxy\"\n name=${cond(this.name)}\n value=${cond(this.value)}\n ?disabled=${this.disabled}\n form=${cond(this.getAttribute(\"form\"))}\n type=${this.type}\n ></button>\n `\n }\n\n private handleOuterClick = (e: MouseEvent) => {\n // we want to avoid emitting click events when a click\n // happens in blank space in the host, but not on the button\n // so we stop propagation of any events if click didn't happen on the internal or proxy button\n const isInternalButton = e\n .composedPath()\n .some(node => node === this.focusableRef.value || node === this.buttonRef.value)\n\n if (!isInternalButton) {\n e.stopPropagation()\n }\n }\n\n private handleClick(e: Event) {\n if (this.buttonRef.value) {\n // prevents two events: one from internal button, one from proxy button\n e.stopPropagation()\n this.buttonRef.value.click()\n }\n }\n\n /**\n * React/Vue etc may remove our proxy button when updating button text, since they are unaware of its existence.\n * So we listen for a slotchange event, and if the element is no longer connected to the DOM we add it back in.\n */\n private handleProxyChange(e: Event) {\n const slot = e.target as HTMLSlotElement\n const proxyButton = this.buttonRef.value\n\n if (proxyButton && proxyButton.assignedSlot !== slot) {\n this.appendChild(proxyButton)\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-button\": Button\n }\n}\n"],"names":["Button","InputMixin","FocusableMixin","LitElement","constructor","this","defaultSlot","SlotController","buttonRef","createRef","events","EventController","lightDom","LightDomController","render","renderLightDom","variant","type","size","download","target","expand","loading","handleOuterClick","e","composedPath","some","node","focusableRef","value","stopPropagation","connectedCallback","super","listen","isSwitch","isDropdownToggle","_a","assignedSlot","name","isIconButton","assigned","localName","shouldShowDropdownIcon","href","innards","html","Boolean","nothing","renderLink","renderButton","ref","cond","disabled","handleProxyChange","handleClick","accessibleExpanded","accessibleHasPopup","form","getAttribute","click","slot","proxyButton","appendChild","styles","componentStyle","style","__decorate","property","reflect","prototype","attribute","customElement"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../src/button/Button.ts"],"sourcesContent":["import { LitElement, html, nothing, TemplateResult } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { createRef, ref } from \"lit/directives/ref.js\"\nimport { EventController } from \"../common/controllers/EventController.js\"\nimport { LightDomController } from \"../common/controllers/LightDomController.js\"\nimport { cond } from \"../common/directives/cond.js\"\n\nimport \"../spinner/Spinner.js\"\n\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\nimport componentStyle from \"../common/styles/Component.css\"\nimport style from \"./Button.css\"\nimport { SlotController } from \"../common/controllers/SlotController.js\"\n\n/**\n * Buttons are used for interface actions. Primary style should be\n * used only once per section for main call-to-action, while other\n * styles can appear more frequently.\n *\n * @status ready\n * @category action\n * @slot - The button content\n * @slot start - Used to place content at the start of button text. Typically used for icons.\n * @slot end - Used to place content at the end of button text. Typically used for icons.\n *\n * @cssprop [--n-button-border-radius=var(--n-border-radius-s)] - Controls the rounded corners of the button, using [border radius tokens](/tokens/#border-radius).\n * @cssprop [--n-button-gap=var(--n-space-s)] - Controls the spacing between items within the button, using our [spacing tokens](/tokens/#space).\n * @cssprop [--n-button-gradient=linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.013) 100%))] - Controls the overlayed gradient background on the button.\n * @cssprop [--n-button-background-color=var(--n-color-button)] - Controls the background color of the button, using our [color tokens](/tokens/#color).\n * @cssprop [--n-button-border-color=var(--n-color-border-strong)] - Controls the border color of the button, using our [color tokens](/tokens/#color).\n * @cssprop [--n-button-text-align=center] - Controls the text alignment for the text in the button.\n * @cssprop [--n-button-box-shadow=var(--n-box-shadow)] - Controls the surrounding shadow, using our [box shadow tokens](/tokens/#box-shadow).\n * @cssprop [--n-button-color=var(--n-color-text)] - Controls the color of the text within the button, using our [color tokens](/tokens/#color).\n * @cssprop [--n-button-padding-inline=calc(var(--n-space-m) / 1.2)] - Controls the inline, or left and right, padding of the button.\n * @cssprop [--n-button-font-size=var(--n-font-size-m)] - Controls the size of the text within the button, using our [font tokens](/tokens/#font).\n * @cssprop [--n-button-font-weight=var(--n-font-weight)] - Controls the weight of the text within the button, using our [font tokens](/tokens/#font).\n * @cssprop [--n-button-min-block-size=var(--n-space-xl)] - Controls the minimum block size, or height, of the button using our [spacing tokens](/tokens/#space).\n */\n@customElement(\"nord-button\")\nexport default class Button extends InputMixin(FocusableMixin(LitElement)) {\n static styles = [componentStyle, style]\n\n private defaultSlot = new SlotController(this)\n private buttonRef = createRef<HTMLButtonElement>()\n private events = new EventController(this)\n private lightDom = new LightDomController(this, {\n render: () => this.renderLightDom(),\n })\n\n /**\n * The style variant of the button.\n *\n * **Variant `switch` has been deprecated.**\n */\n @property({ reflect: true }) variant: \"default\" | \"primary\" | \"dashed\" | \"plain\" | \"danger\" | \"switch\" = \"default\"\n\n /**\n * The type of the button.\n */\n @property({ reflect: true }) type: \"button\" | \"submit\" | \"reset\" = \"submit\"\n\n /**\n * The size of the button.\n * This affects font-size and padding.\n */\n @property({ reflect: true }) size: \"s\" | \"m\" | \"l\" = \"m\"\n\n /**\n * @private\n * This does not need to be documented,\n * since it is only for forwarding the aria-expanded attribute\n * to the internal button element.\n */\n @property({ attribute: \"aria-expanded\" }) accessibleExpanded?: \"true\" | \"false\"\n\n /**\n * @private\n * This does not need to be documented,\n * since it is only for forwarding the aria-haspopup attribute\n * to the internal button element.\n */\n @property({ attribute: \"aria-haspopup\" }) accessibleHasPopup?:\n | \"false\"\n | \"true\"\n | \"menu\"\n | \"listbox\"\n | \"tree\"\n | \"grid\"\n | \"dialog\"\n\n /**\n * When provided, renders the button as a link,\n * with its href attribute set to the given value.\n */\n @property({ reflect: true }) href?: string\n\n /**\n * When provided together with a href property, the button will\n * trigger a file download instead of a page visit.\n */\n @property({ type: Boolean }) download = false\n\n /**\n * When provided together with a href property, determines where\n * to open the linked URL. The keywords have special meanings for\n * where to load the URL: “_self” means the current browsing context,\n * “_blank” usually a new tab but users can configure browsers this to\n * open a new window instead, “_parent” means the parent browsing\n * context of the current one, but if no parent exists, behaves as\n * _self, and finally “top” means the topmost browsing context.\n */\n @property() target: \"_self\" | \"_blank\" | \"_parent\" | \"_top\" = \"_self\"\n\n /**\n * Controls whether the button expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n /**\n * Controls whether the button is in loading state. Please note that the spinner\n * is hidden from assistive technologies, so you need to make sure to announce\n * the loading state to e.g. screen reader users. We also recommend disabling\n * all user interactions on the button itself while in loading state.\n */\n @property({ reflect: true, type: Boolean }) loading = false\n\n connectedCallback() {\n super.connectedCallback()\n this.events.listen(this, \"click\", this.handleOuterClick, true)\n }\n\n render() {\n const isSwitch = this.variant === \"switch\"\n const isDropdownToggle = this.assignedSlot?.name === \"toggle\"\n const isIconButton = this.defaultSlot.assigned.some(node => node.localName === \"nord-icon\")\n const shouldShowDropdownIcon = (isSwitch || (isDropdownToggle && !isIconButton)) && !this.href\n\n const innards = html`\n <slot name=\"start\"></slot>\n <div class=\"n-content\">\n <slot></slot>\n </div>\n <nord-spinner\n class=\"n-button-spinner\"\n color=\"currentColor\"\n ?hidden=${!this.loading || Boolean(this.href)}\n ></nord-spinner>\n <slot name=\"end\">\n ${shouldShowDropdownIcon ? html`<nord-icon name=\"interface-dropdown-small\"></nord-icon>` : nothing}\n </slot>\n `\n\n return this.href ? this.renderLink(innards) : this.renderButton(innards)\n }\n\n /**\n * We jump through some hoops here to ensure the link is treated correctly when \"disabled\".\n * Links cannot be disabled natively, so we need to rely on some aria magic to get the correct semantics.\n * Along with the advice in the article below, we also set tabindex to \"-1\", so it is taken out of tab order.\n *\n * @see https://www.scottohara.me/blog/2021/05/28/disabled-links.html\n */\n private renderLink(innards: TemplateResult) {\n return html`\n <a\n ${ref(this.focusableRef)}\n class=\"n-button\"\n target=${this.target}\n ?download=${this.download}\n href=${cond(this.disabled, nothing, this.href)}\n tabindex=${cond(this.disabled, \"-1\")}\n aria-disabled=${cond(this.disabled, \"true\")}\n role=${cond(this.disabled, \"link\")}\n >${innards}\n </a>\n `\n }\n\n private renderButton(innards: TemplateResult) {\n return html`\n <slot name=\"proxy\" @slotchange=${this.handleProxyChange}></slot>\n <button\n ${ref(this.focusableRef)}\n class=\"n-button\"\n ?disabled=${this.disabled}\n name=${cond(this.name)}\n value=${cond(this.value)}\n @click=${this.handleClick}\n aria-disabled=${cond(this.loading, \"true\")}\n aria-expanded=${cond(this.accessibleExpanded)}\n aria-haspopup=${cond(this.accessibleHasPopup)}\n >\n ${innards}\n </button>\n `\n }\n\n private renderLightDom() {\n if (this.href || !this.form) {\n return nothing\n }\n\n return html`\n <button\n ${ref(this.buttonRef)}\n slot=\"proxy\"\n name=${cond(this.name)}\n value=${cond(this.value)}\n ?disabled=${this.disabled}\n form=${cond(this.getAttribute(\"form\"))}\n type=${this.type}\n ></button>\n `\n }\n\n private handleOuterClick = (e: MouseEvent) => {\n // we want to avoid emitting click events when a click\n // happens in blank space in the host, but not on the button\n // so we stop propagation of any events if click didn't happen on the internal or proxy button\n const isInternalButton = e\n .composedPath()\n .some(node => node === this.focusableRef.value || node === this.buttonRef.value)\n\n if (!isInternalButton) {\n e.stopPropagation()\n }\n }\n\n private handleClick(e: Event) {\n if (this.buttonRef.value) {\n // prevents two events: one from internal button, one from proxy button\n e.stopPropagation()\n this.buttonRef.value.click()\n }\n }\n\n /**\n * React/Vue etc may remove our proxy button when updating button text, since they are unaware of its existence.\n * So we listen for a slotchange event, and if the element is no longer connected to the DOM we add it back in.\n */\n private handleProxyChange(e: Event) {\n const slot = e.target as HTMLSlotElement\n const proxyButton = this.buttonRef.value\n\n if (proxyButton && proxyButton.assignedSlot !== slot) {\n this.appendChild(proxyButton)\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-button\": Button\n }\n}\n"],"names":["Button","InputMixin","FocusableMixin","LitElement","constructor","this","defaultSlot","SlotController","buttonRef","createRef","events","EventController","lightDom","LightDomController","render","renderLightDom","variant","type","size","download","target","expand","loading","handleOuterClick","e","composedPath","some","node","focusableRef","value","stopPropagation","connectedCallback","super","listen","isSwitch","isDropdownToggle","_a","assignedSlot","name","isIconButton","assigned","localName","shouldShowDropdownIcon","href","innards","html","Boolean","nothing","renderLink","renderButton","ref","cond","disabled","handleProxyChange","handleClick","accessibleExpanded","accessibleHasPopup","form","getAttribute","click","slot","proxyButton","appendChild","styles","componentStyle","style","__decorate","property","reflect","prototype","attribute","customElement"],"mappings":"w/SAwCA,IAAqBA,EAArB,cAAoCC,EAAWC,EAAeC,KAA9DC,kCAGUC,KAAAC,YAAc,IAAIC,EAAeF,MACjCA,KAASG,UAAGC,IACZJ,KAAAK,OAAS,IAAIC,EAAgBN,MAC7BA,KAAAO,SAAW,IAAIC,EAAmBR,KAAM,CAC9CS,OAAQ,IAAMT,KAAKU,mBAQQV,KAAOW,QAAqE,UAK5EX,KAAIY,KAAkC,SAMtCZ,KAAIa,KAAoB,IAmCxBb,KAAQc,UAAG,EAW5Bd,KAAMe,OAA4C,QAKlBf,KAAMgB,QAAG,EAQThB,KAAOiB,SAAG,EA2F9CjB,KAAAkB,iBAAoBC,IAIDA,EACtBC,eACAC,MAAKC,GAAQA,IAAStB,KAAKuB,aAAaC,OAASF,IAAStB,KAAKG,UAAUqB,SAG1EL,EAAEM,iBACH,CAuBJ,CA1HCC,oBACEC,MAAMD,oBACN1B,KAAKK,OAAOuB,OAAO5B,KAAM,QAASA,KAAKkB,kBAAkB,EAC1D,CAEDT,eACE,MAAMoB,EAA4B,WAAjB7B,KAAKW,QAChBmB,EAA+C,YAAT,QAAnBC,EAAA/B,KAAKgC,oBAAc,IAAAD,OAAA,EAAAA,EAAAE,MACtCC,EAAelC,KAAKC,YAAYkC,SAASd,MAAKC,GAA2B,cAAnBA,EAAKc,YAC3DC,GAA0BR,GAAaC,IAAqBI,KAAmBlC,KAAKsC,KAEpFC,EAAUC,CAAI,6IAQLxC,KAAKiB,SAAWwB,QAAQzC,KAAKsC,0CAGtCD,EAAyBG,CAAI,0DAA4DE,WAI/F,OAAO1C,KAAKsC,KAAOtC,KAAK2C,WAAWJ,GAAWvC,KAAK4C,aAAaL,EACjE,CASOI,WAAWJ,GACjB,OAAOC,CAAI,MAELK,EAAI7C,KAAKuB,0CAEFvB,KAAKe,sBACFf,KAAKc,mBACVgC,EAAK9C,KAAK+C,SAAUL,EAAS1C,KAAKsC,oBAC9BQ,EAAK9C,KAAK+C,SAAU,yBACfD,EAAK9C,KAAK+C,SAAU,kBAC7BD,EAAK9C,KAAK+C,SAAU,YACxBR,OAGR,CAEOK,aAAaL,GACnB,OAAOC,CAAI,mCACwBxC,KAAKgD,qCAElCH,EAAI7C,KAAKuB,6CAECvB,KAAK+C,mBACVD,EAAK9C,KAAKiC,iBACTa,EAAK9C,KAAKwB,mBACTxB,KAAKiD,+BACEH,EAAK9C,KAAKiB,QAAS,2BACnB6B,EAAK9C,KAAKkD,uCACVJ,EAAK9C,KAAKmD,wBAExBZ,YAGP,CAEO7B,iBACN,OAAIV,KAAKsC,OAAStC,KAAKoD,KACdV,EAGFF,CAAI,WAELK,EAAI7C,KAAKG,iCAEJ2C,EAAK9C,KAAKiC,iBACTa,EAAK9C,KAAKwB,sBACNxB,KAAK+C,mBACVD,EAAK9C,KAAKqD,aAAa,mBACvBrD,KAAKY,iBAGjB,CAeOqC,YAAY9B,GACdnB,KAAKG,UAAUqB,QAEjBL,EAAEM,kBACFzB,KAAKG,UAAUqB,MAAM8B,QAExB,CAMON,kBAAkB7B,GACxB,MAAMoC,EAAOpC,EAAEJ,OACTyC,EAAcxD,KAAKG,UAAUqB,MAE/BgC,GAAeA,EAAYxB,eAAiBuB,GAC9CvD,KAAKyD,YAAYD,EAEpB,GA/MM7D,EAAA+D,OAAS,CAACC,EAAgBC,GAcJC,EAAA,CAA5BC,EAAS,CAAEC,SAAS,KAA6FpE,EAAAqE,UAAA,eAAA,GAKrFH,EAAA,CAA5BC,EAAS,CAAEC,SAAS,KAAsDpE,EAAAqE,UAAA,YAAA,GAM9CH,EAAA,CAA5BC,EAAS,CAAEC,SAAS,KAAmCpE,EAAAqE,UAAA,YAAA,GAQdH,EAAA,CAAzCC,EAAS,CAAEG,UAAW,mBAAwDtE,EAAAqE,UAAA,0BAAA,GAQrCH,EAAA,CAAzCC,EAAS,CAAEG,UAAW,mBAOXtE,EAAAqE,UAAA,0BAAA,GAMiBH,EAAA,CAA5BC,EAAS,CAAEC,SAAS,KAAqBpE,EAAAqE,UAAA,YAAA,GAMbH,EAAA,CAA5BC,EAAS,CAAElD,KAAM6B,WAA2B9C,EAAAqE,UAAA,gBAAA,GAWjCH,EAAA,CAAXC,KAAoEnE,EAAAqE,UAAA,cAAA,GAKzBH,EAAA,CAA3CC,EAAS,CAAEC,SAAS,EAAMnD,KAAM6B,WAAyB9C,EAAAqE,UAAA,cAAA,GAQdH,EAAA,CAA3CC,EAAS,CAAEC,SAAS,EAAMnD,KAAM6B,WAA0B9C,EAAAqE,UAAA,eAAA,GArFxCrE,EAAMkE,EAAA,CAD1BK,EAAc,gBACMvE,SAAAA"}
|