@licklist/design 0.44.485-dev.64 → 0.44.485-dev.66

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 (168) hide show
  1. package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
  2. package/dist/events/edit-event-modal/IntervalInput.js +1 -1
  3. package/dist/help/popover/HelpPopover.d.ts +4 -2
  4. package/dist/help/popover/HelpPopover.d.ts.map +1 -1
  5. package/dist/help/popover/HelpPopover.js +1 -1
  6. package/dist/iframe/event/event-card/IframeEventCard.d.ts +3 -3
  7. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  8. package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
  9. package/dist/iframe/event/event-card/IframeEventCardSkeleton.d.ts +3 -3
  10. package/dist/iframe/event/event-card/IframeEventCardSkeleton.d.ts.map +1 -1
  11. package/dist/iframe/event/event-card/IframeEventCardSkeleton.js +1 -1
  12. package/dist/image-radio-input/ImageRadioInput.d.ts +15 -0
  13. package/dist/image-radio-input/ImageRadioInput.d.ts.map +1 -0
  14. package/dist/image-radio-input/ImageRadioInput.js +1 -0
  15. package/dist/image-radio-input/index.d.ts.map +1 -0
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/product-set/product/quantity/ProductQuantityRechargingControl.d.ts.map +1 -1
  20. package/dist/product-set/product/quantity/ProductQuantityRechargingControl.js +1 -1
  21. package/dist/radio-card/RadioCard.d.ts +13 -0
  22. package/dist/radio-card/RadioCard.d.ts.map +1 -0
  23. package/dist/radio-card/RadioCard.js +1 -0
  24. package/dist/radio-card/index.d.ts +2 -0
  25. package/dist/radio-card/index.d.ts.map +1 -0
  26. package/dist/setting/dashboard/index.d.ts +0 -2
  27. package/dist/setting/dashboard/index.d.ts.map +1 -1
  28. package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
  29. package/dist/snippet/snippet-template/preview/Preview.js +1 -1
  30. package/dist/sorting-select/SortingSelect.d.ts +10 -0
  31. package/dist/sorting-select/SortingSelect.d.ts.map +1 -0
  32. package/dist/sorting-select/SortingSelect.js +1 -0
  33. package/dist/sorting-select/index.d.ts +2 -0
  34. package/dist/sorting-select/index.d.ts.map +1 -0
  35. package/{src/styles/widgets/ImageRadioInput.scss → dist/styles/image-radio-input/_index.scss} +12 -0
  36. package/dist/styles/packages.scss +2 -1
  37. package/{src/styles/widgets/WidgetTypeRadioButton.scss → dist/styles/radio-card/_index.scss} +8 -1
  38. package/package.json +2 -2
  39. package/src/events/edit-event-modal/IntervalInput.tsx +7 -3
  40. package/src/help/popover/HelpPopover.tsx +13 -5
  41. package/src/iframe/event/event-card/IframeEventCard.stories.tsx +6 -14
  42. package/src/iframe/event/event-card/IframeEventCard.tsx +6 -10
  43. package/src/iframe/event/event-card/IframeEventCardSkeleton.tsx +20 -30
  44. package/src/iframe/event/event-card/IframeEventCards.stories.tsx +2 -3
  45. package/src/image-radio-input/ImageRadioInput.stories.tsx +67 -0
  46. package/src/image-radio-input/ImageRadioInput.tsx +53 -0
  47. package/src/index.ts +3 -0
  48. package/src/product-set/product/quantity/ProductQuantityRechargingControl.tsx +24 -27
  49. package/src/radio-card/RadioCard.stories.tsx +48 -0
  50. package/src/radio-card/RadioCard.tsx +49 -0
  51. package/src/radio-card/index.ts +1 -0
  52. package/src/setting/dashboard/index.ts +0 -2
  53. package/src/snippet/snippet-template/preview/Preview.tsx +0 -5
  54. package/src/sorting-select/SortingSelect.stories.tsx +15 -0
  55. package/src/sorting-select/SortingSelect.tsx +79 -0
  56. package/src/sorting-select/index.ts +1 -0
  57. package/{dist/styles/widgets/ImageRadioInput.scss → src/styles/image-radio-input/_index.scss} +12 -0
  58. package/src/styles/packages.scss +2 -1
  59. package/{dist/styles/widgets/WidgetTypeRadioButton.scss → src/styles/radio-card/_index.scss} +8 -1
  60. package/dist/assets/widgets/circlePlus.svg +0 -4
  61. package/dist/assets/widgets/inPage.svg +0 -10
  62. package/dist/assets/widgets/overlay.svg +0 -9
  63. package/dist/assets/widgets/sidebar.svg +0 -9
  64. package/dist/setting/dashboard/snippets/control/SnippetControl.d.ts +0 -9
  65. package/dist/setting/dashboard/snippets/control/SnippetControl.d.ts.map +0 -1
  66. package/dist/setting/dashboard/snippets/control/SnippetControl.js +0 -1
  67. package/dist/setting/dashboard/snippets/control/index.d.ts +0 -2
  68. package/dist/setting/dashboard/snippets/control/index.d.ts.map +0 -1
  69. package/dist/setting/dashboard/snippets/form/SnippetForm.d.ts +0 -33
  70. package/dist/setting/dashboard/snippets/form/SnippetForm.d.ts.map +0 -1
  71. package/dist/setting/dashboard/snippets/form/SnippetForm.js +0 -1
  72. package/dist/setting/dashboard/snippets/form/context.d.ts +0 -11
  73. package/dist/setting/dashboard/snippets/form/context.d.ts.map +0 -1
  74. package/dist/setting/dashboard/snippets/form/context.js +0 -1
  75. package/dist/setting/dashboard/snippets/form/index.d.ts +0 -2
  76. package/dist/setting/dashboard/snippets/form/index.d.ts.map +0 -1
  77. package/dist/setting/dashboard/snippets/modal/SnippetViewTypeModal.d.ts +0 -19
  78. package/dist/setting/dashboard/snippets/modal/SnippetViewTypeModal.d.ts.map +0 -1
  79. package/dist/setting/dashboard/snippets/modal/SnippetViewTypeModal.js +0 -1
  80. package/dist/setting/dashboard/snippets/modal/index.d.ts +0 -3
  81. package/dist/setting/dashboard/snippets/modal/index.d.ts.map +0 -1
  82. package/dist/styles/widgets/BookingStyleSelector.scss +0 -14
  83. package/dist/styles/widgets/CalendarStyleSelector.scss +0 -17
  84. package/dist/styles/widgets/CheckboxGroup.scss +0 -15
  85. package/dist/styles/widgets/ProductSetSelector.scss +0 -19
  86. package/dist/styles/widgets/SnippetCode.scss +0 -18
  87. package/dist/styles/widgets/WidgetBuilderForm.scss +0 -51
  88. package/dist/styles/widgets/WidgetTypeSelector.scss +0 -6
  89. package/dist/styles/widgets/_index.scss +0 -9
  90. package/dist/widgets/BookingStyleSelector/BookingStyleSelector.d.ts +0 -3
  91. package/dist/widgets/BookingStyleSelector/BookingStyleSelector.d.ts.map +0 -1
  92. package/dist/widgets/BookingStyleSelector/index.d.ts +0 -2
  93. package/dist/widgets/BookingStyleSelector/index.d.ts.map +0 -1
  94. package/dist/widgets/CalendarStyleSelector/CalendarStyleSelector.d.ts +0 -3
  95. package/dist/widgets/CalendarStyleSelector/CalendarStyleSelector.d.ts.map +0 -1
  96. package/dist/widgets/CalendarStyleSelector/index.d.ts +0 -2
  97. package/dist/widgets/CalendarStyleSelector/index.d.ts.map +0 -1
  98. package/dist/widgets/CheckboxGroup/CheckboxGroup.d.ts +0 -8
  99. package/dist/widgets/CheckboxGroup/CheckboxGroup.d.ts.map +0 -1
  100. package/dist/widgets/CheckboxGroup/index.d.ts +0 -2
  101. package/dist/widgets/CheckboxGroup/index.d.ts.map +0 -1
  102. package/dist/widgets/ImageRadioInput/ImageRadioInput.d.ts +0 -9
  103. package/dist/widgets/ImageRadioInput/ImageRadioInput.d.ts.map +0 -1
  104. package/dist/widgets/ImageRadioInput/index.d.ts.map +0 -1
  105. package/dist/widgets/ProductSetSelector/ProductSetSelector.d.ts +0 -3
  106. package/dist/widgets/ProductSetSelector/ProductSetSelector.d.ts.map +0 -1
  107. package/dist/widgets/ProductSetSelector/index.d.ts +0 -2
  108. package/dist/widgets/ProductSetSelector/index.d.ts.map +0 -1
  109. package/dist/widgets/SnippetCode/SnippetCode.d.ts +0 -6
  110. package/dist/widgets/SnippetCode/SnippetCode.d.ts.map +0 -1
  111. package/dist/widgets/SnippetCode/index.d.ts +0 -2
  112. package/dist/widgets/SnippetCode/index.d.ts.map +0 -1
  113. package/dist/widgets/WidgetBuilderForm/WidgetBuilderForm.d.ts +0 -12
  114. package/dist/widgets/WidgetBuilderForm/WidgetBuilderForm.d.ts.map +0 -1
  115. package/dist/widgets/WidgetTypeRadio/WidgetTypeRadio.d.ts +0 -7
  116. package/dist/widgets/WidgetTypeRadio/WidgetTypeRadio.d.ts.map +0 -1
  117. package/dist/widgets/WidgetTypeRadio/index.d.ts +0 -2
  118. package/dist/widgets/WidgetTypeRadio/index.d.ts.map +0 -1
  119. package/dist/widgets/WidgetTypeSelector/WidgetTypeSelector.d.ts +0 -3
  120. package/dist/widgets/WidgetTypeSelector/WidgetTypeSelector.d.ts.map +0 -1
  121. package/src/assets/widgets/circlePlus.svg +0 -4
  122. package/src/assets/widgets/inPage.svg +0 -10
  123. package/src/assets/widgets/overlay.svg +0 -9
  124. package/src/assets/widgets/sidebar.svg +0 -9
  125. package/src/setting/dashboard/snippets/control/SnippetControl.tsx +0 -235
  126. package/src/setting/dashboard/snippets/control/index.ts +0 -1
  127. package/src/setting/dashboard/snippets/form/SnippetForm.stories.tsx +0 -104
  128. package/src/setting/dashboard/snippets/form/SnippetForm.tsx +0 -94
  129. package/src/setting/dashboard/snippets/form/context.tsx +0 -18
  130. package/src/setting/dashboard/snippets/form/index.ts +0 -1
  131. package/src/setting/dashboard/snippets/modal/SnippetViewTypeModal.stories.tsx +0 -28
  132. package/src/setting/dashboard/snippets/modal/SnippetViewTypeModal.tsx +0 -104
  133. package/src/setting/dashboard/snippets/modal/index.ts +0 -2
  134. package/src/styles/widgets/BookingStyleSelector.scss +0 -14
  135. package/src/styles/widgets/CalendarStyleSelector.scss +0 -17
  136. package/src/styles/widgets/CheckboxGroup.scss +0 -15
  137. package/src/styles/widgets/ProductSetSelector.scss +0 -19
  138. package/src/styles/widgets/SnippetCode.scss +0 -18
  139. package/src/styles/widgets/WidgetBuilderForm.scss +0 -51
  140. package/src/styles/widgets/WidgetTypeSelector.scss +0 -6
  141. package/src/styles/widgets/_index.scss +0 -9
  142. package/src/widgets/BookingStyleSelector/BookingStyleSelector.stories.tsx +0 -12
  143. package/src/widgets/BookingStyleSelector/BookingStyleSelector.tsx +0 -34
  144. package/src/widgets/BookingStyleSelector/index.ts +0 -1
  145. package/src/widgets/CalendarStyleSelector/CalendarStyleSelector.stories.tsx +0 -12
  146. package/src/widgets/CalendarStyleSelector/CalendarStyleSelector.tsx +0 -29
  147. package/src/widgets/CalendarStyleSelector/index.ts +0 -1
  148. package/src/widgets/CheckboxGroup/CheckboxGroup.stories.tsx +0 -16
  149. package/src/widgets/CheckboxGroup/CheckboxGroup.tsx +0 -64
  150. package/src/widgets/CheckboxGroup/index.ts +0 -1
  151. package/src/widgets/ImageRadioInput/ImageRadioInput.stories.tsx +0 -18
  152. package/src/widgets/ImageRadioInput/ImageRadioInput.tsx +0 -29
  153. package/src/widgets/ProductSetSelector/ProductSetSelector.stories.tsx +0 -12
  154. package/src/widgets/ProductSetSelector/ProductSetSelector.tsx +0 -27
  155. package/src/widgets/ProductSetSelector/index.ts +0 -1
  156. package/src/widgets/SnippetCode/SnippetCode.stories.tsx +0 -17
  157. package/src/widgets/SnippetCode/SnippetCode.tsx +0 -27
  158. package/src/widgets/SnippetCode/index.ts +0 -1
  159. package/src/widgets/WidgetBuilderForm/WidgetBuilderForm.stories.tsx +0 -12
  160. package/src/widgets/WidgetBuilderForm/WidgetBuilderForm.tsx +0 -84
  161. package/src/widgets/WidgetTypeRadio/WidgetTypeRadio.stories.tsx +0 -17
  162. package/src/widgets/WidgetTypeRadio/WidgetTypeRadio.tsx +0 -43
  163. package/src/widgets/WidgetTypeRadio/index.ts +0 -1
  164. package/src/widgets/WidgetTypeSelector/WidgetTypeSelector.stories.tsx +0 -12
  165. package/src/widgets/WidgetTypeSelector/WidgetTypeSelector.tsx +0 -32
  166. package/tests/Snippets/Snippets.test.tsx +0 -77
  167. /package/dist/{widgets/ImageRadioInput → image-radio-input}/index.d.ts +0 -0
  168. /package/src/{widgets/ImageRadioInput → image-radio-input}/index.ts +0 -0
