@iris-ui-kit/vue 0.2.13 → 0.2.15

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/dist/index.cjs CHANGED
@@ -835,16 +835,229 @@ var IrisIcon = vue.defineComponent({
835
835
  // src/admin/styles.ts
836
836
  var __NAV_MENU_STYLE_ID = "iris-nav-menu-styles";
837
837
  var CSS2 = `
838
+ :where(.iris-nav-menu) {
839
+ --iris-nav-indent-step: 16px;
840
+ --iris-nav-item-padding-inline: 10px;
841
+ --iris-nav-item-padding-block: 8px;
842
+ --iris-nav-item-border-radius: var(--iris-radius-md, 6px);
843
+ --iris-nav-item-hover: var(--iris-surface-hover, var(--iris-surface));
844
+ --iris-nav-item-height: 34px;
845
+ display: flex;
846
+ flex-direction: column;
847
+ align-items: stretch;
848
+ gap: 2px;
849
+ width: 100%;
850
+ }
851
+
852
+ :where(.iris-nav-menu--horizontal) {
853
+ flex-direction: row;
854
+ align-items: center;
855
+ width: auto;
856
+ }
857
+
858
+ :where(.iris-nav-menu-group) {
859
+ position: relative;
860
+ }
861
+
862
+ :where(.iris-nav-menu-item) {
863
+ appearance: none;
864
+ box-sizing: border-box;
865
+ display: flex;
866
+ flex: 0 1 auto;
867
+ align-items: center;
868
+ width: 100%;
869
+ min-height: var(--iris-nav-item-height);
870
+ border: none;
871
+ border-radius: var(--iris-nav-item-border-radius);
872
+ background: transparent;
873
+ color: var(--iris-foreground, var(--iris-color-text, var(--iris-foreground)));
874
+ font: inherit;
875
+ font-size: 14px;
876
+ line-height: 1.2;
877
+ font-weight: 400;
878
+ text-align: start;
879
+ cursor: pointer;
880
+ opacity: 1;
881
+ margin: 0;
882
+ gap: 10px;
883
+ padding-block: var(--iris-nav-item-padding-block);
884
+ padding-inline: var(--iris-nav-item-padding-inline);
885
+ text-overflow: ellipsis;
886
+ white-space: nowrap;
887
+ }
888
+
889
+ :where(.iris-nav-menu--horizontal .iris-nav-menu-item) {
890
+ width: auto;
891
+ padding-inline-start: var(--iris-nav-item-padding-inline);
892
+ }
893
+
894
+ :where(.iris-nav-menu-item[data-depth='0']) {
895
+ --iris-nav-item-padding-inline-start: 10px;
896
+ }
897
+
898
+ :where(.iris-nav-menu-item[data-depth='1']) {
899
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step));
900
+ }
901
+
902
+ :where(.iris-nav-menu-item[data-depth='2']) {
903
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 2);
904
+ }
905
+
906
+ :where(.iris-nav-menu-item[data-depth='3']) {
907
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 3);
908
+ }
909
+
910
+ :where(.iris-nav-menu-item[data-depth='4']) {
911
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 4);
912
+ }
913
+
914
+ :where(.iris-nav-menu-item[data-depth='5']) {
915
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 5);
916
+ }
917
+
918
+ :where(.iris-nav-menu-item[data-depth='6']) {
919
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 6);
920
+ }
921
+
922
+ :where(.iris-nav-menu-item[data-depth='7']) {
923
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 7);
924
+ }
925
+
926
+ :where(.iris-nav-menu-item[data-depth='8']) {
927
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 8);
928
+ }
929
+
930
+ :where(.iris-nav-menu-item[data-depth='9']) {
931
+ --iris-nav-item-padding-inline-start: calc(12px + var(--iris-nav-indent-step) * 9);
932
+ }
933
+
934
+ :where(.iris-nav-menu--vertical .iris-nav-menu-item[data-depth]) {
935
+ padding-inline-start: var(--iris-nav-item-padding-inline-start);
936
+ }
937
+
938
+ :where(.iris-nav-menu-item:hover),
939
+ :where(.iris-nav-menu-item.is-hovered):not([disabled], .is-disabled) {
940
+ background: var(--iris-nav-item-hover);
941
+ }
942
+
943
+ :where(.iris-nav-menu-item[data-active='true']) {
944
+ background: var(--iris-primary);
945
+ color: var(--iris-primary-foreground, #fff);
946
+ font-weight: 600;
947
+ }
948
+
949
+ :where(.iris-nav-menu-item[data-active-trail='true']) {
950
+ color: var(--iris-primary);
951
+ font-weight: 600;
952
+ }
953
+
954
+ :where(.iris-nav-menu-item[disabled], .iris-nav-menu-item.is-disabled) {
955
+ cursor: not-allowed;
956
+ opacity: 0.5;
957
+ }
958
+
959
+ :where(.iris-nav-menu-item:focus-visible) {
960
+ outline: 2px solid var(--iris-ring, var(--iris-primary));
961
+ outline-offset: 1px;
962
+ }
963
+
964
+ :where(.iris-nav-menu-label) {
965
+ flex: 0 1 auto;
966
+ min-width: 0;
967
+ overflow: hidden;
968
+ text-overflow: ellipsis;
969
+ }
970
+
971
+ :where(.iris-nav-menu-badge) {
972
+ margin-inline-start: 6px;
973
+ font-size: 11px;
974
+ line-height: 1;
975
+ padding: 2px 6px;
976
+ border-radius: 999px;
977
+ background: var(--iris-danger, #e5484d);
978
+ color: #fff;
979
+ flex: 0 0 auto;
980
+ }
981
+
838
982
  :where(.iris-nav-menu-arrow) {
839
983
  flex: 0 0 auto;
840
984
  opacity: 0.6;
841
985
  transform: rotate(0deg);
842
986
  transform-origin: center;
843
987
  transition: transform 160ms ease;
988
+ margin-inline-start: auto;
844
989
  }
845
- :where(.iris-nav-menu-arrow[data-reversed="true"]) {
990
+
991
+ :where(.iris-nav-menu-arrow[data-reversed='true']) {
846
992
  transform: rotate(180deg);
847
993
  }
994
+
995
+ :where(.iris-nav-menu-fallback-icon) {
996
+ display: inline-flex;
997
+ width: 20px;
998
+ height: 20px;
999
+ align-items: center;
1000
+ justify-content: center;
1001
+ font-weight: 700;
1002
+ }
1003
+
1004
+ :where(.iris-nav-menu-item.is-disabled) .iris-nav-menu-label {
1005
+ opacity: 0.75;
1006
+ }
1007
+
1008
+ :where(.iris-nav-menu-group--depth-0 > .iris-nav-menu-children) {
1009
+ display: none;
1010
+ }
1011
+
1012
+ :where(.iris-nav-menu-group--depth-1 > .iris-nav-menu-children),
1013
+ :where(.iris-nav-menu-group--depth-2 > .iris-nav-menu-children),
1014
+ :where(.iris-nav-menu-group--depth-3 > .iris-nav-menu-children),
1015
+ :where(.iris-nav-menu-group--depth-4 > .iris-nav-menu-children),
1016
+ :where(.iris-nav-menu-group--depth-5 > .iris-nav-menu-children),
1017
+ :where(.iris-nav-menu-group--depth-6 > .iris-nav-menu-children),
1018
+ :where(.iris-nav-menu-group--depth-7 > .iris-nav-menu-children),
1019
+ :where(.iris-nav-menu-group--depth-8 > .iris-nav-menu-children),
1020
+ :where(.iris-nav-menu-group--depth-9 > .iris-nav-menu-children),
1021
+ :where(.iris-nav-menu-group > .iris-nav-menu-children) {
1022
+ display: none;
1023
+ }
1024
+
1025
+ :where(.iris-nav-menu-group[data-open='true'] > .iris-nav-menu-children) {
1026
+ display: block;
1027
+ }
1028
+
1029
+ :where(.iris-nav-menu--horizontal .iris-nav-menu-group > .iris-nav-menu-children) {
1030
+ position: absolute;
1031
+ min-width: 220px;
1032
+ padding: 6px;
1033
+ border: 1px solid var(--iris-border);
1034
+ border-radius: var(--iris-radius-md, 6px);
1035
+ background: var(--iris-surface);
1036
+ box-shadow: var(--iris-shadow-md);
1037
+ }
1038
+
1039
+ :where(.iris-nav-menu--horizontal .iris-nav-menu-group[data-depth='0'] > .iris-nav-menu-children) {
1040
+ inset-block-start: 100%;
1041
+ inset-inline-start: 0;
1042
+ z-index: 60;
1043
+ }
1044
+
1045
+ :where(.iris-nav-menu--horizontal .iris-nav-menu-group[data-depth]:not([data-depth='0']) > .iris-nav-menu-children) {
1046
+ inset-block-start: 0;
1047
+ inset-inline-start: 100%;
1048
+ z-index: 61;
1049
+ }
1050
+
1051
+ :where(.iris-nav-menu--collapsed .iris-nav-menu-item) {
1052
+ justify-content: center;
1053
+ padding-inline-start: var(--iris-nav-item-padding-inline);
1054
+ }
1055
+
1056
+ :where(.iris-nav-menu-item.is-collapsed) {
1057
+ justify-content: center;
1058
+ padding-inline: var(--iris-nav-item-padding-inline);
1059
+ }
1060
+
848
1061
  @media (prefers-reduced-motion: reduce) {
849
1062
  :where(.iris-nav-menu-arrow) {
850
1063
  transition: none;
@@ -958,49 +1171,25 @@ var IrisNavMenu = vue.defineComponent({
958
1171
  if (hoveredAtDepth) return hoveredAtDepth === key;
959
1172
  return interactionKeyAtDepth(focusedBranches.value, depth) === key;
960
1173
  };
961
- const itemStyle = (opts) => {
962
- const bg = opts.active ? "var(--iris-primary)" : opts.hovered && !opts.disabled ? "var(--iris-surface-hover, var(--iris-surface))" : "transparent";
963
- return {
964
- display: "flex",
965
- alignItems: "center",
966
- gap: "10px",
967
- width: props.orientation === "horizontal" && opts.depth === 0 ? "auto" : "100%",
968
- boxSizing: "border-box",
969
- border: "none",
970
- borderRadius: "var(--iris-radius-md, 6px)",
971
- background: bg,
972
- color: opts.active ? "var(--iris-primary-foreground, #fff)" : opts.trail ? "var(--iris-primary)" : "var(--iris-foreground)",
973
- font: "inherit",
974
- fontSize: "14px",
975
- fontWeight: opts.active || opts.trail ? "600" : "400",
976
- textAlign: "start",
977
- cursor: opts.disabled ? "not-allowed" : "pointer",
978
- opacity: opts.disabled ? "0.5" : "1",
979
- padding: props.collapsed ? "10px" : "8px 10px",
980
- paddingInlineStart: props.collapsed || props.orientation === "horizontal" ? "10px" : `${12 + opts.depth * 16}px`,
981
- justifyContent: props.collapsed ? "center" : "flex-start"
982
- };
1174
+ const itemClass = (opts) => {
1175
+ const depth = Math.min(9, opts.depth);
1176
+ return [
1177
+ "iris-nav-menu-item",
1178
+ `iris-nav-menu-item--depth-${depth}`,
1179
+ `iris-nav-menu-item--${opts.branch ? "branch" : "leaf"}`,
1180
+ opts.active ? "is-active" : void 0,
1181
+ opts.trail ? "is-trail" : void 0,
1182
+ opts.hovered ? "is-hovered" : void 0,
1183
+ opts.open ? "is-open" : void 0,
1184
+ opts.disabled ? "is-disabled" : void 0
1185
+ ].filter(Boolean);
983
1186
  };
984
- const hoverHandlers = (key) => ({
985
- onMouseenter: () => hovered.value = key,
986
- onMouseleave: () => {
987
- if (hovered.value === key) hovered.value = null;
988
- }
989
- });
990
1187
  const iconNode = (node, size = 18) => node.icon ? vue.h(IrisIcon, { name: node.icon, size }) : null;
991
1188
  const badgeNode = (node) => node.badge !== void 0 && node.badge !== "" && !props.collapsed ? vue.h(
992
1189
  "span",
993
1190
  {
994
- "data-iris-nav-badge": "",
995
- style: {
996
- marginInlineStart: "auto",
997
- fontSize: "11px",
998
- lineHeight: "1",
999
- padding: "2px 6px",
1000
- borderRadius: "999px",
1001
- background: "var(--iris-danger, #e5484d)",
1002
- color: "#fff"
1003
- }
1191
+ class: "iris-nav-menu-badge",
1192
+ "data-iris-nav-badge": ""
1004
1193
  },
1005
1194
  String(node.badge)
1006
1195
  ) : null;
@@ -1012,25 +1201,38 @@ var IrisNavMenu = vue.defineComponent({
1012
1201
  {
1013
1202
  key: node.key,
1014
1203
  type: "button",
1204
+ class: [
1205
+ ...itemClass({
1206
+ depth: 0,
1207
+ active,
1208
+ trail: false,
1209
+ hovered: hovered.value === node.key,
1210
+ open: false,
1211
+ disabled: !!node.disabled,
1212
+ branch
1213
+ }),
1214
+ "is-collapsed"
1215
+ ],
1015
1216
  "data-iris-nav-item": "",
1016
1217
  "data-key": node.key,
1017
1218
  "data-active": active ? "true" : void 0,
1018
1219
  "data-branch": branch ? "true" : void 0,
1220
+ "data-hovered": hovered.value === node.key ? "true" : void 0,
1019
1221
  disabled: node.disabled,
1020
1222
  title: node.title,
1021
1223
  "aria-label": branch ? `${node.title} (section)` : node.title,
1022
1224
  "aria-current": active && !branch ? "page" : void 0,
1023
- style: itemStyle({
1024
- depth: 0,
1025
- active,
1026
- trail: false,
1027
- hovered: hovered.value === node.key,
1028
- disabled: !!node.disabled
1029
- }),
1030
- ...hoverHandlers(node.key),
1225
+ onMouseenter: () => {
1226
+ if (!node.disabled) hovered.value = node.key;
1227
+ },
1228
+ onMouseleave: () => {
1229
+ if (hovered.value === node.key) hovered.value = null;
1230
+ },
1031
1231
  onClick: () => select(branch ? core.firstLeaf(node) : node)
1032
1232
  },
1033
- [iconNode(node, 20) ?? vue.h("span", { style: { fontWeight: "700" } }, node.title.charAt(0))]
1233
+ [
1234
+ iconNode(node, 20) ?? vue.h("span", { class: "iris-nav-menu-fallback-icon" }, node.title.charAt(0))
1235
+ ]
1034
1236
  );
1035
1237
  });
1036
1238
  const renderItem = (node, depth) => {
@@ -1045,24 +1247,33 @@ var IrisNavMenu = vue.defineComponent({
1045
1247
  "button",
1046
1248
  {
1047
1249
  type: "button",
1250
+ class: itemClass({
1251
+ depth,
1252
+ active,
1253
+ trail,
1254
+ hovered: hovered.value === node.key,
1255
+ open: branch ? shown : false,
1256
+ disabled: !!node.disabled,
1257
+ branch
1258
+ }),
1048
1259
  "data-iris-nav-item": "",
1049
1260
  "data-key": node.key,
1050
1261
  "data-branch": branch ? "true" : void 0,
1051
1262
  "data-active": active ? "true" : void 0,
1052
1263
  "data-active-trail": trail ? "true" : void 0,
1053
1264
  "data-open": branch && shown ? "true" : void 0,
1265
+ "data-hovered": hovered.value === node.key ? "true" : void 0,
1054
1266
  "data-depth": String(depth),
1267
+ "data-orientation": props.orientation,
1055
1268
  disabled: node.disabled,
1056
1269
  "aria-expanded": branch ? shown ? "true" : "false" : void 0,
1057
1270
  "aria-current": active ? "page" : void 0,
1058
- style: itemStyle({
1059
- depth,
1060
- active,
1061
- trail,
1062
- hovered: hovered.value === node.key,
1063
- disabled: !!node.disabled
1064
- }),
1065
- ...hoverHandlers(node.key),
1271
+ onMouseenter: () => {
1272
+ if (!node.disabled) hovered.value = node.key;
1273
+ },
1274
+ onMouseleave: () => {
1275
+ if (hovered.value === node.key) hovered.value = null;
1276
+ },
1066
1277
  onClick: () => branch ? toggle(node.key) : select(node)
1067
1278
  },
1068
1279
  [
@@ -1070,12 +1281,7 @@ var IrisNavMenu = vue.defineComponent({
1070
1281
  vue.h(
1071
1282
  "span",
1072
1283
  {
1073
- style: {
1074
- flex: branch ? "1" : "0 1 auto",
1075
- overflow: "hidden",
1076
- textOverflow: "ellipsis",
1077
- whiteSpace: "nowrap"
1078
- }
1284
+ class: "iris-nav-menu-label"
1079
1285
  },
1080
1286
  node.title
1081
1287
  ),
@@ -1084,16 +1290,18 @@ var IrisNavMenu = vue.defineComponent({
1084
1290
  name: horizontal && depth === 0 ? "chevron-down" : "chevron-right",
1085
1291
  size: 16,
1086
1292
  class: "iris-nav-menu-arrow",
1087
- "data-reversed": arrowReversed ? "true" : void 0,
1088
- style: { marginInlineStart: badgeNode(node) ? "6px" : "auto" }
1293
+ "data-reversed": arrowReversed ? "true" : void 0
1089
1294
  }) : null
1090
1295
  ]
1091
1296
  );
1092
- const groupStyle = horizontal && branch ? { position: "relative" } : void 0;
1093
1297
  if (!branch || !horizontal && !open)
1094
1298
  return vue.h(
1095
1299
  "div",
1096
- { key: node.key, "data-iris-nav-group": branch ? "" : void 0, style: groupStyle },
1300
+ {
1301
+ key: node.key,
1302
+ "data-iris-nav-group": branch ? "" : void 0,
1303
+ class: ["iris-nav-menu-group", `iris-nav-menu-group--depth-${Math.min(9, depth)}`]
1304
+ },
1097
1305
  [row]
1098
1306
  );
1099
1307
  return vue.h(
@@ -1102,7 +1310,11 @@ var IrisNavMenu = vue.defineComponent({
1102
1310
  key: node.key,
1103
1311
  "data-iris-nav-group": "",
1104
1312
  "data-open": shown ? "true" : void 0,
1105
- style: groupStyle,
1313
+ "data-depth": String(depth),
1314
+ class: [
1315
+ "iris-nav-menu-group",
1316
+ `iris-nav-menu-group--depth-${Math.min(9, depth)}`
1317
+ ],
1106
1318
  ...horizontal ? {
1107
1319
  onMouseenter: () => setBranchInteraction(hoveredBranches, node.key, true),
1108
1320
  onMouseleave: () => setBranchInteraction(hoveredBranches, node.key, false),
@@ -1121,22 +1333,10 @@ var IrisNavMenu = vue.defineComponent({
1121
1333
  vue.h(
1122
1334
  "div",
1123
1335
  {
1336
+ class: "iris-nav-menu-children",
1124
1337
  "data-iris-nav-children": "",
1125
1338
  role: "group",
1126
- "aria-hidden": horizontal && !shown ? "true" : void 0,
1127
- style: horizontal ? {
1128
- display: shown ? "block" : "none",
1129
- position: "absolute",
1130
- insetBlockStart: depth === 0 ? "100%" : "0",
1131
- insetInlineStart: depth === 0 ? "0" : "100%",
1132
- zIndex: depth === 0 ? "60" : "61",
1133
- minWidth: "220px",
1134
- padding: "6px",
1135
- border: "1px solid var(--iris-border)",
1136
- borderRadius: "var(--iris-radius-md, 6px)",
1137
- background: "var(--iris-surface)",
1138
- boxShadow: "var(--iris-shadow-md)"
1139
- } : void 0
1339
+ "aria-hidden": horizontal && !shown ? "true" : void 0
1140
1340
  },
1141
1341
  (node.children ?? []).map((child) => renderItem(child, depth + 1))
1142
1342
  )
@@ -1190,22 +1390,22 @@ var IrisNavMenu = vue.defineComponent({
1190
1390
  }
1191
1391
  }
1192
1392
  };
1393
+ const menuClass = [
1394
+ "iris-nav-menu",
1395
+ `iris-nav-menu--${props.orientation}`,
1396
+ props.collapsed ? "iris-nav-menu--collapsed" : "iris-nav-menu--expanded"
1397
+ ];
1193
1398
  return () => vue.h(
1194
1399
  "nav",
1195
1400
  {
1196
1401
  ...attrs,
1402
+ class: [...menuClass, attrs.class],
1197
1403
  "data-iris-nav-menu": "",
1198
1404
  "data-collapsed": props.collapsed ? "true" : void 0,
1199
1405
  "data-orientation": props.orientation,
1200
1406
  "aria-label": props.ariaLabel ?? t("admin.nav"),
1201
1407
  onKeydown,
1202
- style: {
1203
- display: "flex",
1204
- flexDirection: props.orientation === "horizontal" ? "row" : "column",
1205
- alignItems: props.orientation === "horizontal" ? "center" : void 0,
1206
- gap: "2px",
1207
- ...attrs.style ?? {}
1208
- }
1408
+ style: attrs.style
1209
1409
  },
1210
1410
  props.collapsed ? renderCollapsed() : tree.value.map((node) => renderItem(node, 0))
1211
1411
  );