@blocklet/labels 1.6.141 → 1.6.143

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
@@ -658,7 +658,7 @@ function LabelsProvider({ fetchLabels, createLabel, children }) {
658
658
  [localeTransformer, getParents]
659
659
  );
660
660
  const parseLabelIds = useCallback((labelIdsStr) => {
661
- return (labelIdsStr == null ? void 0 : labelIdsStr.split(",")) || [];
661
+ return (labelIdsStr == null ? void 0 : labelIdsStr.split(",").filter(Boolean)) || [];
662
662
  }, []);
663
663
  const stringifyLabelIds = useCallback((labelIds = []) => {
664
664
  if (!(labelIds == null ? void 0 : labelIds.length)) {
@@ -1111,17 +1111,31 @@ function Labels2({ labels, sx, renderLabel, prepend, displaySystemLabels = true
1111
1111
  if (!item) {
1112
1112
  return null;
1113
1113
  }
1114
+ const labelChip = /* @__PURE__ */ jsx(LabelChip, { label: item }, item.data.id);
1114
1115
  if (renderLabel) {
1115
- return renderLabel(item);
1116
+ return renderLabel(item, labelChip);
1116
1117
  }
1117
- return /* @__PURE__ */ jsx(LabelChip, { label: item }, item.data.id);
1118
+ return labelChip;
1118
1119
  })
1119
1120
  ] });
1120
1121
  }
1121
- function LabelsInput({ value = [], onChange, ...rest }) {
1122
+ function LabelsInput({
1123
+ value = [],
1124
+ onChange,
1125
+ sx,
1126
+ ...rest
1127
+ }) {
1122
1128
  var _a;
1123
1129
  const { getLabelsByIds, loading } = LabelsContainer.useContainer();
1124
1130
  const valueOptions = useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
1131
+ const mergedSx = [
1132
+ {
1133
+ "& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, py: 0.75 },
1134
+ "& .MuiInputBase-input": { width: !(value == null ? void 0 : value.length) ? "initial" : "20px", p: 0 }
1135
+ },
1136
+ ...Array.isArray(sx) ? sx : [sx]
1137
+ ];
1138
+ const placeholder = !(value == null ? void 0 : value.length) ? rest.placeholder || "Select labels" : "";
1125
1139
  if (loading) {
1126
1140
  return null;
1127
1141
  }
@@ -1134,6 +1148,7 @@ function LabelsInput({ value = [], onChange, ...rest }) {
1134
1148
  TextField,
1135
1149
  {
1136
1150
  ...rest,
1151
+ placeholder,
1137
1152
  fullWidth: true,
1138
1153
  InputProps: {
1139
1154
  autoComplete: "off",
@@ -1143,10 +1158,7 @@ function LabelsInput({ value = [], onChange, ...rest }) {
1143
1158
  ...valueOptions.map((x, index) => /* @__PURE__ */ jsx(LabelChip, { label: x }, index))
1144
1159
  ].filter(Boolean)
1145
1160
  },
1146
- sx: {
1147
- "& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, p: 1 },
1148
- "& .MuiInputBase-input": { width: (rest == null ? void 0 : rest.placeholder) ? "initial" : "20px", p: 0 }
1149
- }
1161
+ sx: mergedSx
1150
1162
  }
1151
1163
  )
1152
1164
  }
package/dist/index.umd.js CHANGED
@@ -646,7 +646,7 @@ var __publicField = (obj, key, value) => {
646
646
  [localeTransformer, getParents]
647
647
  );
648
648
  const parseLabelIds = react.useCallback((labelIdsStr) => {
649
- return (labelIdsStr == null ? void 0 : labelIdsStr.split(",")) || [];
649
+ return (labelIdsStr == null ? void 0 : labelIdsStr.split(",").filter(Boolean)) || [];
650
650
  }, []);
651
651
  const stringifyLabelIds = react.useCallback((labelIds = []) => {
652
652
  if (!(labelIds == null ? void 0 : labelIds.length)) {
@@ -1099,17 +1099,31 @@ var __publicField = (obj, key, value) => {
1099
1099
  if (!item) {
1100
1100
  return null;
1101
1101
  }
1102
+ const labelChip = /* @__PURE__ */ jsxRuntime.jsx(LabelChip, { label: item }, item.data.id);
1102
1103
  if (renderLabel) {
1103
- return renderLabel(item);
1104
+ return renderLabel(item, labelChip);
1104
1105
  }
1105
- return /* @__PURE__ */ jsxRuntime.jsx(LabelChip, { label: item }, item.data.id);
1106
+ return labelChip;
1106
1107
  })
1107
1108
  ] });
