@triptease/tt-navbar 0.0.62 → 0.0.64

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,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.62
2
+ * @triptease/tt-navbar v0.0.64
3
3
  */
4
4
 
5
5
  // src/Config.ts
@@ -1,4 +1,4 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.62
2
+ * @triptease/tt-navbar v0.0.64
3
3
  */
4
4
  //# sourceMappingURL=global.d.js.map
package/dist/web/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.62
2
+ * @triptease/tt-navbar v0.0.64
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1033,56 +1033,39 @@ var styles = i`
1033
1033
  overflow-y: auto;
1034
1034
 
1035
1035
 
1036
- li {
1037
- display: flex;
1038
- padding: 0.5rem;
1039
- box-sizing: border-box;
1040
- text-align: left;
1041
- text-overflow: ellipsis;
1042
- text-wrap: nowrap;
1043
- align-items: center;
1044
- gap: 0.25rem;
1045
- max-width: 100%;
1046
- width: 100%;
1047
- overflow-y: visible;
1048
- flex: 1;
1049
-
1050
-
1051
- input[type="checkbox"] {
1052
- width: var(--checkbox-size, var(--space-scale-2));
1053
- aspect-ratio: 1;
1054
- flex: 0 0 auto;
1055
- }
1036
+ .no-results {
1037
+ display: none;
1038
+ }
1056
1039
 
1057
- span {
1058
- overflow: hidden;
1040
+ &:not(:has(tt-option:not([hidden], .select-all))) {
1041
+ .no-results {
1042
+ display: flex;
1043
+ padding: 0.5rem;
1044
+ box-sizing: border-box;
1045
+ text-align: left;
1059
1046
  text-overflow: ellipsis;
1060
- white-space: nowrap;
1047
+ text-wrap: nowrap;
1048
+ align-items: center;
1049
+ gap: 0.25rem;
1050
+ max-width: 100%;
1051
+ width: 100%;
1052
+ overflow-y: visible;
1061
1053
  flex: 1;
1062
- line-height: 1.1;
1063
- }
1064
-
1065
- &.no-results {
1066
- display: none;
1067
- }
1068
1054
 
1069
- &[aria-hidden="true"] {
1070
- visibility: hidden;
1071
- display: none;
1072
- }
1073
- }
1074
1055
 
1075
- &:not(:has([role="option"]:not([data-value="select-all"]))) {
1076
- .no-results {
1077
- display: flex;
1056
+ span {
1057
+ overflow: hidden;
1058
+ text-overflow: ellipsis;
1059
+ white-space: nowrap;
1060
+ flex: 1;
1061
+ line-height: 1.1;
1062
+ }
1078
1063
  }
1079
1064
 
1080
1065
  .select-all {
1081
1066
  display: none;
1082
1067
  }
1083
1068
  }
1084
-
1085
-
1086
1069
  }
1087
1070
 
1088
1071
  [role="combobox"][aria-expanded="true"] ~ [role="listbox"][data-open-upward] {
@@ -1096,50 +1079,10 @@ var styles = i`
1096
1079
  aspect-ratio: 1;
1097
1080
  }
1098
1081
 
