@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.
- package/dist/availability-indicator/AvailabilityIndicator.d.ts +5 -4
- package/dist/availability-indicator/AvailabilityIndicator.d.ts.map +1 -1
- package/dist/availability-indicator/AvailabilityIndicator.js +1 -1
- package/dist/calendar/Calendar.d.ts +2 -4
- package/dist/calendar/Calendar.d.ts.map +1 -1
- package/dist/date-time-button/DateTimeButton.d.ts +4 -5
- package/dist/date-time-button/DateTimeButton.d.ts.map +1 -1
- package/dist/date-time-button/DateTimeButton.js +1 -1
- package/package.json +1 -1
- package/src/availability-indicator/AvailabilityIndicator.tsx +41 -33
- package/src/calendar/Calendar.tsx +2 -3
- package/src/date-time-button/DateTimeButton.tsx +11 -6
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
|
|
2
3
|
type AvailabilityIndicatorProps = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
resources: ZoneResourcesAvailability;
|
|
5
|
+
isUnavailable?: boolean;
|
|
6
|
+
isSoldOut?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const AvailabilityIndicator: ({
|
|
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":";
|
|
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,
|
|
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;
|
|
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;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AAIrH,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,QAAQ,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,yBAAyB,GAAG,IAAI,CAAC;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,QAAQ,6CAIlB,aAAa,gBAaf,CAAC"}
|
|
@@ -1,18 +1,17 @@
|
|
|
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;
|
|
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=
|
|
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,5 +1,6 @@
|
|
|
1
|
-
import 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 (
|
|
20
|
-
return { label: "lotsOfSpace", icon:
|
|
25
|
+
if (bookedResources / totalResources <= LOTS_OF_SPACE_LIMIT) {
|
|
26
|
+
return { label: "lotsOfSpace", icon: AvailableIcon };
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
if (
|
|
24
|
-
return { label: "limited", icon:
|
|
29
|
+
if (bookedResources / totalResources >= LIMITED_LIMIT) {
|
|
30
|
+
return { label: "limited", icon: LimitedIcon };
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
return { label: "available", icon:
|
|
33
|
+
return { label: "available", icon: AvailableIcon };
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
type AvailabilityIndicatorProps = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
resources: ZoneResourcesAvailability;
|
|
38
|
+
isUnavailable?: boolean;
|
|
39
|
+
isSoldOut?: boolean;
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
export const AvailabilityIndicator = ({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
resources,
|
|
44
|
+
isUnavailable,
|
|
45
|
+
isSoldOut,
|
|
40
46
|
}: AvailabilityIndicatorProps) => {
|
|
41
47
|
const { t } = useTranslation("Design");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 ||
|
|
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
|
|
67
|
+
<AvailabilityIndicator
|
|
68
|
+
resources={resources}
|
|
69
|
+
isUnavailable={_isDisabled}
|
|
70
|
+
isSoldOut={isSoldOut}
|
|
71
|
+
/>
|
|
67
72
|
)}
|
|
68
73
|
</button>
|
|
69
74
|
);
|