@@ -37,6 +37,7 @@ export function IntervalInput({
37
37
  formState: { errors },
38
38
  watch,
39
39
  control,
40
+ trigger,
40
41
  setValue,
41
42
  } = useFormContext<IntervalInputValues>();
42
43
 
@@ -84,6 +85,11 @@ export function IntervalInput({
84
85
  setIsOverriden(Boolean(isOverridenProductSet));
85
86
  }, [productSets, productSetId, setIsOverriden, editedProductSet]);
86
87
 
88
+ const onChangeEndDate = (nextEndtDate: string) => {
89
+ setValue("end", nextEndtDate);
90
+ trigger("end");
91
+ };
92
+
87
93
  return (
88
94
  <>
89
95
  <Form.Row className="interval-container">
@@ -113,9 +119,7 @@ export function IntervalInput({
113
119
  {...register("end", validationOptions.end)}
114
120
  value={end}
115
121
  name="end"
116
- onChange={({ target: { value: nextEndtDate } }) =>
117
- setValue("end", nextEndtDate)
118
- }
122
+ onChange={({ target: { value: nextEndtDate } }) => onChangeEndDate(nextEndtDate)}
119
123
  min={start}
120
124
  isInvalid={Boolean(errors.end)}
121
125
  onClick={() => endDateInput?.current?.showPicker()}
@@ -1,23 +1,31 @@
1
1
  import { useId } from "@react-aria/utils";
2
- import React from "react";
2
+ import React, { ReactNode } from "react";
3
3
  import Button from "react-bootstrap/Button";
4
4
  import OverlayTrigger from "react-bootstrap/OverlayTrigger";
5
5
  import Popover from "react-bootstrap/Popover";
6
6
  import { ButtonVariant } from "react-bootstrap/types";
7
+ import clsx from "clsx";
7
8
  import Icon from "../../static/Icon";
8
9
 
9
10
  export type HelpPopoverProps = {
10
11
  children?: React.ReactElement | React.ReactElement[];
11
12
  title?: string;
12
13
  variant?: ButtonVariant;
14
+ icon?: ReactNode;
15
+ bordered?: boolean;
13
16
  };
14
17
 
15
- export function HelpPopover(props: HelpPopoverProps) {
16
- const { children, title, variant = "light" } = props;
18
+ export function HelpPopover({
19
+ children,
20
+ title,
21
+ variant = "light",
22
+ icon,
23
+ bordered = false,
24
+ }: HelpPopoverProps) {
17
25
  const popoverId = useId();
18
26
 
19
27
  const popover = (
20
- <Popover id={popoverId}>
28
+ <Popover id={popoverId} className={clsx(bordered && "border")}>
21
29
  <Popover.Title as="h3">{title}</Popover.Title>
22
30
  <Popover.Content>{children}</Popover.Content>
23
31
  </Popover>
@@ -39,7 +47,7 @@ export function HelpPopover(props: HelpPopoverProps) {
39
47
  {...triggerHandler}
40
48
  className="btn-icon-popover rounded-circle px-2 py-1 d-inline-flex align-items-center"
41
49
  >
42
- <Icon type="question" style={{ width: "10px" }} />
50
+ {icon ?? <Icon type="question" style={{ width: "10px" }} />}
43
51
  </Button>
44
52
  )}
45
53
  </OverlayTrigger>
@@ -11,18 +11,15 @@ export default {
11
11
 
12
12
  export function Default() {
13
13
  const showImage = boolean("showImage", true);
14
- const displayCost = boolean("displayCost", false);
15
- const displayType = boolean("displayType", true);
16
- const displayDescription = boolean("displayDescription", false);
17
14
  const isListView = boolean("isListView", false);
18
15
 
19
16
  return (
20
17
  <div>
21
18
  <IframeEventCard
22
19
  imageSrc={
23
- // eslint-disable-next-line max-len
24
20
  showImage
25
- ? "https://images.unsplash.com/photo-1638988319382-90e61be77c59?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=687&q=80"
21
+ ? // eslint-disable-next-line max-len
22
+ "https://images.unsplash.com/photo-1638988319382-90e61be77c59?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=687&q=80"
26
23
  : undefined
27
24
  }
28
25
  title="Glitterbomb Bucks / Baga Chipz"
@@ -43,9 +40,8 @@ export function Default() {
43
40
  RuPaul's Drag Race UK to VINYL Cambridge! So get excited because
44
41
  the...`}
45
42
  snippetSetting={{
46
- displayCost,
47
- displayType,
48
- displayDescription,
43
+ includeAvailability: ["calendar", "product_sets", "time_slots"],
44
+ includeFromPrice: ["calendar", "product_sets", "time_slots"],
49
45
  }}
50
46
  goToDetails={() => null}
51
47
  isListView={isListView}
@@ -59,9 +55,6 @@ export function Default() {
59
55
 
60
56
  export function EventCardSkeleton() {
61
57
  const showImage = boolean("showImage", true);
62
- const displayCost = boolean("displayCost", false);
63
- const displayType = boolean("displayType", true);
64
- const displayDescription = boolean("displayDescription", false);
65
58
  const isListView = boolean("isListView", false);
66
59
 
67
60
  return (
@@ -69,9 +62,8 @@ export function EventCardSkeleton() {
69
62
  <IframeEventCardSkeleton
70
63
  showImage={showImage}
71
64
  snippetSetting={{
72
- displayCost,
73
- displayType,
74
- displayDescription,
65
+ includeAvailability: ["calendar", "product_sets", "time_slots"],
66
+ includeFromPrice: ["calendar", "product_sets", "time_slots"],
75
67
  }}
76
68
  isListView={isListView}
77
69
  />
@@ -3,7 +3,7 @@ import { Card } from "react-bootstrap";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import { useIntl } from "react-intl";
5
5
  import clsx from "clsx";
6
- import { SnippetSetting } from "@licklist/core/dist/DataMapper/Provider/SnippetSettingDataMapper";
6
+ import { Snippet } from "@licklist/core/dist/DataMapper/Provider/SnippetDataMapper";
7
7
  import { TipTapEditor } from "../../../tiptap-editor/TipTapEditor";
8
8
  import { formatContent } from "../../../events/event-card/utils";
9
9
  import { ReactComponent as ClockSvg } from "../../../assets/iframe/clock.svg";
@@ -18,7 +18,8 @@ interface IframeEventCardProps {
18
18
  cost?: number;
19
19
  date: string;
20
20
  imageSrc?: string;
21
- snippetSetting?: SnippetSetting;
21
+ // eslint-disable-next-line react/no-unused-prop-types
22
+ snippetSetting?: Snippet["widgetSetting"];
22
23
  colour?: string;
23
24
  goToDetails?: () => void;
24
25
  description?: string | null;
@@ -35,11 +36,6 @@ export function IframeEventCard({
35
36
  cost,
36
37
  date,
37
38
  imageSrc,
38
- snippetSetting = {
39
- displayType: true,
40
- displayCost: true,
41
- displayDescription: true,
42
- },
43
39
  colour,
44
40
  goToDetails,
45
41
  description,
@@ -102,7 +98,7 @@ export function IframeEventCard({
102
98
  </div>
103
99
  </Card.Text>
104
100
 
105
- {type && !!snippetSetting.displayType && (
101
+ {type && (
106
102
  <Card.Text as="div" className="list-view-hided">
107
103
  <div className="d-flex align-items-center mb-3">
108
104
  <div className="icon-wrapper">
@@ -113,7 +109,7 @@ export function IframeEventCard({
113
109
  </Card.Text>
114
110
  )}
115
111
 
116
- {typeof cost === "number" && !!snippetSetting.displayCost && (
112
+ {typeof cost === "number" && (
117
113
  <Card.Text as="div">
118
114
  <div className="d-flex align-items-center mb-3">
119
115
  <div className="icon-wrapper">
@@ -127,7 +123,7 @@ export function IframeEventCard({
127
123
  </Card.Text>
128
124
  )}
129
125
 
130
- {description && !!snippetSetting.displayDescription && (
126
+ {description && (
131
127
  <Card.Text as="div" className="list-view-hided">
132
128
  <TipTapEditor
133
129
  viewMode
@@ -2,11 +2,12 @@ import React, { memo } from "react";
2
2
  import { Card } from "react-bootstrap";
3
3
  import clsx from "clsx";
4
4
  import Skeleton from "react-loading-skeleton";
5
- import { SnippetSetting } from "@licklist/core/dist/DataMapper/Provider/SnippetSettingDataMapper";
5
+ import { Snippet } from "@licklist/core/dist/DataMapper/Provider/SnippetDataMapper";
6
6
 
7
7
  interface IframeEventCardSkeletonProps {
8
8
  showImage?: boolean;
9
- snippetSetting?: SnippetSetting;
9
+ // eslint-disable-next-line react/no-unused-prop-types
10
+ snippetSetting?: Snippet["widgetSetting"];
10
11
  colour?: string;
11
12
  isListView?: boolean;
12
13
  className?: string;
@@ -15,11 +16,6 @@ interface IframeEventCardSkeletonProps {
15
16
  export const IframeEventCardSkeleton = memo(
16
17
  ({
17
18
  showImage,
18
- snippetSetting = {
19
- displayType: true,
20
- displayCost: true,
21
- displayDescription: true,
22
- },
23
19
  colour,
24
20
  isListView = false,
25
21
  className,
@@ -61,31 +57,25 @@ export const IframeEventCardSkeleton = memo(
61
57
  </div>
62
58
  </Card.Text>
63
59
 
64
- {!!snippetSetting.displayType && (
65
- <Card.Text as="div" className="list-view-hided">
66
- <div className="d-flex align-items-center mb-3">
67
- <p className="iframe-event-card__bold m-0">
68
- <Skeleton className="skeleton-w6" />
69
- </p>
70
- </div>
71
- </Card.Text>
72
- )}
60
+ <Card.Text as="div" className="list-view-hided">
61
+ <div className="d-flex align-items-center mb-3">
62
+ <p className="iframe-event-card__bold m-0">
63
+ <Skeleton className="skeleton-w6" />
64
+ </p>
65
+ </div>
66
+ </Card.Text>
73
67
 
74
- {!!snippetSetting.displayCost && (
75
- <Card.Text as="div">
76
- <div className="d-flex align-items-center mb-3">
77
- <p className="iframe-event-card__bold m-0">
78
- <Skeleton className="skeleton-w6" />
79
- </p>
80
- </div>
81
- </Card.Text>
82
- )}
68
+ <Card.Text as="div">
69
+ <div className="d-flex align-items-center mb-3">
70
+ <p className="iframe-event-card__bold m-0">
71
+ <Skeleton className="skeleton-w6" />
72
+ </p>
73
+ </div>
74
+ </Card.Text>
83
75
 
84
- {!!snippetSetting.displayDescription && (
85
- <Card.Text as="div" className="list-view-hided">
86
- <Skeleton className="w-100 h-100" />
87
- </Card.Text>
88
- )}
76
+ <Card.Text as="div" className="list-view-hided">
77
+ <Skeleton className="w-100 h-100" />
78
+ </Card.Text>
89
79
  </div>
90
80
  </Card.Body>
91
81
  </Card>
@@ -581,9 +581,8 @@ export function Default() {
581
581
  date={String(event.startAt)}
582
582
  colour={event.colour}
583
583
  snippetSetting={{
584
- displayCost,
585
- displayType,
586
- displayDescription,
584
+ includeAvailability: [],
585
+ includeFromPrice: [],
587
586
  }}
588
587
  imageSrc={event.imgSrc}
589
588
  goToDetails={() => {}}
@@ -0,0 +1,67 @@
1
+ import React from "react";
2
+ import { Meta, Story } from "@storybook/react";
3
+ import { FormProvider, useForm } from "react-hook-form";
4
+ import { ImageRadioInput, ImageRadioInputProps } from "./ImageRadioInput";
5
+ import { ReactComponent as MonthIcon } from "../assets/widgets/monthCalendar.svg";
6
+ import Icon from "../static/Icon";
7
+
8
+ export default {
9
+ title: "ImageRadioInput",
10
+ component: ImageRadioInput,
11
+ } as Meta;
12
+
13
+ type FormModel = {
14
+ test: string;
15
+ };
16
+
17
+ export const Default: Story<ImageRadioInputProps<FormModel>> = (args) => {
18
+ const form = useForm();
19
+
20
+ return (
21
+ <FormProvider {...form}>
22
+ <ImageRadioInput {...args} />
23
+ </FormProvider>
24
+ );
25
+ };
26
+
27
+ Default.args = {
28
+ img: <MonthIcon />,
29
+ label: "Month",
30
+ name: "test",
31
+ };
32
+
33
+ export const WithFontAwesomeIcon: Story<ImageRadioInputProps<FormModel>> = (
34
+ args
35
+ ) => {
36
+ const form = useForm();
37
+
38
+ return (
39
+ <FormProvider {...form}>
40
+ <ImageRadioInput {...args} />
41
+ </FormProvider>
42
+ );
43
+ };
44
+
45
+ WithFontAwesomeIcon.args = {
46
+ img: <Icon type="bars" />,
47
+ label: "List",
48
+ name: "test",
49
+ };
50
+
51
+ export const Disabled: Story<ImageRadioInputProps<FormModel>> = (args) => {
52
+ const form = useForm();
53
+
54
+ return (
55
+ <FormProvider {...form}>
56
+ <ImageRadioInput {...args} />
57
+ </FormProvider>
58
+ );
59
+ };
60
+
61
+ Disabled.args = {
62
+ img: <MonthIcon />,
63
+ label: "Month",
64
+ name: "test",
65
+ disabled: true,
66
+ disabledMessage: "Coming soon",
67
+ };
@@ -0,0 +1,53 @@
1
+ import clsx from "clsx";
2
+ import React, { ReactNode } from "react";
3
+ import { Form } from "react-bootstrap";
4
+ import { FormCheckInputProps } from "react-bootstrap/esm/FormCheckInput";
5
+ import { Path, RegisterOptions, useFormContext } from "react-hook-form";
6
+
7
+ export type ImageRadioInputProps<FormModel> = {
8
+ img: ReactNode;
9
+ label: string;
10
+ value: string | number;
11
+ name: Path<FormModel>;
12
+ disabled?: boolean;
13
+ disabledMessage?: string;
14
+ rules?: RegisterOptions<FormModel>;
15
+ inputProps?: FormCheckInputProps;
16
+ };
17
+
18
+ export const ImageRadioInput = <FormModel,>({
19
+ img,
20
+ label,
21
+ value,
22
+ name,
23
+ disabled,
24
+ disabledMessage,
25
+ rules,
26
+ inputProps,
27
+ }: ImageRadioInputProps<FormModel>) => {
28
+ const { register } = useFormContext<FormModel>();
29
+
30
+ return (
31
+ <Form.Check className="image-radio-input">
32
+ <Form.Check.Label
33
+ className={clsx("image-radio-input-wrapper", disabled && "disabled")}
34
+ >
35
+ <div className="image-radio-input-image-wrapper">{img}</div>
36
+
37
+ <div className="image-radio-input-label">
38
+ <Form.Check.Input
39
+ type="radio"
40
+ value={value}
41
+ disabled={disabled}
42
+ {...register(name, rules)}
43
+ {...inputProps}
44
+ />
45
+ <span>{label}</span>
46
+ </div>
47
+ </Form.Check.Label>
48
+ <Form.Control.Feedback type="valid" className="d-block text-center">
49
+ {disabledMessage}
50
+ </Form.Control.Feedback>
51
+ </Form.Check>
52
+ );
53
+ };
package/src/index.ts CHANGED
@@ -34,3 +34,6 @@ export * from "./resource";
34
34
  export * from "./virtualized";
35
35
  export * from "./customers";
36
36
  export * from "./striped-static-table";
37
+ export * from "./radio-card";
38
+ export * from "./image-radio-input";
39
+ export * from "./sorting-select";
@@ -34,42 +34,19 @@ export function ProductQuantityRechargingControl<T extends FormValues>(
34
34
  } = props;
35
35
  const {
36
36
  control,
37
- clearErrors,
38
- setError,
37
+ trigger,
39
38
  watch,
39
+ register,
40
40
  formState: { errors },
41
41
  } = useFormContext<T>();
42
42
  const { t } = useTranslation("Design");
43
43
  const totalQuantityId = useId();
44
44
 
45
45
  const maxQuantityValue = watch(`${fieldNamePrefix}.maxQuantity` as Path<T>);
46
- const totalQuantityValue = watch(
47
- `${fieldNamePrefix}.totalQuantity` as Path<T>
48
- );
49
-
50
46
 
51
47
  useEffect(() => {
52
- if (Number(totalQuantityValue) === 0) {
53
- setError(`${fieldNamePrefix}.totalQuantity` as Path<T>, {
54
- type: HookFormService.manualErrorType,
55
- message: t("Validation:fieldMinNumber", {
56
- attribute: t("totalQuantity"),
57
- min: 1,
58
- }),
59
- });
60
- } else if (Number(maxQuantityValue) > Number(totalQuantityValue)) {
61
- setError(`${fieldNamePrefix}.totalQuantity` as Path<T>, {
62
- type: HookFormService.manualErrorType,
63
- message: t("Validation:fieldTotalNumber", {
64
- attribute: t("totalQuantity"),
65
- max: t("maxOrderQuantity"),
66
- }),
67
- });
68
- } else {
69
- clearErrors(`${fieldNamePrefix}.totalQuantity` as Path<T>);
70
- }
71
- // eslint-disable-next-line react-hooks/exhaustive-deps
72
- }, [totalQuantityValue, maxQuantityValue, setError, clearErrors]);
48
+ trigger(`${fieldNamePrefix}.totalQuantity` as Path<T>);
49
+ }, [maxQuantityValue]);
73
50
 
74
51
  return (
75
52
  <>
@@ -90,6 +67,26 @@ export function ProductQuantityRechargingControl<T extends FormValues>(
90
67
  type="number"
91
68
  min={0}
92
69
  step={1}
70
+ {...register(`${fieldNamePrefix}.totalQuantity` as Path<T>, {
71
+ validate: (value) => {
72
+ const min = 1;
73
+ const maxQuantity = Number(maxQuantityValue);
74
+ const totalQuantity = Number(value);
75
+ if (totalQuantity < min) {
76
+ return t("Validation:fieldMinNumber", {
77
+ attribute: t("totalQuantity"),
78
+ min: 1,
79
+ }) as string;
80
+ }
81
+ if (totalQuantity < maxQuantity) {
82
+ return t("Validation:fieldTotalNumber", {
83
+ attribute: t("totalQuantity"),
84
+ max: t("maxOrderQuantity"),
85
+ }) as string;
86
+ }
87
+ return true;
88
+ }
89
+ })}
93
90
  value={value as string}
94
91
  onFocus={onFocus}
95
92
  onChange={onChange}
@@ -0,0 +1,48 @@
1
+ import React, { useEffect } from "react";
2
+ import { Meta, Story } from "@storybook/react";
3
+ import { FormProvider, useForm } from "react-hook-form";
4
+ import { RadioCard, RadioCardProps } from "./RadioCard";
5
+
6
+ export default {
7
+ title: "Widgets / Widget Type Radio Card",
8
+ component: RadioCard,
9
+ } as Meta;
10
+
11
+ type FormModel = {
12
+ name: string;
13
+ };
14
+
15
+ export const Default: Story<RadioCardProps<FormModel>> = (args) => {
16
+ const form = useForm<FormModel>();
17
+
18
+ return (
19
+ <FormProvider {...form}>
20
+ <RadioCard {...args} />
21
+ </FormProvider>
22
+ );
23
+ };
24
+
25
+ Default.args = {
26
+ label: "Venue Map",
27
+ description: "Date > Floor",
28
+ name: "name",
29
+ };
30
+
31
+ export const Invalid: Story<RadioCardProps<FormModel>> = (args) => {
32
+ const form = useForm<FormModel>();
33
+
34
+ return (
35
+ <FormProvider {...form}>
36
+ <RadioCard {...args} />
37
+ </FormProvider>
38
+ );
39
+ };
40
+
41
+ Invalid.args = {
42
+ label: "Venue Map",
43
+ description: "Date > Floor",
44
+ name: "name",
45
+ inputProps: {
46
+ isInvalid: true,
47
+ },
48
+ };
@@ -0,0 +1,49 @@
1
+ import clsx from "clsx";
2
+ import React, { ReactNode } from "react";
3
+ import { Form } from "react-bootstrap";
4
+ import { FormCheckInputProps } from "react-bootstrap/esm/FormCheckInput";
5
+ import { Path, RegisterOptions, useFormContext } from "react-hook-form";
6
+
7
+ export type RadioCardProps<FormModel> = {
8
+ label: string;
9
+ description: ReactNode;
10
+ name: Path<FormModel>;
11
+ value: string;
12
+ rules: RegisterOptions<FormModel>;
13
+ inputProps?: FormCheckInputProps;
14
+ };
15
+
16
+ export const RadioCard = <FormModel,>({
17
+ label,
18
+ description,
19
+ name,
20
+ value,
21
+ rules,
22
+ inputProps,
23
+ }: RadioCardProps<FormModel>) => {
24
+ const {
25
+ register,
26
+ formState: { errors },
27
+ } = useFormContext<FormModel>();
28
+
29
+ const isInvalid = !!errors[name as string] || inputProps?.isInvalid;
30
+
31
+ return (
32
+ <Form.Check className={clsx("radio-card", isInvalid && "invalid")}>
33
+ <Form.Check.Label>
34
+ <div className="radio-card-controls">
35
+ <Form.Check.Input
36
+ type="radio"
37
+ isInvalid={isInvalid}
38
+ value={value}
39
+ {...register(name, rules)}
40
+ {...inputProps}
41
+ />
42
+ <span>{label}</span>
43
+ </div>
44
+
45
+ <p className="radio-card-description">{description}</p>
46
+ </Form.Check.Label>
47
+ </Form.Check>
48
+ );
49
+ };
@@ -0,0 +1 @@
1
+ export { RadioCard } from "./RadioCard";
@@ -1,7 +1,5 @@
1
1
  export * from "./DashboardSettingForm";
2
- export * from "./snippets/form";
3
2
  export * from "./snippets/card";
4
3
  export * from "./snippet-templates/card";
5
4
  export * from "./payments/payments-form/PaymentsForm";
6
5
  export * from "./payments/payments-modal/PaymentsModal";
7
- export * from "./snippets/modal";
@@ -368,11 +368,6 @@ export function Preview({
368
368
  type="Party Doors 22:00 - 03:00"
369
369
  cost={6}
370
370
  date="Sat 2nd May"
371
- snippetSetting={{
372
- displayCost: true,
373
- displayType: true,
374
- displayDescription: true,
375
- }}
376
371
  goToDetails={() => null}
377
372
  shortDate="07/03/2023"
378
373
  />
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { Meta, Story } from "@storybook/react";
3
+ import { SortingSelect, SortingSelectProps } from "./SortingSelect";
4
+
5
+ export default {
6
+ title: "SortingSelect",
7
+ } as Meta;
8
+
9
+ export const Default: Story<SortingSelectProps> = (props) => {
10
+ return <SortingSelect {...props} />;
11
+ };
12
+
13
+ Default.args = {
14
+ onSortingChange: () => null,
15
+ };