@drawbridge/components 0.1.46 → 0.1.48

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.
Files changed (162) hide show
  1. package/dist/bridge/cart-drawer.js +152 -0
  2. package/dist/bridge/cart-drawer.mjs +123 -0
  3. package/dist/bridge/fields.js +278 -0
  4. package/dist/bridge/fields.mjs +276 -1
  5. package/dist/bridge/form-subdomain-checkout.js +687 -0
  6. package/dist/bridge/form-subdomain-checkout.mjs +665 -0
  7. package/dist/bridge/form-subdomain-shop-modal.js +234 -274
  8. package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
  9. package/dist/bridge/form-subdomain-shop.js +4 -1
  10. package/dist/bridge/form-subdomain-shop.mjs +4 -1
  11. package/dist/bridge/form-subdomain.js +24 -5
  12. package/dist/bridge/form-subdomain.mjs +25 -6
  13. package/dist/bridge/lib/age-gate.js +12 -0
  14. package/dist/bridge/lib/age-gate.mjs +11 -0
  15. package/dist/bridge/lib/cart.js +79 -0
  16. package/dist/bridge/lib/cart.mjs +48 -0
  17. package/dist/bridge/lib/checkout-kit.js +2 -32
  18. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  19. package/dist/bridge/lib/entry.js +41 -0
  20. package/dist/bridge/lib/entry.mjs +40 -0
  21. package/dist/bridge/product-tile.js +13 -6
  22. package/dist/bridge/product-tile.mjs +13 -6
  23. package/dist/bridge/template-layout.js +263 -129
  24. package/dist/bridge/template-layout.mjs +264 -130
  25. package/dist/bridge/template-modal.js +39 -74
  26. package/dist/bridge/template-modal.mjs +40 -75
  27. package/dist/dashboard/avatar.js +2 -3
  28. package/dist/dashboard/avatar.mjs +2 -3
  29. package/dist/dashboard/buttons-subscription.js +1 -1
  30. package/dist/dashboard/buttons-subscription.mjs +1 -1
  31. package/dist/dashboard/campaign-form.js +179 -155
  32. package/dist/dashboard/campaign-form.mjs +179 -155
  33. package/dist/dashboard/campaign-share.js +347 -0
  34. package/dist/dashboard/campaign-share.mjs +314 -0
  35. package/dist/dashboard/card-affiliate.js +1 -1
  36. package/dist/dashboard/card-affiliate.mjs +1 -1
  37. package/dist/dashboard/card-campaign-switch.js +4 -1
  38. package/dist/dashboard/card-campaign-switch.mjs +4 -1
  39. package/dist/dashboard/card-order.js +22 -4
  40. package/dist/dashboard/card-order.mjs +22 -4
  41. package/dist/dashboard/embed-stripe.js +145 -0
  42. package/dist/dashboard/embed-stripe.mjs +116 -0
  43. package/dist/dashboard/form-admin-provider.js +71 -17
  44. package/dist/dashboard/form-admin-provider.mjs +71 -17
  45. package/dist/dashboard/form-file-upload.js +3 -2
  46. package/dist/dashboard/form-file-upload.mjs +4 -3
  47. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  48. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  49. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  50. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  51. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  52. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  53. package/dist/dashboard/form-organization-campaign-page.js +73 -39
  54. package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
  55. package/dist/dashboard/form-organization-campaign.js +82 -0
  56. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  57. package/dist/dashboard/form-organization-connection.js +48 -6
  58. package/dist/dashboard/form-organization-connection.mjs +48 -7
  59. package/dist/dashboard/form-organization-product.js +1461 -0
  60. package/dist/dashboard/form-organization-product.mjs +1425 -0
  61. package/dist/dashboard/form-organization-workflow.js +72 -1
  62. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  63. package/dist/dashboard/form-otc.js +4 -5
  64. package/dist/dashboard/form-otc.mjs +4 -5
  65. package/dist/dashboard/form-stripe.js +12 -5
  66. package/dist/dashboard/form-stripe.mjs +12 -5
  67. package/dist/dashboard/input-combobox.js +6 -0
  68. package/dist/dashboard/input-combobox.mjs +6 -0
  69. package/dist/dashboard/input-fields.js +37 -161
  70. package/dist/dashboard/input-fields.mjs +37 -161
  71. package/dist/dashboard/input-file.js +21 -4
  72. package/dist/dashboard/input-file.mjs +21 -4
  73. package/dist/dashboard/input-font.js +2 -0
  74. package/dist/dashboard/input-font.mjs +2 -0
  75. package/dist/dashboard/input-gallery.js +201 -0
  76. package/dist/dashboard/input-gallery.mjs +172 -0
  77. package/dist/dashboard/input-group-ai.js +15 -3
  78. package/dist/dashboard/input-group-ai.mjs +15 -3
  79. package/dist/dashboard/lib/ab-tests.js +2 -2
  80. package/dist/dashboard/lib/ab-tests.mjs +2 -2
  81. package/dist/dashboard/lib/connection-controls.js +5 -2
  82. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  83. package/dist/dashboard/lib/form-page.js +1 -1
  84. package/dist/dashboard/lib/form-page.mjs +1 -1
  85. package/dist/dashboard/lib/menu.js +19 -0
  86. package/dist/dashboard/lib/menu.mjs +18 -0
  87. package/dist/dashboard/lib/products.js +169 -0
  88. package/dist/dashboard/lib/products.mjs +135 -0
  89. package/dist/dashboard/lib/settings-paths.js +35 -0
  90. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  91. package/dist/dashboard/lib/uppy.js +10 -1
  92. package/dist/dashboard/lib/uppy.mjs +11 -2
  93. package/dist/dashboard/menu.js +13 -2
  94. package/dist/dashboard/menu.mjs +13 -2
  95. package/dist/dashboard/order-sections.js +456 -6
  96. package/dist/dashboard/order-sections.mjs +453 -7
  97. package/dist/dashboard/preview.js +119 -52
  98. package/dist/dashboard/preview.mjs +119 -52
  99. package/dist/dashboard/provider-ui.js +9 -7
  100. package/dist/dashboard/provider-ui.mjs +9 -7
  101. package/dist/dashboard/recharts.js +10 -4
  102. package/dist/dashboard/recharts.mjs +10 -4
  103. package/dist/dashboard/shipping-rates.js +404 -0
  104. package/dist/dashboard/shipping-rates.mjs +371 -0
  105. package/dist/dashboard/template-buyer.js +301 -0
  106. package/dist/dashboard/template-buyer.mjs +267 -0
  107. package/dist/dashboard/template-dashboard.js +11 -1
  108. package/dist/dashboard/template-dashboard.mjs +11 -1
  109. package/dist/dashboard/template-design.js +209 -130
  110. package/dist/dashboard/template-design.mjs +210 -131
  111. package/dist/dashboard/template-ui.js +157 -55
  112. package/dist/dashboard/template-ui.mjs +158 -56
  113. package/dist/icons/flags.js +134 -0
  114. package/dist/icons/flags.mjs +115 -0
  115. package/dist/input-checkbox.js +28 -10
  116. package/dist/input-checkbox.mjs +28 -10
  117. package/dist/product.js +96 -24
  118. package/dist/product.mjs +97 -25
  119. package/dist/shared/carousel.js +14 -5
  120. package/dist/shared/carousel.mjs +14 -5
  121. package/dist/shared/lib/helpers.js +54 -6
  122. package/dist/shared/lib/helpers.mjs +53 -8
  123. package/dist/shared/order-summary.js +139 -0
  124. package/dist/shared/order-summary.mjs +110 -0
  125. package/package.json +84 -4
  126. package/types/bridge/cart-drawer.d.ts +31 -0
  127. package/types/bridge/fields.d.ts +14 -2
  128. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  129. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  130. package/types/bridge/form-subdomain.d.ts +13 -0
  131. package/types/bridge/lib/age-gate.d.ts +5 -0
  132. package/types/bridge/lib/cart.d.ts +44 -0
  133. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  134. package/types/bridge/lib/entry.d.ts +5 -0
  135. package/types/bridge/product-tile.d.ts +2 -0
  136. package/types/dashboard/campaign-share.d.ts +16 -0
  137. package/types/dashboard/card-order.d.ts +6 -0
  138. package/types/dashboard/embed-stripe.d.ts +25 -0
  139. package/types/dashboard/form-admin-provider.d.ts +9 -2
  140. package/types/dashboard/form-file-upload.d.ts +2 -1
  141. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  142. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  143. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  144. package/types/dashboard/form-organization-campaign-page.d.ts +8 -1
  145. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  146. package/types/dashboard/form-organization-connection.d.ts +11 -0
  147. package/types/dashboard/form-organization-product.d.ts +24 -0
  148. package/types/dashboard/form-otc.d.ts +5 -1
  149. package/types/dashboard/form-stripe.d.ts +3 -2
  150. package/types/dashboard/input-combobox.d.ts +2 -0
  151. package/types/dashboard/input-file.d.ts +2 -0
  152. package/types/dashboard/input-gallery.d.ts +14 -0
  153. package/types/dashboard/lib/products.d.ts +14 -0
  154. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  155. package/types/dashboard/order-sections.d.ts +24 -1
  156. package/types/dashboard/preview.d.ts +11 -3
  157. package/types/dashboard/shipping-rates.d.ts +26 -0
  158. package/types/dashboard/template-buyer.d.ts +50 -0
  159. package/types/icons/flags.d.ts +5 -0
  160. package/types/input-checkbox.d.ts +2 -0
  161. package/types/shared/lib/helpers.d.ts +4 -0
  162. package/types/shared/order-summary.d.ts +19 -0
