@licklist/design 0.44.486-dev.71 → 0.44.486-dev.72

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.
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
2
3
  type AvailabilityIndicatorProps = {
3
- booked: number;
4
- total: number;
5
- notAvailable?: boolean;
4
+ resources: ZoneResourcesAvailability;
5
+ isUnavailable?: boolean;
6
+ isSoldOut?: boolean;
6
7
  };
7
- export declare const AvailabilityIndicator: ({ booked, total, notAvailable, }: AvailabilityIndicatorProps) => JSX.Element;
8
+ export declare const AvailabilityIndicator: ({ resources, isUnavailable, isSoldOut, }: AvailabilityIndicatorProps) => JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=AvailabilityIndicator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvailabilityIndicator.d.ts","sourceRoot":"","sources":["../../src/availability-indicator/AvailabilityIndicator.tsx"],"names":[],"mappings":";AA6BA,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,qBAAqB,qCAI/B,0BAA0B,gBAmB5B,CAAC"}
1
+ {"version":3,"file":"AvailabilityIndicator.d.ts","sourceRoot":"","sources":["../../src/availability-indicator/AvailabilityIndicator.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AAiCrH,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,yBAAyB,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,qBAAqB,6CAI/B,0BAA0B,gBAc5B,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,a=require("react"),t=(e=a)&&"object"==typeof e&&"default"in e?e.default:e,l=require("react-i18next"),i=require("../assets/iframe/available.svg.js"),o=require("../assets/iframe/limited.svg.js"),n=require("../assets/iframe/soldOut.svg.js");exports.AvailabilityIndicator=function(e){var a=e.booked,s=e.total,r=e.notAvailable,c=l.useTranslation("Design").t,m=function(e,a){return e===a?{label:"soldOut",icon:t.createElement(n.ReactComponent,{className:"logo"})}:e/a<=.2?{label:"lotsOfSpace",icon:t.createElement(i.ReactComponent,{className:"logo"})}:e/a>=.8?{label:"limited",icon:t.createElement(o.ReactComponent,{className:"logo"})}:{label:"available",icon:t.createElement(i.ReactComponent,{className:"logo"})}}(a,s),u=m.icon,v=m.label;return r?t.createElement("div",{className:"availability-indicator"},t.createElement(n.ReactComponent,{className:"logo"}),t.createElement("div",null,c("notAvailable"))):t.createElement("div",{className:"availability-indicator"},u,t.createElement("div",null,c(v)))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,l=require("react-i18next"),i=require("../assets/iframe/available.svg.js"),n=require("../assets/iframe/limited.svg.js"),r=require("../assets/iframe/soldOut.svg.js"),o=function(e){var t=e.icon,l=e.label;return a.createElement("div",{className:"availability-indicator"},t,a.createElement("div",null,l))};exports.AvailabilityIndicator=function(e){var t=e.resources,s=e.isUnavailable,c=e.isSoldOut,u=l.useTranslation("Design").t;if(s)return a.createElement(o,{icon:r.ReactComponent,label:u("notAvailable")});if(c)return a.createElement(o,{icon:r.ReactComponent,label:u("soldOut")});var b=function(e){var t=e.bookedResources,a=e.totalResources;return t===a?{label:"soldOut",icon:r.ReactComponent}:t/a<=.2?{label:"lotsOfSpace",icon:i.ReactComponent}:t/a>=.8?{label:"limited",icon:n.ReactComponent}:{label:"available",icon:i.ReactComponent}}(t),m=b.icon,v=b.label;return a.createElement(o,{icon:m,label:u(v)})};
@@ -1,5 +1,6 @@
1
1
  import { Dispatch, ReactElement, SetStateAction } from "react";
2
2
  import { DateTime } from "luxon";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  export declare const defaultStartDay: DateTime;
4
5
  export type CalendarProps = {
5
6
  currentDate: DateTime;
@@ -11,10 +12,7 @@ export type CalendarProps = {
11
12
  fromPrice?: string | ReactElement | null;
12
13
  isLoading?: boolean;
13
14
  initialDate?: DateTime;
14
- getAvailability?: (date: DateTime) => {
15
- booked: number;
16
- total: number;
17
- } | undefined;
15
+ getAvailability?: (date: DateTime) => ZoneResourcesAvailability | null;
18
16
  includeAvailability?: boolean;
19
17
  };
20
18
  export declare const Calendar: ({ disabledDates, initialDate, ...props }: CalendarProps) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,eAAO,MAAM,eAAe,UAK1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,aAAa,EAAE,QAAQ,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,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@
1
1
  import { ReactElement } from "react";
2
2
  import { DateTime } from "luxon";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  export type DateTimeButtonProps<T = DateTime | string> = {
4
5
  date: T;
5
6
  isSelected?: boolean;
6
7
  isDisabled?: boolean;
8
+ isSoldOut?: boolean;
7
9
  onSelect: (date: T) => void;
8
10
  isOnlyTimeContainer?: boolean;
9
11
  price?: string | number | ReactElement | null;
10
- resources?: {
11
- booked: number;
12
- total: number;
13
- };
12
+ resources?: ZoneResourcesAvailability | null;
14
13
  calendarView?: boolean;
15
14
  showResources?: boolean;
16
15
  };
17
- export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled: _isDisabled, isSelected, onSelect, isOnlyTimeContainer, price, resources, calendarView, showResources, }: DateTimeButtonProps<T>) => JSX.Element;
16
+ export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled: _isDisabled, isSelected, isSoldOut, onSelect, isOnlyTimeContainer, price, resources, calendarView, showResources, }: DateTimeButtonProps<T>) => JSX.Element;
18
17
  //# sourceMappingURL=DateTimeButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,cAAc,oMAgD1B,CAAC"}
