@nocode-factory/sanity-kit 2.20.0 → 2.20.1

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.d.ts CHANGED
@@ -1339,7 +1339,7 @@ export declare function ActorName(props: {
1339
1339
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1340
1340
  * le vérifie.
1341
1341
  */
1342
- export declare const KIT_VERSION = "2.20.0";
1342
+ export declare const KIT_VERSION = "2.20.1";
1343
1343
  /**
1344
1344
  * Données de la page proposées comme colonnes.
1345
1345
  *
package/dist/index.js CHANGED
@@ -1417,7 +1417,7 @@ function explainGrantError(error) {
1417
1417
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1418
1418
  * le vérifie.
1419
1419
  */
1420
- const KIT_VERSION = "2.20.0";
1420
+ const KIT_VERSION = "2.20.1";
1421
1421
  /**
1422
1422
  * Signale ce Studio au service du kit, une fois par montage.
1423
1423
  *
@@ -1744,7 +1744,7 @@ function useKitUpdate() {
1744
1744
  !controller.signal.aborted && body?.version && setLatest(body.version);
1745
1745
  }).catch(() => {}), () => controller.abort();
1746
1746
  }, []);
1747
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.20.0") > 0);
1747
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.20.1") > 0);
1748
1748
  return {
1749
1749
  current: KIT_VERSION,
1750
1750
  latest,
@@ -7749,34 +7749,28 @@ function createOverrideInput(config) {
7749
7749
  });
7750
7750
  }
7751
7751
  function WithDot(props) {
7752
- let { rel, inList, shortName, parent, ...inputProps } = props, client = useKitClient(), languageField = config.i18n?.field ?? "language", language = useFormValue([languageField]) ?? null, inherited = defaultValueAt(useComponentDefaults(client, defaultsType, languageField, language), shortName, rel), field = rel[rel.length - 1] ?? "", router = useRouter();
7753
- if (isEmptyValue(inputProps.value) && !isEmptyValue(inherited)) {
7754
- let st = inputProps.schemaType, placeholder = (st.jsonType === "string" || st.jsonType === "number") && !st.options?.list?.length ? inheritedPlaceholder(inherited) : null, withPlaceholder = placeholder === null ? inputProps : {
7755
- ...inputProps,
7756
- elementProps: {
7757
- ...inputProps.elementProps,
7758
- placeholder
7759
- }
7760
- };
7761
- return /* @__PURE__ */ jsxs(Stack, {
7762
- gap: 2,
7763
- children: [inputProps.renderDefault(withPlaceholder), placeholder === null && /* @__PURE__ */ jsxs(Text, {
7764
- size: 0,
7765
- muted: !0,
7766
- children: ["Valeur par défaut du composant : ", describeValue(inherited)]
7767
- })]
7768
- });
7769
- }
7770
- if (!isOverride(inputProps.value, inherited, field, parent)) return inputProps.renderDefault(inputProps);
7771
- let action = resetAction(inherited), onClick = action.kind === "noDefault" ? () => router.navigateIntent("edit", componentIntentParams(`${namespace}${shortName}`, namespace, config.componentPreview, defaultsType)) : inList ? () => inputProps.onChange(set(structuredClone(inherited))) : () => inputProps.onChange(unset());
7752
+ let { rel, inList, shortName, parent, ...inputProps } = props, client = useKitClient(), languageField = config.i18n?.field ?? "language", language = useFormValue([languageField]) ?? null, inherited = defaultValueAt(useComponentDefaults(client, defaultsType, languageField, language), shortName, rel), field = rel[rel.length - 1] ?? "", router = useRouter(), inherits = isEmptyValue(inputProps.value) && !isEmptyValue(inherited), st = inputProps.schemaType, freeText = (st.jsonType === "string" || st.jsonType === "number") && !st.options?.list?.length, placeholder = inherits && freeText ? inheritedPlaceholder(inherited) : null, shown = placeholder === null ? inputProps : {
7753
+ ...inputProps,
7754
+ elementProps: {
7755
+ ...inputProps.elementProps,
7756
+ placeholder
7757
+ }
7758
+ }, override = !inherits && isOverride(inputProps.value, inherited, field, parent), action = resetAction(inherited), onClick = action.kind === "noDefault" ? () => router.navigateIntent("edit", componentIntentParams(`${namespace}${shortName}`, namespace, config.componentPreview, defaultsType)) : inList ? () => inputProps.onChange(set(structuredClone(inherited))) : () => inputProps.onChange(unset());
7772
7759
  return /* @__PURE__ */ jsxs(Flex, {
7773
7760
  align: "flex-start",
7774
7761
  gap: 2,
7775
- children: [/* @__PURE__ */ jsx(Box, {
7762
+ children: [/* @__PURE__ */ jsxs(Box, {
7776
7763
  flex: 1,
7777
7764
  style: { minWidth: 0 },
7778
- children: inputProps.renderDefault(inputProps)
7779
- }), /* @__PURE__ */ jsx(OverrideDot, {
7765
+ children: [inputProps.renderDefault(shown), inherits && placeholder === null && /* @__PURE__ */ jsx(Box, {
7766
+ marginTop: 2,
7767
+ children: /* @__PURE__ */ jsxs(Text, {
7768
+ size: 0,
7769
+ muted: !0,
7770
+ children: ["Valeur par défaut du composant : ", describeValue(inherited)]
7771
+ })
7772
+ })]
7773
+ }), override && /* @__PURE__ */ jsx(OverrideDot, {
7780
7774
  hasDefault: action.kind !== "noDefault",
7781
7775
  full: describeValue(inherited),
7782
7776
  short: shortValue(inherited),
@@ -7938,16 +7932,14 @@ function createSlugUrlInput(config) {
7938
7932
  path: pageType.path,
7939
7933
  pathPrefix: pageType.pathPrefix,
7940
7934
  locale
7941
- }, config.i18n) : null, url = toUrl(config.previewUrl, path);
7942
- if (!url) return props.renderDefault(props);
7943
- let copy = () => {
7944
- navigator.clipboard.writeText(url).then(() => {
7935
+ }, config.i18n) : null, url = toUrl(config.previewUrl, path), copy = () => {
7936
+ url && navigator.clipboard.writeText(url).then(() => {
7945
7937
  setCopied(!0), window.setTimeout(() => setCopied(!1), 1500);
7946
7938
  });
7947
7939
  };
7948
7940
  return /* @__PURE__ */ jsxs(Stack, {
7949
7941
  gap: 2,
7950
- children: [props.renderDefault(props), /* @__PURE__ */ jsx(Card, {
7942
+ children: [props.renderDefault(props), url && /* @__PURE__ */ jsx(Card, {
7951
7943
  tone: "primary",
7952
7944
  padding: 2,
7953
7945
  radius: 2,
@@ -8040,14 +8032,12 @@ function fieldPathKey(path) {
8040
8032
  */
8041
8033
  function withTranslationTodo(Inner, config) {
8042
8034
  function TranslationTodoInput(props) {
8043
- let id = useFormValue(["_id"]), client = useKitClient(), todo = useTranslationTodo(client, config.i18n ? id : void 0), [busy, setBusy] = useState(!1), key = fieldPathKey(props.path), inner = createElement(Inner, props);
8044
- if (!todo?.paths?.includes(key)) return inner;
8045
- let done = () => {
8046
- setBusy(!0), client.patch(todo._id).set({ paths: (todo.paths ?? []).filter((p) => p !== key) }).commit().finally(() => setBusy(!1));
8035
+ let id = useFormValue(["_id"]), client = useKitClient(), todo = useTranslationTodo(client, config.i18n ? id : void 0), [busy, setBusy] = useState(!1), key = fieldPathKey(props.path), inner = createElement(Inner, props), show = !!todo?.paths?.includes(key), done = () => {
8036
+ todo && (setBusy(!0), client.patch(todo._id).set({ paths: (todo.paths ?? []).filter((p) => p !== key) }).commit().finally(() => setBusy(!1)));
8047
8037
  };
8048
8038
  return /* @__PURE__ */ jsxs(Stack, {
8049
8039
  gap: 2,
8050
- children: [inner, /* @__PURE__ */ jsx(Card, {
8040
+ children: [inner, show && /* @__PURE__ */ jsx(Card, {
8051
8041
  tone: "caution",
8052
8042
  padding: 2,
8053
8043
  radius: 2,
@@ -8060,7 +8050,7 @@ function withTranslationTodo(Inner, config) {
8060
8050
  style: { flex: 1 },
8061
8051
  children: [
8062
8052
  "À traduire : modifié dans la version ",
8063
- (todo.sourceLanguage ?? "").toUpperCase(),
8053
+ (todo?.sourceLanguage ?? "").toUpperCase(),
8064
8054
  "."
8065
8055
  ]
8066
8056
  }), /* @__PURE__ */ jsx(Button, {