1099
- [role="option"].select-all {
1082
+ tt-option.select-all::part(option) {
1100
1083
  border-bottom: 1px solid var(--color-border-300);
1101
1084
  }
1102
1085
 
1103
- [aria-multiselectable="false"] [role="option"][aria-selected="true"] {
1104
- color: var(--tt-combobox-option-selected-color, var(--color-primary-400));
1105
- font-weight: var(--font-weight-medium);
1106
- }
1107
-
1108
- [role="option"]:is(:hover, [data-active="true"]) {
1109
- background-color: var(--tt-combobox-option-background-color-hover, inherit);
1110
- color: var(--tt-combobox-option-color-hover, inherit);
1111
-
1112
- &:first-child {
1113
- border-top-left-radius: var(--border-radius);
1114
- border-top-right-radius: var(--border-radius);
1115
- }
1116
-
1117
- &:last-child {
1118
- border-bottom-left-radius: var(--border-radius);
1119
- border-bottom-right-radius: var(--border-radius);
1120
- }
1121
- }
1122
-
1123
- [role="option"]:hover {
1124
- cursor: pointer;
1125
- }
1126
-
1127
- [role="option"][aria-disabled="true"] {
1128
- pointer-events: none;
1129
- opacity: 0.5;
1130
- }
1131
-
1132
- [role="listbox"][aria-multiselectable="true"] [role="option"] input[type="checkbox"] {
1133
- accent-color: var(--color-primary-400);
1134
- width: var(--checkbox-size, var(--space-scale-2));
1135
- aspect-ratio: 1;
1136
- pointer-events: none;
1137
- }
1138
-
1139
- [role="listbox"][aria-multiselectable="true"] [role="option"][aria-disabled="true"] input[type="checkbox"] {
1140
- pointer-events: none;
1141
- }
1142
-
1143
1086
  label {
1144
1087
  font-size: var(--tt-combobox-label-font-size, inherit);
1145
1088
  color: var(--tt-combobox-label-color, inherit);
@@ -1148,7 +1091,6 @@ var styles = i`
1148
1091
  &[data-hidden] {
1149
1092
  display: none;
1150
1093
  }
1151
-
1152
1094
  }
1153
1095
  `;
1154
1096
 
@@ -1158,7 +1100,13 @@ var TtCombobox = class extends i4 {
1158
1100
  return this.internals.form;
1159
1101
  }
1160
1102
  get _isAllSelected() {
1161
- return Array.from(this._selectableVisibleOptions).every((option) => Array.from(this._selectedVisibleOptions).includes(option));
1103
+ return Boolean(this._visibleOptionsNotSelectAll.length) && Array.from(this._visibleOptionsNotSelectAll).every((option) => this.value.includes(option.value));
1104
+ }
1105
+ get _selectedVisibleOptions() {
1106
+ return Array.from(this._visibleOptions).filter((option) => this.value.includes(option.value));
1107
+ }
1108
+ get _selectedOptions() {
1109
+ return Array.from(this._visibleOptionsNotSelectAll).filter((option) => this.value.includes(option.value));
1162
1110
  }
1163
1111
  constructor() {
1164
1112
  super();
@@ -1184,7 +1132,7 @@ var TtCombobox = class extends i4 {
1184
1132
  });
1185
1133
  this._valueChanged = () => {
1186
1134
  this._selectableOptions.forEach((option) => {
1187
- if (this.value.includes(option.dataset.value)) {
1135
+ if (this.value.includes(option.value)) {
1188
1136
  this._checkOption(option);
1189
1137
  } else {
1190
1138
  this._uncheckOption(option);
@@ -1201,14 +1149,14 @@ var TtCombobox = class extends i4 {
1201
1149
  event.preventDefault();
1202
1150
  event.stopPropagation();
1203
1151
  if (this._filter !== "" && this._isAllSelected) {
1204
- const selectedVisibleValues = Array.from(this._selectedVisibleOptions).map((option) => option.dataset.value);
1152
+ const selectedVisibleValues = this._selectedVisibleOptions.map((option) => option.value);
1205
1153
  this.value = this.value.filter((value) => !selectedVisibleValues.includes(value));
1206
1154
  } else if (this._filter !== "") {
1207
- this.value = Array.from(/* @__PURE__ */ new Set([...this.value, ...Array.from(this._selectableVisibleOptions).map((option) => option.dataset.value)]));
1155
+ this.value = Array.from(/* @__PURE__ */ new Set([...this.value, ...Array.from(this._selectableVisibleOptions).map((option) => option.value)]));
1208
1156
  } else if (this.value.length === this._selectableOptions.length) {
1209
1157
  this.value = [];
1210
1158
  } else {
1211
- this.value = Array.from(this._selectableOptions).map((option) => option.dataset.value);
1159
+ this.value = Array.from(this._selectableOptions).map((option) => option.value);
1212
1160
  }
1213
1161
  };
1214
1162
  this._renderSelectAll = () => {
@@ -1219,20 +1167,18 @@ var TtCombobox = class extends i4 {
1219
1167
  const active = this._getActiveOptionId() === id;
1220
1168
  const selected = this._isAllSelected;
1221
1169
  return x`
1222
- <li
1170
+ <tt-option
1171
+ id="${id}"
1223
1172
  class="select-all"
1224
- role="option"
1225
- id="${this.id}-option-select-all"
1226
- aria-selected="${selected}"
1227
- data-active=${active}
1173
+ ?selected=${selected}
1174
+ ?active=${active}
1175
+ include-checkbox
1228
1176
  @click="${this._selectAll}"
1229
- @mousedown="${(evt) => evt.preventDefault()}"
1230
- data-value="select-all"
1177
+ exportparts="option, checkbox"
1231
1178
  part="option"
1232
- >
1233
- <input type="checkbox" ?checked=${selected} role="presentation" tabindex="-1" part="checkbox">
1234
- Select all
1235
- </li>`;
1179
+ value="select-all"
1180
+ >Select all</tt-option>
1181
+ `;
1236
1182
  };
1237
1183
  this._renderChevron = () => x`
1238
1184
  <button type="button" aria-label="Expand" @click="${this._onChevronClick}" aria-expanded="${this._expanded}"
@@ -1277,7 +1223,8 @@ var TtCombobox = class extends i4 {
1277
1223
  }
1278
1224
  if (changedProperties.has("options")) {
1279
1225
  this.updateComplete.then(() => {
1280
- this.value = Array.from(/* @__PURE__ */ new Set([...this.value, ...Array.from(this._selectedOptions).map((option) => option.dataset.value)]));
1226
+ const selectedAssignedOptions = Array.from(this.options).filter((option) => option.selected);
1227
+ this.value = Array.from(/* @__PURE__ */ new Set([...this.value, ...selectedAssignedOptions.map((option) => option.value)]));
1281
1228
  this._listenForOptionChange();
1282
1229
  });
1283
1230
  }
@@ -1285,7 +1232,7 @@ var TtCombobox = class extends i4 {
1285
1232
  }
1286
1233
  _reportValidity() {
1287
1234
  if (this.required && !this.value.length) {
1288
- const errorMessage = this.multiselect ? "Please select at least one option" : "Please select an option";
1235
+ const errorMessage = this.multiselect ? "Please select at least one tt-option" : "Please select an tt-option";
1289
1236
  this.internals.setValidity({
1290
1237
  valueMissing: true
1291
1238
  }, errorMessage, this._comboboxInput);
@@ -1382,7 +1329,9 @@ var TtCombobox = class extends i4 {
1382
1329
  event.preventDefault();
1383
1330
  event.stopPropagation();
1384
1331
  const option = event.currentTarget;
1385
- const selectedValue = option.dataset.value;
1332
+ if (option.disabled)
1333
+ return;
1334
+ const selectedValue = option.value;
1386
1335
  if (this.multiselect) {
1387
1336
  if (this.value.includes(selectedValue)) {
1388
1337
  this.value = this.value.filter((value) => value !== selectedValue);
@@ -1420,11 +1369,11 @@ var TtCombobox = class extends i4 {
1420
1369
  if (this.disabled) {
1421
1370
  return "Disabled";
1422
1371
  }
1423
- if (!this._selectedVisibleOptions.length) {
1372
+ if (!this.value.length) {
1424
1373
  return "No options selected";
1425
1374
  }
1426
- if (this._selectedVisibleOptions.length === 1) {
1427
- return this._selectedVisibleOptions[0].textContent?.trim();
1375
+ if (this.value.length === 1) {
1376
+ return Array.from(this._selectableVisibleOptions).find((option) => option.value === this.value[0])?.textContent?.trim();
1428
1377
  }
1429
1378
  if (this._isAllSelected) {
1430
1379
  return this.selectAllPlaceholder || "All options selected";
@@ -1462,25 +1411,21 @@ var TtCombobox = class extends i4 {
1462
1411
  const hidden = Boolean(this._filter !== "" && !option.value.toLowerCase().includes(this._filter.toLowerCase()) && !option.innerText.toLowerCase().includes(this._filter.toLowerCase()) || option.hidden);
1463
1412
  const id = `${this.id}-option-${option.value}`;
1464
1413
  const active = this._getActiveOptionId() === id;
1465
- const selected = Boolean(this.multiselect && option.selected);
1414
+ const selected = this.value.includes(option.value);
1466
1415
  return x`
1467
- <li
1468
- role="option"
1469
- id="${this.id}-option-${option.value}"
1470
- aria-selected=${this.multiselect && option.selected}
1471
- data-active=${active}
1416
+ <tt-option
1417
+ id="${id}"
1418
+ value="${option.value}"
1419
+ ?selected=${selected}
1420
+ ?disabled=${option.disabled}
1421
+ ?active=${active}
1422
+ ?include-checkbox=${this.multiselect}
1423
+ ?hidden=${hidden}
1472
1424
  @click="${this._onClickOption}"
1473
- @mousedown="${(event) => event.preventDefault()}"
1474
- data-value="${option.value}"
1475
- aria-disabled=${option.disabled}
1476
- aria-hidden=${hidden || E}
1477
- data-deselectable=${!option.selected}
1478
- part="option"
1479
1425
  >
1480
- ${this.multiselect ? x`<input type="checkbox" ?checked=${selected}
1481
- role="presentation" tabindex="-1" part="checkbox">` : E}
1482
- <span>${o7(option.innerHTML)}</span>
1483
- </li>`;
1426
+ ${o7(option.innerHTML)}
1427
+ </tt-option>
1428
+ `;
1484
1429
  }
1485
1430
  _hasErrorContent() {
1486
1431
  return this.errorElements?.length > 0;
@@ -1568,26 +1513,23 @@ __decorate([
1568
1513
  o6({ slot: "option", selector: "option" })
1569
1514
  ], TtCombobox.prototype, "options", void 0);
1570
1515
  __decorate([
1571
- o6({ slot: "option", selector: "option:not([disabled])" })
1516
+ o6({ slot: "option", selector: "tt-option:not([disabled])" })
1572
1517
  ], TtCombobox.prototype, "activeOptions", void 0);
1573
1518
  __decorate([
1574
1519
  o6({ slot: "error" })
1575
1520
  ], TtCombobox.prototype, "errorElements", void 0);
1576
1521
  __decorate([
1577
- r6('li[role="option"]:not([aria-disabled="true"], [aria-hidden="true"])')
1522
+ r6("tt-option:not([hidden], [disabled])")
1578
1523
  ], TtCombobox.prototype, "_visibleOptions", void 0);
1579
1524
  __decorate([
1580
- r6('li[role="option"]:not([aria-disabled="true"], [data-value="select-all"])')
1525
+ r6("tt-option:not([hidden], .select-all")
1526
+ ], TtCombobox.prototype, "_visibleOptionsNotSelectAll", void 0);
1527
+ __decorate([
1528
+ r6("tt-option:not([disabled], .select-all)")
1581
1529
  ], TtCombobox.prototype, "_selectableOptions", void 0);
1582
1530
  __decorate([
1583
- r6('li[role="option"]:not([aria-disabled="true"], [data-value="select-all"], [aria-hidden="true"])')
1531
+ r6("tt-option:not([disabled], [hidden], .select-all)")
1584
1532
  ], TtCombobox.prototype, "_selectableVisibleOptions", void 0);
1585
- __decorate([
1586
- r6('li[role="option"]:not([data-value="select-all"])[aria-selected="true"]')
1587
- ], TtCombobox.prototype, "_selectedOptions", void 0);
1588
- __decorate([
1589
- r6('li[role="option"]:not([data-value="select-all"], [aria-hidden="true"])[aria-selected="true"]')
1590
- ], TtCombobox.prototype, "_selectedVisibleOptions", void 0);
1591
1533
  __decorate([
1592
1534
  e5('input[role="combobox"]')
1593
1535
  ], TtCombobox.prototype, "_comboboxInput", void 0);
@@ -1598,6 +1540,152 @@ __decorate([
1598
1540
  n4({ type: Array, attribute: "value" })
1599
1541
  ], TtCombobox.prototype, "value", void 0);
1600
1542
 
1543
+ // node_modules/@triptease/tt-combobox/dist/src/tt-option/styles.js
1544
+ var styles2 = i`
1545
+ li {
1546
+ cursor: pointer;
1547
+ display: flex;
1548
+ padding: 0.5rem;
1549
+ box-sizing: border-box;
1550
+ text-align: left;
1551
+ text-overflow: ellipsis;
1552
+ text-wrap: nowrap;
1553
+ align-items: center;
1554
+ gap: 0.25rem;
1555
+ max-width: 100%;
1556
+ width: 100%;
1557
+ overflow-y: visible;
1558
+ flex: 1;
1559
+
1560
+ input[type="checkbox"] {
1561
+ width: var(--checkbox-size, var(--space-scale-2));
1562
+ aspect-ratio: 1;
1563
+ flex: 0 0 auto;
1564
+ accent-color: var(--color-primary-400);
1565
+ pointer-events: none;
1566
+ }
1567
+
1568
+ span {
1569
+ overflow: hidden;
1570
+ text-overflow: ellipsis;
1571
+ white-space: nowrap;
1572
+ flex: 1;
1573
+ line-height: 1.1;
1574
+ }
1575
+
1576
+ &[aria-hidden="true"] {
1577
+ visibility: hidden;
1578
+ display: none;
1579
+ }
1580
+
1581
+ &[aria-disabled="true"] {
1582
+ pointer-events: none;
1583
+ opacity: 0.5;
1584
+ }
1585
+
1586
+ &[aria-selected="true"]:not(:has(input[type="checkbox"])) {
1587
+ color: var(--tt-combobox-option-selected-color, var(--color-primary-400));
1588
+ font-weight: var(--font-weight-medium);
1589
+ }
1590
+ }
1591
+
1592
+ :host([active]), :host(:hover) {
1593
+ li {
1594
+ background-color: var(--tt-combobox-option-background-color-hover, var(--color-surface-300));
1595
+ color: var(--tt-combobox-option-color-hover, inherit);
1596
+ }
1597
+
1598
+ &:first-child li {
1599
+ border-top-left-radius: var(--border-radius);
1600
+ border-top-right-radius: var(--border-radius);
1601
+ }
1602
+
1603
+ &:last-child li {
1604
+ border-bottom-left-radius: var(--border-radius);
1605
+ border-bottom-right-radius: var(--border-radius);
1606
+ }
1607
+ }
1608
+
1609
+ :host([disabled]) {
1610
+ pointer-events: none;
1611
+ }
1612
+ `;
1613
+
1614
+ // node_modules/@triptease/tt-combobox/dist/src/tt-option/TtOption.js
1615
+ var TtOption = class extends i4 {
1616
+ constructor() {
1617
+ super(...arguments);
1618
+ this.disabled = false;
1619
+ this.selected = false;
1620
+ this.active = false;
1621
+ this.value = "";
1622
+ this.includeCheckbox = false;
1623
+ this._onClick = (event) => {
1624
+ if (this.disabled) {
1625
+ event.preventDefault();
1626
+ event.stopImmediatePropagation();
1627
+ event.stopPropagation();
1628
+ }
1629
+ };
1630
+ }
1631
+ connectedCallback() {
1632
+ super.connectedCallback();
1633
+ this.addEventListener("click", this._onClick);
1634
+ }
1635
+ disconnectedCallback() {
1636
+ super.disconnectedCallback();
1637
+ this.removeEventListener("click", this._onClick);
1638
+ }
1639
+ render() {
1640
+ return x`
1641
+ <li
1642
+ role="option"
1643
+ aria-selected="${this.selected}"
1644
+ aria-disabled="${this.disabled}"
1645
+ ?aria-hidden="${this.hidden}"
1646
+ data-active="${this.active}"
1647
+ data-value="${this.value}"
1648
+ @click="${this._onClick}"
1649
+ @mousedown="${(event) => event.preventDefault()}"
1650
+ part="option"
1651
+ >
1652
+ ${this.includeCheckbox ? x`<input type="checkbox" ?checked=${this.selected}
1653
+ role="presentation" tabindex="-1" part="checkbox">` : E}
1654
+ <span>
1655
+ <slot></slot>
1656
+ </span>
1657
+ </li>
1658
+ `;
1659
+ }
1660
+ };
1661
+ TtOption.styles = styles2;
1662
+ TtOption.shadowRootOptions = {
1663
+ ...i4.shadowRootOptions,
1664
+ delegatesFocus: true
1665
+ };
1666
+ __decorate([
1667
+ n4({ type: Boolean })
1668
+ ], TtOption.prototype, "disabled", void 0);
1669
+ __decorate([
1670
+ n4({ type: Boolean })
1671
+ ], TtOption.prototype, "selected", void 0);
1672
+ __decorate([
1673
+ n4({ type: Boolean })
1674
+ ], TtOption.prototype, "active", void 0);
1675
+ __decorate([
1676
+ n4({ type: String })
1677
+ ], TtOption.prototype, "value", void 0);
1678
+ __decorate([
1679
+ n4({ type: Boolean, attribute: "include-checkbox" })
1680
+ ], TtOption.prototype, "includeCheckbox", void 0);
1681
+
1682
+ // node_modules/@triptease/tt-combobox/dist/src/tt-option/tt-option.js
1683
+ if (typeof window !== "undefined") {
1684
+ if (!window.customElements.get("tt-option")) {
1685
+ window.customElements.define("tt-option", TtOption);
1686
+ }
1687
+ }
1688
+
1601
1689
  // node_modules/@triptease/tt-combobox/dist/src/tt-combobox.js
1602
1690
  if (typeof window !== "undefined") {
1603
1691
  if (!window.customElements.get("tt-combobox")) {
@@ -1618,7 +1706,7 @@ var visuallyHiddenCss = i`
1618
1706
  clip-path: inset(50%);
1619
1707
  white-space: nowrap;
1620
1708
  `;
1621
- var styles2 = i`
1709
+ var styles3 = i`
1622
1710
  :host {
1623
1711
  --nav-bar-width: 260px;
1624
1712
 
@@ -2332,7 +2420,7 @@ var TtNavbar = class extends i4 {
2332
2420
  `;
2333
2421
  }
2334
2422
  };
2335
- TtNavbar.styles = styles2;
2423
+ TtNavbar.styles = styles3;
2336
2424
  __decorateClass([
2337
2425
  n4({ type: Function })
2338
2426
  ], TtNavbar.prototype, "navigate", 2);