1
+ {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AAIrH,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,cAAc,+MAsD1B,CAAC"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),i=e(require("react")),a=e(require("clsx")),r=require("../availability-indicator/AvailabilityIndicator.js"),n=require("./DateContent.js");exports.DateTimeButton=function(e){var l=e.date,o=e.isDisabled,s=e.isSelected,c=e.onSelect,d=e.isOnlyTimeContainer,u=e.price,b=e.resources,m=e.calendarView,y=e.showResources,v="string"==typeof l,f=o||b&&b.booked===b.total;return i.createElement("button",{type:"button",onClick:function(){return c(l)},disabled:f,className:a("date-time-button",f&&"disabled",s&&"selected",v&&"time-button",d&&"only-time-container",!v&&"today",m&&"calendar-view")},v?l:i.createElement(n.DateContent,{date:l,isDisabled:f,isSelected:s}),u&&!f&&i.createElement("div",{className:"price"},u),y&&b&&i.createElement(r.AvailabilityIndicator,t.__assign({},b,{notAvailable:o})))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),i=e(require("clsx")),a=require("../availability-indicator/AvailabilityIndicator.js"),r=require("./DateContent.js");exports.DateTimeButton=function(e){var n=e.date,o=e.isDisabled,s=e.isSelected,l=e.isSoldOut,c=e.onSelect,u=e.isOnlyTimeContainer,d=e.price,b=e.resources,m=e.calendarView,y=e.showResources,v="string"==typeof n,f=o||b&&b.bookedResources===b.totalResources;return t.createElement("button",{type:"button",onClick:function(){return c(n)},disabled:f,className:i("date-time-button",f&&"disabled",s&&"selected",v&&"time-button",u&&"only-time-container",!v&&"today",m&&"calendar-view")},v?n:t.createElement(r.DateContent,{date:n,isDisabled:f,isSelected:s}),d&&!f&&t.createElement("div",{className:"price"},d),y&&b&&t.createElement(a.AvailabilityIndicator,{resources:b,isUnavailable:o,isSoldOut:l}))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.486-dev.71",
3
+ "version": "0.44.486-dev.72",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -1,5 +1,6 @@
1
- import React, { ReactElement } from "react";
1
+ import React, { FunctionComponent, SVGProps } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  import { ReactComponent as AvailableIcon } from "../assets/iframe/available.svg";
4
5
  import { ReactComponent as LimitedIcon } from "../assets/iframe/limited.svg";
5
6
  import { ReactComponent as SoldOutIcon } from "../assets/iframe/soldOut.svg";
@@ -7,53 +8,60 @@ import { ReactComponent as SoldOutIcon } from "../assets/iframe/soldOut.svg";
7
8
  const LOTS_OF_SPACE_LIMIT = 0.2;
8
9
  const LIMITED_LIMIT = 0.8;
9
10
 
10
- const getIconsAndLabels = (
11
- booked: number,
12
- total: number
13
- ): { label: string; icon: ReactElement } => {
14
- if (booked === total) {
15
- return { label: "soldOut", icon: <SoldOutIcon className="logo" /> };
11
+ type Config = {
12
+ label: string;
13
+ icon: FunctionComponent<SVGProps<SVGSVGElement>>;
14
+ };
15
+
16
+ const getIconsAndLabels = ({
17
+ bookedResources,
18
+ totalResources,
19
+ }: ZoneResourcesAvailability): Config => {
20
+ if (bookedResources === totalResources) {
21
+ return { label: "soldOut", icon: SoldOutIcon };
16
22
  }
17
23
 
18
24
  // lots of space if less than 80% booked
19
- if (booked / total <= LOTS_OF_SPACE_LIMIT) {
20
- return { label: "lotsOfSpace", icon: <AvailableIcon className="logo" /> };
25
+ if (bookedResources / totalResources <= LOTS_OF_SPACE_LIMIT) {
26
+ return { label: "lotsOfSpace", icon: AvailableIcon };
21
27
  }
22
28
 
23
- if (booked / total >= LIMITED_LIMIT) {
24
- return { label: "limited", icon: <LimitedIcon className="logo" /> };
29
+ if (bookedResources / totalResources >= LIMITED_LIMIT) {
30
+ return { label: "limited", icon: LimitedIcon };
25
31
  }
26
32
 
27
- return { label: "available", icon: <AvailableIcon className="logo" /> };
33
+ return { label: "available", icon: AvailableIcon };
28
34
  };
29
35
 
30
36
  type AvailabilityIndicatorProps = {
31
- booked: number;
32
- total: number;
33
- notAvailable?: boolean;
37
+ resources: ZoneResourcesAvailability;
38
+ isUnavailable?: boolean;
39
+ isSoldOut?: boolean;
34
40
  };
35
41
 
36
42
  export const AvailabilityIndicator = ({
37
- booked,
38
- total,
39
- notAvailable,
43
+ resources,
44
+ isUnavailable,
45
+ isSoldOut,
40
46
  }: AvailabilityIndicatorProps) => {
41
47
  const { t } = useTranslation("Design");
42
- const { icon, label } = getIconsAndLabels(booked, total);
43
-
44
- if (notAvailable) {
45
- return (
46
- <div className="availability-indicator">
47
- <SoldOutIcon className="logo" />
48
- <div>{t("notAvailable")}</div>
49
- </div>
50
- );
48
+
49
+ if (isUnavailable) {
50
+ return <Indicator icon={SoldOutIcon} label={t("notAvailable")} />;
51
51
  }
52
52
 
53
- return (
54
- <div className="availability-indicator">
55
- {icon}
56
- <div>{t(label)}</div>
57
- </div>
58
- );
53
+ if (isSoldOut) {
54
+ return <Indicator icon={SoldOutIcon} label={t("soldOut")} />;
55
+ }
56
+
57
+ const { icon, label } = getIconsAndLabels(resources);
58
+
59
+ return <Indicator icon={icon} label={t(label)} />;
59
60
  };
61
+
62
+ const Indicator = ({ icon, label }: Config) => (
63
+ <div className="availability-indicator">
64
+ {icon}
65
+ <div>{label}</div>
66
+ </div>
67
+ );
@@ -1,5 +1,6 @@
1
1
  import React, { Dispatch, ReactElement, SetStateAction } from "react";
2
2
  import { DateTime } from "luxon";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  import { CalendarButtons } from "./components/CalendarButtons";
4
5
  import { CalendarDates } from "./components/CalendarDates";
5
6
 
@@ -20,9 +21,7 @@ export type CalendarProps = {
20
21
  fromPrice?: string | ReactElement | null;
21
22
  isLoading?: boolean;
22
23
  initialDate?: DateTime;
23
- getAvailability?: (
24
- date: DateTime
25
- ) => { booked: number; total: number } | undefined;
24
+ getAvailability?: (date: DateTime) => ZoneResourcesAvailability | null;
26
25
  includeAvailability?: boolean;
27
26
  };
28
27
 
@@ -1,6 +1,7 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import clsx from "clsx";
3
3
  import { DateTime } from "luxon";
4
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
4
5
  import { AvailabilityIndicator } from "../availability-indicator";
5
6
  import { DateContent } from "./DateContent";
6
7
 
@@ -8,13 +9,11 @@ export type DateTimeButtonProps<T = DateTime | string> = {
8
9
  date: T;
9
10
  isSelected?: boolean;
10
11
  isDisabled?: boolean;
12
+ isSoldOut?: boolean;
11
13
  onSelect: (date: T) => void;
12
14
  isOnlyTimeContainer?: boolean;
13
15
  price?: string | number | ReactElement | null;
14
- resources?: {
15
- booked: number;
16
- total: number;
17
- };
16
+ resources?: ZoneResourcesAvailability | null;
18
17
  calendarView?: boolean;
19
18
  showResources?: boolean;
20
19
  };
@@ -23,6 +22,7 @@ export const DateTimeButton = <T extends DateTime | string>({
23
22
  date,
24
23
  isDisabled: _isDisabled,
25
24
  isSelected,
25
+ isSoldOut,
26
26
  onSelect,
27
27
  isOnlyTimeContainer,
28
28
  price,
@@ -33,7 +33,8 @@ export const DateTimeButton = <T extends DateTime | string>({
33
33
  const isTimeVariant = typeof date === "string";
34
34
 
35
35
  const isDisabled =
36
- _isDisabled || (resources && resources.booked === resources.total);
36
+ _isDisabled ||
37
+ (resources && resources.bookedResources === resources.totalResources);
37
38
 
38
39
  return (
39
40
  <button
@@ -63,7 +64,11 @@ export const DateTimeButton = <T extends DateTime | string>({
63
64
  {price && !isDisabled && <div className="price">{price}</div>}
64
65
 
65
66
  {showResources && resources && (
66
- <AvailabilityIndicator {...resources} notAvailable={_isDisabled} />
67
+ <AvailabilityIndicator
68
+ resources={resources}
69
+ isUnavailable={_isDisabled}
70
+ isSoldOut={isSoldOut}
71
+ />
67
72
  )}
68
73
  </button>
69
74
  );