@@ -53,18 +53,16 @@ var import_input_combobox = __toESM(require("./input-combobox"));
53
53
  var import_input_text = __toESM(require("../input-text"));
54
54
  var import_input_textarea = __toESM(require("../input-textarea"));
55
55
  var import_input_switch = __toESM(require("../shared/input-switch"));
56
- var import_input_array = require("./input-array");
57
56
  var import_input_file = __toESM(require("./input-file"));
57
+ var import_input_gallery = __toESM(require("./input-gallery"));
58
58
  var import_hooks = require("./lib/hooks");
59
59
  var import_divider = __toESM(require("../shared/divider"));
60
60
  var import_button = __toESM(require("../shared/button"));
61
61
  var import_map_pin = __toESM(require("../icons/map-pin"));
62
- var import_plus = __toESM(require("../icons/plus"));
63
- var import_trash = __toESM(require("../icons/trash"));
62
+ var import_lock = __toESM(require("../icons/lock"));
64
63
  var import_geo = require("./lib/geo");
65
64
  var import_loader = require("../shared/loader");
66
65
  var import_campaign = require("../shared/lib/campaign");
67
- const FormReposition = (0, import_dynamic.default)(() => import("./form-reposition"), { loading: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {}), ssr: false });
68
66
  const InputGoogleAutocomplete = (0, import_dynamic.default)(() => import("./google").then((m) => m.InputGoogleAutocomplete), { loading: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {}), ssr: false });
