@blocklet/labels 2.0.84 → 2.0.85

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.es.js CHANGED
@@ -1091,6 +1091,12 @@ function GithubLabelPicker({
1091
1091
  }
1092
1092
  return void 0;
1093
1093
  };
1094
+ const isLabelPermitted = (node) => {
1095
+ const label = node.data;
1096
+ const passportsToCheck = [...label.passports || [], ...label.type === "system" ? ["admin", "owner"] : []];
1097
+ const isPermitted = !enableAccessControl || isAdmin || hasAnyPassport(passportsToCheck);
1098
+ return isPermitted;
1099
+ };
1094
1100
  if (loading) {
1095
1101
  return null;
1096
1102
  }
@@ -1185,15 +1191,11 @@ function GithubLabelPicker({
1185
1191
  renderTags: () => null,
1186
1192
  noOptionsText: noLabelsText || "No labels",
1187
1193
  renderOption: (props, option, { selected }) => {
1188
- const label = option.data;
1189
- const passportsToCheck = [
1190
- ...label.passports || [],
1191
- ...label.type === "system" ? ["admin", "owner"] : []
1192
- ];
1193
- const isPermitted = !enableAccessControl || isAdmin || hasAnyPassport(passportsToCheck);
1194
+ const isPermitted = isLabelPermitted(option);
1194
1195
  if (!isPermitted) {
1195
1196
  return null;
1196
1197
  }
1198
+ const label = option.data;
1197
1199
  return /* @__PURE__ */ createElement(
1198
1200
  Box$1,
1199
1201
  {
@@ -1223,18 +1225,22 @@ function GithubLabelPicker({
1223
1225
  },
1224
1226
  groupBy: () => "x",
1225
1227
  renderGroup: (params) => {
1228
+ const recentLabelNodes = getLabelsByIds(initialRecentLabels).filter(isLabelPermitted);
1226
1229
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1227
- !!(initialRecentLabels == null ? void 0 : initialRecentLabels.length) && /* @__PURE__ */ jsxs("li", { children: [
1230
+ !!(recentLabelNodes == null ? void 0 : recentLabelNodes.length) && /* @__PURE__ */ jsxs("li", { children: [
1228
1231
  /* @__PURE__ */ jsx(Box$1, { sx: { mb: 0.5, fontSize: 12, fontWeight: "medium" }, children: t("label.recently") }),
1229
- /* @__PURE__ */ jsx(Box$1, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75, mb: 2 }, children: initialRecentLabels.map((x) => {
1230
- const selected = value == null ? void 0 : value.includes(x);
1232
+ /* @__PURE__ */ jsx(Box$1, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75, mb: 2 }, children: recentLabelNodes.map((x) => {
1233
+ const labelId = x.data.id;
1234
+ const selected = value == null ? void 0 : value.includes(labelId);
1231
1235
  return /* @__PURE__ */ jsx(
1232
1236
  LabelChip,
1233
1237
  {
1234
- label: getLabelsByIds([x])[0],
1238
+ label: x,
1235
1239
  fullName: false,
1236
1240
  onClick: () => {
1237
- handleChange(selected ? pendingValue.filter((y) => y !== x) : [...pendingValue, x]);
1241
+ handleChange(
1242
+ selected ? pendingValue.filter((y) => y !== labelId) : [...pendingValue, labelId]
1243
+ );
1238
1244
  },
1239
1245
  sx: {
1240
1246
  height: 24,
@@ -1243,7 +1249,7 @@ function GithubLabelPicker({
1243
1249
  ...getSelectedSx(selected)
1244
1250
  }
1245
1251
  },
1246
- x
1252
+ labelId
1247
1253
  );
1248
1254
  }) })
1249
1255
  ] }),
package/dist/index.umd.js CHANGED
@@ -1078,6 +1078,12 @@ var __publicField = (obj, key, value) => {
1078
1078
  }
1079
1079
  return void 0;
1080
1080
  };
1081
+ const isLabelPermitted = (node) => {
1082
+ const label = node.data;
1083
+ const passportsToCheck = [...label.passports || [], ...label.type === "system" ? ["admin", "owner"] : []];
1084
+ const isPermitted = !enableAccessControl || isAdmin || hasAnyPassport(passportsToCheck);
1085
+ return isPermitted;
1086
+ };
1081
1087
  if (loading) {
1082
1088
  return null;
1083
1089
  }
@@ -1172,15 +1178,11 @@ var __publicField = (obj, key, value) => {
1172
1178
  renderTags: () => null,
1173
1179
  noOptionsText: noLabelsText || "No labels",
1174
1180
  renderOption: (props, option, { selected }) => {
1175
- const label = option.data;
1176
- const passportsToCheck = [
1177
- ...label.passports || [],
1178
- ...label.type === "system" ? ["admin", "owner"] : []
1179
- ];
1180
- const isPermitted = !enableAccessControl || isAdmin || hasAnyPassport(passportsToCheck);
1181
+ const isPermitted = isLabelPermitted(option);
1181
1182
  if (!isPermitted) {
1182
1183
  return null;
1183
1184
  }
1185
+ const label = option.data;
1184
1186
  return /* @__PURE__ */ react.createElement(
1185
1187
  material.Box,
1186
1188
  {
@@ -1210,18 +1212,22 @@ var __publicField = (obj, key, value) => {
1210
1212
  },
1211
1213
  groupBy: () => "x",
1212
1214
  renderGroup: (params) => {
1215
+ const recentLabelNodes = getLabelsByIds(initialRecentLabels).filter(isLabelPermitted);
1213
1216
  return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
1214
- !!(initialRecentLabels == null ? void 0 : initialRecentLabels.length) && /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
1217
+ !!(recentLabelNodes == null ? void 0 : recentLabelNodes.length) && /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
1215
1218
  /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { mb: 0.5, fontSize: 12, fontWeight: "medium" }, children: t("label.recently") }),
1216
- /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75, mb: 2 }, children: initialRecentLabels.map((x) => {
1217
- const selected = value == null ? void 0 : value.includes(x);
1219
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.75, mb: 2 }, children: recentLabelNodes.map((x) => {
1220
+ const labelId = x.data.id;
1221
+ const selected = value == null ? void 0 : value.includes(labelId);
1218
1222
  return /* @__PURE__ */ jsxRuntime.jsx(
1219
1223
  LabelChip,
1220
1224
  {
1221
- label: getLabelsByIds([x])[0],
1225
+ label: x,
1222
1226
  fullName: false,
1223
1227
  onClick: () => {
1224
- handleChange(selected ? pendingValue.filter((y) => y !== x) : [...pendingValue, x]);
1228
+ handleChange(
1229
+ selected ? pendingValue.filter((y) => y !== labelId) : [...pendingValue, labelId]
1230
+ );
1225
1231
  },
1226
1232
  sx: {
1227
1233
  height: 24,
@@ -1230,7 +1236,7 @@ var __publicField = (obj, key, value) => {
1230
1236
  ...getSelectedSx(selected)
1231
1237
  }
1232
1238
  },
1233
- x
1239
+ labelId
1234
1240
  );
1235
1241
  }) })
1236
1242
  ] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/labels",
3
- "version": "2.0.84",
3
+ "version": "2.0.85",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@blocklet/translation-input": "2.0.84",
31
+ "@blocklet/translation-input": "2.0.85",
32
32
  "@emotion/css": "^11.10.5",
33
33
  "@emotion/react": "^11.10.5",
34
34
  "@emotion/styled": "^11.10.5",
@@ -83,5 +83,5 @@
83
83
  "resolutions": {
84
84
  "react": "^18.2.0"
85
85
  },
86
- "gitHead": "616816e0b718c1281dc04a8f25b898c4c023cb80"
86
+ "gitHead": "a59a345501aeab25f6c71c1aeacfb94fd2e55de5"
87
87
  }