1108
1109
  }
1109
- function LabelsInput({ value = [], onChange, ...rest }) {
1110
+ function LabelsInput({
1111
+ value = [],
1112
+ onChange,
1113
+ sx,
1114
+ ...rest
1115
+ }) {
1110
1116
  var _a;
1111
1117
  const { getLabelsByIds, loading } = LabelsContainer.useContainer();
1112
1118
  const valueOptions = react.useMemo(() => getLabelsByIds(value), [getLabelsByIds, value]);
1119
+ const mergedSx = [
1120
+ {
1121
+ "& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, py: 0.75 },
1122
+ "& .MuiInputBase-input": { width: !(value == null ? void 0 : value.length) ? "initial" : "20px", p: 0 }
1123
+ },
1124
+ ...Array.isArray(sx) ? sx : [sx]
1125
+ ];
1126
+ const placeholder = !(value == null ? void 0 : value.length) ? rest.placeholder || "Select labels" : "";
1113
1127
  if (loading) {
1114
1128
  return null;
1115
1129
  }
@@ -1122,6 +1136,7 @@ var __publicField = (obj, key, value) => {
1122
1136
  material.TextField,
1123
1137
  {
1124
1138
  ...rest,
1139
+ placeholder,
1125
1140
  fullWidth: true,
1126
1141
  InputProps: {
1127
1142
  autoComplete: "off",
@@ -1131,10 +1146,7 @@ var __publicField = (obj, key, value) => {
1131
1146
  ...valueOptions.map((x, index) => /* @__PURE__ */ jsxRuntime.jsx(LabelChip, { label: x }, index))
1132
1147
  ].filter(Boolean)
1133
1148
  },
1134
- sx: {
1135
- "& .MuiInputBase-root": { flexWrap: "wrap", gap: 0.5, p: 1 },
1136
- "& .MuiInputBase-input": { width: (rest == null ? void 0 : rest.placeholder) ? "initial" : "20px", p: 0 }
1137
- }
1149
+ sx: mergedSx
1138
1150
  }
1139
1151
  )
1140
1152
  }
@@ -3,5 +3,5 @@ interface LabelsInputProps {
3
3
  value: string[];
4
4
  onChange: (value: string[]) => void;
5
5
  }
6
- export declare function LabelsInput({ value, onChange, ...rest }: LabelsInputProps & Omit<TextFieldProps, 'onChange'>): import("react/jsx-runtime").JSX.Element | null;
6
+ export declare function LabelsInput({ value, onChange, sx, ...rest }: LabelsInputProps & Omit<TextFieldProps, 'onChange'>): import("react/jsx-runtime").JSX.Element | null;
7
7
  export {};
@@ -4,7 +4,7 @@ import type { LabelTreeNode } from './tree';
4
4
  interface LabelsProps {
5
5
  labels: string[] | undefined | null;
6
6
  sx?: SxProps;
7
- renderLabel?: (label: LabelTreeNode) => JSX.Element;
7
+ renderLabel?: (label: LabelTreeNode, labelChip: React.ReactElement) => JSX.Element;
8
8
  prepend?: React.ReactNode;
9
9
  displaySystemLabels?: boolean;
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/labels",
3
- "version": "1.6.141",
3
+ "version": "1.6.143",
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": "1.6.141",
31
+ "@blocklet/translation-input": "1.6.143",
32
32
  "@emotion/css": "^11.10.5",
33
33
  "@emotion/react": "^11.10.5",
34
34
  "@emotion/styled": "^11.10.5",
@@ -80,5 +80,5 @@
80
80
  "resolutions": {
81
81
  "react": "^18.2.0"
82
82
  },
83
- "gitHead": "a8b2ab4266196099fbebee92873db434486213be"
83
+ "gitHead": "dd8210e9eb9b27b281583b4a5ce302a8c72b1ea0"
84
84
  }