69
67
  const switches = [
70
68
  {
@@ -749,10 +747,29 @@ const useDescriptions = (onUpdate) => {
749
747
  descriptions
750
748
  };
751
749
  };
752
- const InputFieldsImages = ({ described, organization, onUpdate, preview = true, values = {} }) => {
750
+ const InputFieldsImages = ({ described, locked, organization, onUpdate, preview = true, values = {} }) => {
753
751
  var _a, _b, _c, _d;
754
752
  const { control, formState, getValues } = (0, import_react_hook_form.useFormContext)();
755
753
  const { describe, descriptions } = useDescriptions(onUpdate);
754
+ const lock = locked && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
755
+ "span",
756
+ {
757
+ ...{
758
+ className: "flex items-center gap-1"
759
+ },
760
+ children: [
761
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
762
+ import_lock.default,
763
+ {
764
+ ...{
765
+ className: "w-4 h-4 shrink-0"
766
+ }
767
+ }
768
+ ),
769
+ "Set by the connected brand"
770
+ ]
771
+ }
772
+ );
756
773
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
757
774
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
758
775
  import_react_hook_form.Controller,
@@ -777,6 +794,7 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
777
794
  description: descriptions == null ? void 0 : descriptions.logo,
778
795
  onDescription: describe("logo")
779
796
  },
797
+ disabled: Boolean(locked),
780
798
  endpoint: "/organization/" + values.organization,
781
799
  onChange: (val) => {
782
800
  onChange(val);
@@ -788,7 +806,8 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
788
806
  }
789
807
  }
790
808
  ),
791
- label: "Logo"
809
+ label: "Logo",
810
+ message: lock || void 0
792
811
  }
793
812
  }
794
813
  );
@@ -820,6 +839,7 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
820
839
  description: descriptions == null ? void 0 : descriptions.preview,
821
840
  onDescription: describe("preview")
822
841
  },
842
+ disabled: Boolean(locked),
823
843
  endpoint: "/organization/" + values.organization,
824
844
  organization,
825
845
  onChange: (val) => {
@@ -832,7 +852,7 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
832
852
  }
833
853
  ),
834
854
  label: "Preview image",
835
- message: "The image that is displayed in applications that support link previews"
855
+ message: lock || "The image that is displayed in applications that support link previews"
836
856
  }
837
857
  }
838
858
  );
@@ -843,161 +863,17 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
843
863
  )
844
864
  ] });
845
865
  };
846
- const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
847
- var _a, _b;
848
- const queryClient = (0, import_react_query.useQueryClient)();
849
- const modal = (0, import_hooks.useModal)({ queryClient });
850
- const { control, formState, getValues, setValue } = (0, import_react_hook_form.useFormContext)();
851
- const gallery = (0, import_react_hook_form.useWatch)({ control, name: "gallery" }) || [];
852
- const taken = () => (getValues().gallery || []).map((item) => {
853
- var _a2;
854
- return (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.id;
855
- }).filter(Boolean);
856
- const change = (path, value) => {
857
- setValue(path, value, { shouldDirty: true });
858
- onUpdate == null ? void 0 : onUpdate(getValues());
859
- };
860
- const reposition = (index) => {
861
- var _a2, _b2;
862
- const item = getValues("gallery." + index);
863
- modal.open({
864
- message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
865
- FormReposition,
866
- {
867
- ...{
868
- file: item == null ? void 0 : item.file,
869
- onDone: (position) => {
870
- change("gallery." + index + ".position", position);
871
- modal.close();
872
- },
873
- page: getValues(),
874
- position: item == null ? void 0 : item.position
875
- }
876
- }
877
- ),
878
- title: ((_b2 = (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) == null ? void 0 : _b2.includes("video")) ? "Reposition video" : "Reposition photo"
879
- });
880
- };
881
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
882
- import_input_group.default,
883
- {
884
- ...{
885
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.gallery) == null ? void 0 : _b.message,
886
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
887
- import_input_array.InputArraySortable,
888
- {
889
- ...{
890
- control,
891
- "data-guide": "form-input-gallery",
892
- empty: "Gallery is empty",
893
- name: "gallery",
894
- onSort: () => onUpdate == null ? void 0 : onUpdate(getValues()),
895
- renderButton: (append) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
896
- import_input_file.default,
897
- {
898
- ...{
899
- button: {
900
- icon: import_plus.default,
901
- text: "Add gallery item"
902
- },
903
- endpoint: "/organization/" + values.organization,
904
- filters: {
905
- id: {
906
- $nin: taken()
907
- }
908
- },
909
- onChange: (response) => {
910
- append({ file: response });
911
- onUpdate == null ? void 0 : onUpdate(getValues());
912
- },
913
- organization,
914
- nullable: false,
915
- value: null,
916
- type: "media"
917
- }
918
- }
919
- ),
920
- renderControls: ({ index, remove }) => [
921
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
922
- import_input_array.InputArrayControl,
923
- {
924
- ...{
925
- onClick: () => {
926
- remove(index);
927
- onUpdate == null ? void 0 : onUpdate(getValues());
928
- },
929
- icon: import_trash.default
930
- }
931
- },
932
- "gallery-control-remove-" + index
933
- )
934
- ]
935
- },
936
- children: ({ field, handle, index, update }) => {
937
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
938
- const item = gallery[index] || field;
939
- const editable = /^(image|video)\//.test(((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) || "");
940
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
941
- "div",
942
- {
943
- ...{
944
- className: "flex items-center min-w-0 flex-1 space-x-3"
945
- },
946
- children: [
947
- handle,
948
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
949
- import_input_group.default,
950
- {
951
- ...{
952
- error: ((_e = (_d = (_c = (_b2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _b2.gallery) == null ? void 0 : _c[index]) == null ? void 0 : _d.file) == null ? void 0 : _e.message) || ((_i = (_h = (_g = (_f = formState == null ? void 0 : formState.errors) == null ? void 0 : _f.gallery) == null ? void 0 : _g[index]) == null ? void 0 : _h.description) == null ? void 0 : _i.message),
953
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
954
- import_input_file.default,
955
- {
956
- ...{
957
- // The item's own description and crop.
958
- description: item == null ? void 0 : item.description,
959
- edited: Boolean(item == null ? void 0 : item.position),
960
- endpoint: "/organization/" + values.organization,
961
- filters: {
962
- id: {
963
- $nin: taken()
964
- }
965
- },
966
- // Another file is another item: no description, no crop.
967
- onChange: (response) => {
968
- update(
969
- index,
970
- {
971
- file: response
972
- }
973
- );
974
- onUpdate == null ? void 0 : onUpdate(getValues());
975
- },
976
- onDescription: (text) => change("gallery." + index + ".description", text),
977
- ...editable && {
978
- onEdit: () => reposition(index)
979
- },
980
- organization,
981
- nullable: false,
982
- value: item == null ? void 0 : item.file,
983
- type: "media"
984
- }
985
- }
986
- )
987
- }
988
- }
989
- )
990
- ]
991
- }
992
- );
993
- }
994
- }
995
- ),
996
- label: "Gallery"
997
- }
866
+ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
867
+ import_input_gallery.default,
868
+ {
869
+ ...{
870
+ endpoint: "/organization/" + values.organization,
871
+ onUpdate,
872
+ organization,
873
+ reposition: true
998
874
  }
999
- ) });
1000
- };
875
+ }
876
+ );
1001
877
  // Annotate the CommonJS export names for ESM import in node:
1002
878
  0 && (module.exports = {
1003
879
  InputFieldsAddress,
@@ -14,15 +14,13 @@ import InputCombobox from "./input-combobox.mjs";
14
14
  import InputText from "../input-text.mjs";
15
15
  import InputTextarea from "../input-textarea.mjs";
16
16
  import InputSwitch from "../shared/input-switch.mjs";
17
- import { InputArrayControl, InputArraySortable } from "./input-array.mjs";
18
17
  import InputFile from "./input-file.mjs";
18
+ import InputGallery from "./input-gallery.mjs";
19
19
  import { useModal } from "./lib/hooks.mjs";
20
20
  import Divider from "../shared/divider.mjs";
21
21
  import Button from "../shared/button.mjs";
22
22
  import MapPin from "../icons/map-pin.mjs";
23
- import Plus from "../icons/plus.mjs";
24
- import Trash from "../icons/trash.mjs";
25
- const FormReposition = dynamic(() => import("./form-reposition.mjs"), { loading: () => /* @__PURE__ */ jsx(LoaderDynamic, {}), ssr: false });
23
+ import Lock from "../icons/lock.mjs";
26
24
  const InputGoogleAutocomplete = dynamic(() => import("./google.mjs").then((m) => m.InputGoogleAutocomplete), { loading: () => /* @__PURE__ */ jsx(LoaderDynamic, {}), ssr: false });
27
25
  import { getLocation, reverseGeocode } from "./lib/geo.mjs";
28
26
  import { LoaderDynamic } from "../shared/loader.mjs";
@@ -710,10 +708,29 @@ const useDescriptions = (onUpdate) => {
710
708
  descriptions
711
709
  };
712
710
  };
713
- const InputFieldsImages = ({ described, organization, onUpdate, preview = true, values = {} }) => {
711
+ const InputFieldsImages = ({ described, locked, organization, onUpdate, preview = true, values = {} }) => {
714
712
  var _a, _b, _c, _d;
715
713
  const { control, formState, getValues } = useFormContext();
716
714
  const { describe, descriptions } = useDescriptions(onUpdate);
715
+ const lock = locked && /* @__PURE__ */ jsxs(
716
+ "span",
717
+ {
718
+ ...{
719
+ className: "flex items-center gap-1"
720
+ },
721
+ children: [
722
+ /* @__PURE__ */ jsx(
723
+ Lock,
724
+ {
725
+ ...{
726
+ className: "w-4 h-4 shrink-0"
727
+ }
728
+ }
729
+ ),
730
+ "Set by the connected brand"
731
+ ]
732
+ }
733
+ );
717
734
  return /* @__PURE__ */ jsxs(Fragment, { children: [
718
735
  /* @__PURE__ */ jsx(
719
736
  Controller,
@@ -738,6 +755,7 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
738
755
  description: descriptions == null ? void 0 : descriptions.logo,
739
756
  onDescription: describe("logo")
740
757
  },
758
+ disabled: Boolean(locked),
741
759
  endpoint: "/organization/" + values.organization,
742
760
  onChange: (val) => {
743
761
  onChange(val);
@@ -749,7 +767,8 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
749
767
  }
750
768
  }
751
769
  ),
752
- label: "Logo"
770
+ label: "Logo",
771
+ message: lock || void 0
753
772
  }
754
773
  }
755
774
  );
@@ -781,6 +800,7 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
781
800
  description: descriptions == null ? void 0 : descriptions.preview,
782
801
  onDescription: describe("preview")
783
802
  },
803
+ disabled: Boolean(locked),
784
804
  endpoint: "/organization/" + values.organization,
785
805
  organization,
786
806
  onChange: (val) => {
@@ -793,7 +813,7 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
793
813
  }
794
814
  ),
795
815
  label: "Preview image",
796
- message: "The image that is displayed in applications that support link previews"
816
+ message: lock || "The image that is displayed in applications that support link previews"
797
817
  }
798
818
  }
799
819
  );
@@ -804,161 +824,17 @@ const InputFieldsImages = ({ described, organization, onUpdate, preview = true,
804
824
  )
805
825
  ] });
806
826
  };
807
- const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => {
808
- var _a, _b;
809
- const queryClient = useQueryClient();
810
- const modal = useModal({ queryClient });
811
- const { control, formState, getValues, setValue } = useFormContext();
812
- const gallery = useWatch({ control, name: "gallery" }) || [];
813
- const taken = () => (getValues().gallery || []).map((item) => {
814
- var _a2;
815
- return (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.id;
816
- }).filter(Boolean);
817
- const change = (path, value) => {
818
- setValue(path, value, { shouldDirty: true });
819
- onUpdate == null ? void 0 : onUpdate(getValues());
820
- };
821
- const reposition = (index) => {
822
- var _a2, _b2;
823
- const item = getValues("gallery." + index);
824
- modal.open({
825
- message: /* @__PURE__ */ jsx(
826
- FormReposition,
827
- {
828
- ...{
829
- file: item == null ? void 0 : item.file,
830
- onDone: (position) => {
831
- change("gallery." + index + ".position", position);
832
- modal.close();
833
- },
834
- page: getValues(),
835
- position: item == null ? void 0 : item.position
836
- }
837
- }
838
- ),
839
- title: ((_b2 = (_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) == null ? void 0 : _b2.includes("video")) ? "Reposition video" : "Reposition photo"
840
- });
841
- };
842
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
843
- InputGroup,
844
- {
845
- ...{
846
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.gallery) == null ? void 0 : _b.message,
847
- input: /* @__PURE__ */ jsx(
848
- InputArraySortable,
849
- {
850
- ...{
851
- control,
852
- "data-guide": "form-input-gallery",
853
- empty: "Gallery is empty",
854
- name: "gallery",
855
- onSort: () => onUpdate == null ? void 0 : onUpdate(getValues()),
856
- renderButton: (append) => /* @__PURE__ */ jsx(
857
- InputFile,
858
- {
859
- ...{
860
- button: {
861
- icon: Plus,
862
- text: "Add gallery item"
863
- },
864
- endpoint: "/organization/" + values.organization,
865
- filters: {
866
- id: {
867
- $nin: taken()
868
- }
869
- },
870
- onChange: (response) => {
871
- append({ file: response });
872
- onUpdate == null ? void 0 : onUpdate(getValues());
873
- },
874
- organization,
875
- nullable: false,
876
- value: null,
877
- type: "media"
878
- }
879
- }
880
- ),
881
- renderControls: ({ index, remove }) => [
882
- /* @__PURE__ */ jsx(
883
- InputArrayControl,
884
- {
885
- ...{
886
- onClick: () => {
887
- remove(index);
888
- onUpdate == null ? void 0 : onUpdate(getValues());
889
- },
890
- icon: Trash
891
- }
892
- },
893
- "gallery-control-remove-" + index
894
- )
895
- ]
896
- },
897
- children: ({ field, handle, index, update }) => {
898
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
899
- const item = gallery[index] || field;
900
- const editable = /^(image|video)\//.test(((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.mimetype) || "");
901
- return /* @__PURE__ */ jsxs(
902
- "div",
903
- {
904
- ...{
905
- className: "flex items-center min-w-0 flex-1 space-x-3"
906
- },
907
- children: [
908
- handle,
909
- /* @__PURE__ */ jsx(
910
- InputGroup,
911
- {
912
- ...{
913
- error: ((_e = (_d = (_c = (_b2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _b2.gallery) == null ? void 0 : _c[index]) == null ? void 0 : _d.file) == null ? void 0 : _e.message) || ((_i = (_h = (_g = (_f = formState == null ? void 0 : formState.errors) == null ? void 0 : _f.gallery) == null ? void 0 : _g[index]) == null ? void 0 : _h.description) == null ? void 0 : _i.message),
914
- input: /* @__PURE__ */ jsx(
915
- InputFile,
916
- {
917
- ...{
918
- // The item's own description and crop.
919
- description: item == null ? void 0 : item.description,
920
- edited: Boolean(item == null ? void 0 : item.position),
921
- endpoint: "/organization/" + values.organization,
922
- filters: {
923
- id: {
924
- $nin: taken()
925
- }
926
- },
927
- // Another file is another item: no description, no crop.
928
- onChange: (response) => {
929
- update(
930
- index,
931
- {
932
- file: response
933
- }
934
- );
935
- onUpdate == null ? void 0 : onUpdate(getValues());
936
- },
937
- onDescription: (text) => change("gallery." + index + ".description", text),
938
- ...editable && {
939
- onEdit: () => reposition(index)
940
- },
941
- organization,
942
- nullable: false,
943
- value: item == null ? void 0 : item.file,
944
- type: "media"
945
- }
946
- }
947
- )
948
- }
949
- }
950
- )
951
- ]
952
- }
953
- );
954
- }
955
- }
956
- ),
957
- label: "Gallery"
958
- }
827
+ const InputFieldsMedia = ({ organization, onUpdate, values = {} }) => /* @__PURE__ */ jsx(
828
+ InputGallery,
829
+ {
830
+ ...{
831
+ endpoint: "/organization/" + values.organization,
832
+ onUpdate,
833
+ organization,
834
+ reposition: true
959
835
  }
960
- ) });
961
- };
836
+ }
837
+ );
962
838
  export {
963
839
  InputFieldsAddress,
964
840
  InputFieldsCampaign,
@@ -34,6 +34,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
34
34
  var import_react_query = require("@tanstack/react-query");
35
35
  var import_hooks = require("./lib/hooks");
36
36
  var import_form_file = __toESM(require("./form-file"));
37
+ var import_form_file_upload = __toESM(require("./form-file-upload"));
37
38
  var import_card_asset = __toESM(require("../shared/card-asset"));
38
39
  var import_upload = __toESM(require("../icons/upload"));
39
40
  var import_trash = __toESM(require("../icons/trash"));
@@ -43,6 +44,10 @@ var import_pencil = __toESM(require("../icons/pencil"));
43
44
  const InputFile = ({
44
45
  button = {},
45
46
  description,
47
+ // @story products/digital-file
48
+ // A product variant's digital file: the uploader alone, no Library to pick
49
+ // from, and no thumbnail, since a private file has none.
50
+ digital = false,
46
51
  disabled,
47
52
  edited = false,
48
53
  endpoint,
@@ -59,7 +64,7 @@ const InputFile = ({
59
64
  const modal = (0, import_hooks.useModal)({
60
65
  queryClient
61
66
  });
62
- if (value == null ? void 0 : value.sizes) {
67
+ if (digital ? value == null ? void 0 : value.id : value == null ? void 0 : value.sizes) {
63
68
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
64
69
  "div",
65
70
  {
@@ -74,7 +79,7 @@ const InputFile = ({
74
79
  className: "flex items-center space-x-3 border border-black rounded w-full py-2 px-2 bg-white"
75
80
  },
76
81
  children: [
77
- (value == null ? void 0 : value.mimetype) && (onEdit && !disabled ? (
82
+ (value == null ? void 0 : value.mimetype) && !digital && (onEdit && !disabled ? (
78
83
  // @story pages/reposition
79
84
  // The thumbnail is the button: a pencil over it on hover or focus,
80
85
  // the tooltip names the action, and a green ring once it is edited.
@@ -233,7 +238,19 @@ const InputFile = ({
233
238
  onClick: (event) => {
234
239
  event.preventDefault();
235
240
  modal.open({
236
- message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
+ message: digital ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
242
+ import_form_file_upload.default,
243
+ {
244
+ ...{
245
+ endpoint,
246
+ onSuccess: (response) => {
247
+ onChange(response == null ? void 0 : response.result);
248
+ modal.close();
249
+ },
250
+ type: "digital"
251
+ }
252
+ }
253
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
237
254
  import_form_file.default,
238
255
  {
239
256
  ...{
@@ -248,7 +265,7 @@ const InputFile = ({
248
265
  }
249
266
  }
250
267
  ),
251
- title: "File uploader"
268
+ title: digital ? "Digital file" : "File uploader"
252
269
  });
253
270
  },
254
271
  variant: "link"
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useQueryClient } from "@tanstack/react-query";
3
3
  import { useModal } from "./lib/hooks.mjs";
4
4
  import FormFile from "./form-file.mjs";
5
+ import FormFileUpload from "./form-file-upload.mjs";
5
6
  import CardAsset from "../shared/card-asset.mjs";
6
7
  import Upload from "../icons/upload.mjs";
7
8
  import Trash from "../icons/trash.mjs";
@@ -11,6 +12,10 @@ import Pencil from "../icons/pencil.mjs";
11
12
  const InputFile = ({
12
13
  button = {},
13
14
  description,
15
+ // @story products/digital-file
16
+ // A product variant's digital file: the uploader alone, no Library to pick
17
+ // from, and no thumbnail, since a private file has none.
18
+ digital = false,
14
19
  disabled,
15
20
  edited = false,
16
21
  endpoint,
@@ -27,7 +32,7 @@ const InputFile = ({
27
32
  const modal = useModal({
28
33
  queryClient
29
34
  });
30
- if (value == null ? void 0 : value.sizes) {
35
+ if (digital ? value == null ? void 0 : value.id : value == null ? void 0 : value.sizes) {
31
36
  return /* @__PURE__ */ jsxs(
32
37
  "div",
33
38
  {
@@ -42,7 +47,7 @@ const InputFile = ({
42
47
  className: "flex items-center space-x-3 border border-black rounded w-full py-2 px-2 bg-white"
43
48
  },
44
49
  children: [
45
- (value == null ? void 0 : value.mimetype) && (onEdit && !disabled ? (
50
+ (value == null ? void 0 : value.mimetype) && !digital && (onEdit && !disabled ? (
46
51
  // @story pages/reposition
47
52
  // The thumbnail is the button: a pencil over it on hover or focus,
48
53
  // the tooltip names the action, and a green ring once it is edited.
@@ -201,7 +206,19 @@ const InputFile = ({
201
206
  onClick: (event) => {
202
207
  event.preventDefault();
203
208
  modal.open({
204
- message: /* @__PURE__ */ jsx(
209
+ message: digital ? /* @__PURE__ */ jsx(
210
+ FormFileUpload,
211
+ {
212
+ ...{
213
+ endpoint,
214
+ onSuccess: (response) => {
215
+ onChange(response == null ? void 0 : response.result);
216
+ modal.close();
217
+ },
218
+ type: "digital"
219
+ }
220
+ }
221
+ ) : /* @__PURE__ */ jsx(
205
222
  FormFile,
206
223
  {
207
224
  ...{
@@ -216,7 +233,7 @@ const InputFile = ({
216
233
  }
217
234
  }
218
235
  ),
219
- title: "File uploader"
236
+ title: digital ? "Digital file" : "File uploader"
220
237
  });
221
238
  },
222
239
  variant: "link"
@@ -485,6 +485,7 @@ const InputFont = ({
485
485
  import_input_combobox.default,
486
486
  {
487
487
  ...{
488
+ "aria-label": "Weight",
488
489
  disabled,
489
490
  onChange: (selectedValue) => {
490
491
  onChange({
@@ -501,6 +502,7 @@ const InputFont = ({
501
502
  import_input_combobox.default,
502
503
  {
503
504
  ...{
505
+ "aria-label": "Letter case",
504
506
  disabled,
505
507
  onChange: (selectedValue) => {
506
508
  onChange({
@@ -453,6 +453,7 @@ const InputFont = ({
453
453
  InputCombobox,
454
454
  {
455
455
  ...{
456
+ "aria-label": "Weight",
456
457
  disabled,
457
458
  onChange: (selectedValue) => {
458
459
  onChange({
@@ -469,6 +470,7 @@ const InputFont = ({
469
470
  InputCombobox,
470
471
  {
471
472
  ...{
473
+ "aria-label": "Letter case",
472
474
  disabled,
473
475
  onChange: (selectedValue) => {
474
476
  onChange({