@taqwim/solid 0.1.0-beta.2 → 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +83 -99
- package/dist/source/HijriCalendar.d.ts +4 -0
- package/dist/source/HijriCalendar.jsx +17 -3
- package/dist/source/types.d.ts +6 -1
- package/dist/source/types.js +3 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,49 +1,23 @@
|
|
|
1
1
|
import { createComponent as e, insert as t, memo as n, mergeProps as r, spread as i, template as a, use as o } from "solid-js/web";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createCalendar as s, getCellDisplayValues as c } from "@taqwim/calendar-core";
|
|
3
|
+
import { createContext as l, createEffect as u, createRenderEffect as d, createSignal as f, onCleanup as p, onMount as m, splitProps as h, useContext as g } from "solid-js";
|
|
4
4
|
//#region src/context.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
let e =
|
|
5
|
+
var _ = l();
|
|
6
|
+
function v() {
|
|
7
|
+
let e = g(_);
|
|
8
8
|
if (!e) throw Error("Taqwim calendar parts must be rendered inside <HijriCalendarRoot>");
|
|
9
9
|
return e;
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/types.ts
|
|
13
|
-
var
|
|
14
|
-
"defaultValue",
|
|
15
|
-
"value",
|
|
16
|
-
"onValueChange",
|
|
17
|
-
"defaultPlaceholder",
|
|
18
|
-
"placeholder",
|
|
19
|
-
"onPlaceholderChange",
|
|
20
|
-
"weekStartsOn",
|
|
21
|
-
"weekdayFormat",
|
|
22
|
-
"calendarLabel",
|
|
23
|
-
"fixedWeeks",
|
|
24
|
-
"numberOfMonths",
|
|
25
|
-
"pagedNavigation",
|
|
26
|
-
"multiple",
|
|
27
|
-
"preventDeselect",
|
|
28
|
-
"disableDaysOutsideCurrentView",
|
|
29
|
-
"disabled",
|
|
30
|
-
"readonly",
|
|
31
|
-
"minValue",
|
|
32
|
-
"maxValue",
|
|
33
|
-
"locale",
|
|
34
|
-
"dir",
|
|
35
|
-
"isDateDisabled",
|
|
36
|
-
"isDateUnavailable",
|
|
37
|
-
"nextPage",
|
|
38
|
-
"prevPage"
|
|
39
|
-
];
|
|
13
|
+
var y = /* @__PURE__ */ "defaultValue.value.onValueChange.defaultPlaceholder.placeholder.onPlaceholderChange.weekStartsOn.weekdayFormat.calendarLabel.fixedWeeks.numberOfMonths.pagedNavigation.multiple.preventDeselect.disableDaysOutsideCurrentView.disabled.readonly.minValue.maxValue.locale.showGregorian.dateEmphasis.gregorianLocale.dir.isDateDisabled.isDateUnavailable.nextPage.prevPage".split(".");
|
|
40
14
|
//#endregion
|
|
41
15
|
//#region src/useCalendar.ts
|
|
42
|
-
function
|
|
43
|
-
let t =
|
|
44
|
-
return
|
|
16
|
+
function b(e) {
|
|
17
|
+
let t = s(e()), [n, r] = f(t.getSnapshot());
|
|
18
|
+
return p(t.subscribe(() => {
|
|
45
19
|
r(t.getSnapshot());
|
|
46
|
-
})),
|
|
20
|
+
})), d(() => {
|
|
47
21
|
t.setOptions(e());
|
|
48
22
|
}), {
|
|
49
23
|
store: t,
|
|
@@ -52,133 +26,139 @@ function y(e) {
|
|
|
52
26
|
}
|
|
53
27
|
//#endregion
|
|
54
28
|
//#region src/HijriCalendar.tsx
|
|
55
|
-
var
|
|
56
|
-
function
|
|
29
|
+
var x = /*#__PURE__*/ a("<div><div style=position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0><div role=heading aria-level=2>"), S = /*#__PURE__*/ a("<div role=group data-taqwim-calendar-header>"), C = /*#__PURE__*/ a("<div data-taqwim-calendar-heading>"), w = /*#__PURE__*/ a("<button>"), T = /*#__PURE__*/ a("<div tabindex=-1>"), E = /*#__PURE__*/ a("<div aria-hidden=true data-taqwim-calendar-grid-head>"), D = /*#__PURE__*/ a("<div data-taqwim-calendar-grid-body>"), O = /*#__PURE__*/ a("<div role=row data-taqwim-calendar-grid-row>"), k = /*#__PURE__*/ a("<div data-taqwim-calendar-head-cell>"), A = /*#__PURE__*/ a("<div role=gridcell data-taqwim-calendar-cell>");
|
|
30
|
+
function j(e, t) {
|
|
57
31
|
return typeof e == "function" ? e(t()) : e;
|
|
58
32
|
}
|
|
59
|
-
function
|
|
60
|
-
let [a, s,
|
|
33
|
+
function M(n) {
|
|
34
|
+
let [a, s, c] = h(n, y, ["children", "initialFocus"]), l, d, { store: f, state: p } = b(() => ({
|
|
61
35
|
...a,
|
|
62
36
|
onFocusedDateChange: (e) => {
|
|
63
|
-
d = e ?
|
|
37
|
+
d = e ? f.formatter.isoDate(e) : void 0;
|
|
64
38
|
}
|
|
65
39
|
}));
|
|
66
|
-
|
|
67
|
-
if (
|
|
40
|
+
u(() => {
|
|
41
|
+
if (p(), !d) return;
|
|
68
42
|
let e = d;
|
|
69
|
-
d = void 0,
|
|
70
|
-
}),
|
|
71
|
-
s.initialFocus &&
|
|
43
|
+
d = void 0, l?.querySelector(`[data-taqwim-calendar-cell-trigger][data-value="${e}"]`)?.focus();
|
|
44
|
+
}), m(() => {
|
|
45
|
+
s.initialFocus && f.focusInitial();
|
|
72
46
|
});
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
return e(
|
|
47
|
+
let g = (e) => {
|
|
48
|
+
f.handleKeydown(e) && e.preventDefault();
|
|
49
|
+
}, v = () => (p(), f.getRootProps());
|
|
50
|
+
return e(_.Provider, {
|
|
77
51
|
value: {
|
|
78
|
-
store:
|
|
79
|
-
state:
|
|
52
|
+
store: f,
|
|
53
|
+
state: p
|
|
80
54
|
},
|
|
81
55
|
get children() {
|
|
82
|
-
var e =
|
|
83
|
-
return typeof
|
|
56
|
+
var e = x(), n = e.firstChild, a = n.firstChild, u = l;
|
|
57
|
+
return typeof u == "function" ? o(u, e) : l = e, i(e, r(v, c, { onKeyDown: g }), !1, !0), t(e, () => j(s.children, () => ({
|
|
84
58
|
get months() {
|
|
85
|
-
return
|
|
59
|
+
return p().months;
|
|
86
60
|
},
|
|
87
61
|
get weekDays() {
|
|
88
|
-
return
|
|
62
|
+
return p().weekDays;
|
|
63
|
+
},
|
|
64
|
+
get modelValue() {
|
|
65
|
+
return p().value;
|
|
66
|
+
},
|
|
67
|
+
get gregorianValue() {
|
|
68
|
+
return p().gregorianValue;
|
|
89
69
|
},
|
|
90
70
|
get state() {
|
|
91
|
-
return
|
|
71
|
+
return p();
|
|
92
72
|
},
|
|
93
|
-
store:
|
|
94
|
-
})), n), t(a, () =>
|
|
73
|
+
store: f
|
|
74
|
+
})), n), t(a, () => p().fullCalendarLabel), e;
|
|
95
75
|
}
|
|
96
76
|
});
|
|
97
77
|
}
|
|
98
|
-
function
|
|
99
|
-
let { state: n } =
|
|
78
|
+
function N(e) {
|
|
79
|
+
let { state: n } = v(), [a, o] = h(e, ["children"]);
|
|
100
80
|
return (() => {
|
|
101
|
-
var e =
|
|
81
|
+
var e = S();
|
|
102
82
|
return i(e, r({ get "aria-label"() {
|
|
103
83
|
return n().fullCalendarLabel;
|
|
104
84
|
} }, o), !1, !0), t(e, () => a.children), e;
|
|
105
85
|
})();
|
|
106
86
|
}
|
|
107
|
-
function
|
|
108
|
-
let { state: a } =
|
|
87
|
+
function P(e) {
|
|
88
|
+
let { state: a } = v(), [o, s] = h(e, ["children"]);
|
|
109
89
|
return (() => {
|
|
110
|
-
var e =
|
|
90
|
+
var e = C();
|
|
111
91
|
return i(e, r({ get "data-disabled"() {
|
|
112
92
|
return a().disabled ? "" : void 0;
|
|
113
93
|
} }, s), !1, !0), t(e, (() => {
|
|
114
94
|
var e = n(() => o.children === void 0);
|
|
115
|
-
return () => e() ? a().headingValue :
|
|
95
|
+
return () => e() ? a().headingValue : j(o.children, () => a().headingValue);
|
|
116
96
|
})()), e;
|
|
117
97
|
})();
|
|
118
98
|
}
|
|
119
|
-
function
|
|
120
|
-
let { store: n, state: a } =
|
|
99
|
+
function F(e) {
|
|
100
|
+
let { store: n, state: a } = v(), [o, s] = h(e, ["children"]), c = () => (a(), n.getPrevButtonProps());
|
|
121
101
|
return (() => {
|
|
122
|
-
var e =
|
|
102
|
+
var e = w();
|
|
123
103
|
return i(e, r(c, s, {
|
|
124
104
|
get disabled() {
|
|
125
105
|
return a().isPrevDisabled;
|
|
126
106
|
},
|
|
127
107
|
onClick: () => n.prevPage()
|
|
128
|
-
}), !1, !0), t(e, () =>
|
|
108
|
+
}), !1, !0), t(e, () => j(o.children, () => a().isPrevDisabled)), e;
|
|
129
109
|
})();
|
|
130
110
|
}
|
|
131
|
-
function
|
|
132
|
-
let { store: n, state: a } =
|
|
111
|
+
function I(e) {
|
|
112
|
+
let { store: n, state: a } = v(), [o, s] = h(e, ["children"]), c = () => (a(), n.getNextButtonProps());
|
|
133
113
|
return (() => {
|
|
134
|
-
var e =
|
|
114
|
+
var e = w();
|
|
135
115
|
return i(e, r(c, s, {
|
|
136
116
|
get disabled() {
|
|
137
117
|
return a().isNextDisabled;
|
|
138
118
|
},
|
|
139
119
|
onClick: () => n.nextPage()
|
|
140
|
-
}), !1, !0), t(e, () =>
|
|
141
|
-
})();
|
|
142
|
-
}
|
|
143
|
-
function I(e) {
|
|
144
|
-
let { store: n, state: a } = _(), [o, s] = p(e, ["month", "children"]), c = () => o.month ?? a().months[0], l = () => (a(), n.getGridProps(c()));
|
|
145
|
-
return (() => {
|
|
146
|
-
var e = w();
|
|
147
|
-
return i(e, r(l, s), !1, !0), t(e, () => A(o.children, c)), e;
|
|
120
|
+
}), !1, !0), t(e, () => j(o.children, () => a().isNextDisabled)), e;
|
|
148
121
|
})();
|
|
149
122
|
}
|
|
150
123
|
function L(e) {
|
|
151
|
-
let {
|
|
124
|
+
let { store: n, state: a } = v(), [o, s] = h(e, ["month", "children"]), c = () => o.month ?? a().months[0], l = () => (a(), n.getGridProps(c()));
|
|
152
125
|
return (() => {
|
|
153
126
|
var e = T();
|
|
154
|
-
return i(e,
|
|
127
|
+
return i(e, r(l, s), !1, !0), t(e, () => j(o.children, c)), e;
|
|
155
128
|
})();
|
|
156
129
|
}
|
|
157
130
|
function R(e) {
|
|
158
|
-
let
|
|
131
|
+
let { state: n } = v(), [r, a] = h(e, ["children"]);
|
|
159
132
|
return (() => {
|
|
160
133
|
var e = E();
|
|
161
|
-
return i(e,
|
|
134
|
+
return i(e, a, !1, !0), t(e, () => j(r.children, () => n().weekDays)), e;
|
|
162
135
|
})();
|
|
163
136
|
}
|
|
164
137
|
function z(e) {
|
|
165
|
-
let [n, r] =
|
|
138
|
+
let [n, r] = h(e, ["children"]);
|
|
166
139
|
return (() => {
|
|
167
140
|
var e = D();
|
|
168
141
|
return i(e, r, !1, !0), t(e, () => n.children), e;
|
|
169
142
|
})();
|
|
170
143
|
}
|
|
171
144
|
function B(e) {
|
|
172
|
-
let [n, r] =
|
|
145
|
+
let [n, r] = h(e, ["children"]);
|
|
173
146
|
return (() => {
|
|
174
147
|
var e = O();
|
|
175
148
|
return i(e, r, !1, !0), t(e, () => n.children), e;
|
|
176
149
|
})();
|
|
177
150
|
}
|
|
178
151
|
function V(e) {
|
|
179
|
-
let [n,
|
|
152
|
+
let [n, r] = h(e, ["children"]);
|
|
180
153
|
return (() => {
|
|
181
154
|
var e = k();
|
|
155
|
+
return i(e, r, !1, !0), t(e, () => n.children), e;
|
|
156
|
+
})();
|
|
157
|
+
}
|
|
158
|
+
function H(e) {
|
|
159
|
+
let [n, a] = h(e, ["day", "children"]);
|
|
160
|
+
return (() => {
|
|
161
|
+
var e = A();
|
|
182
162
|
return i(e, r({
|
|
183
163
|
get "aria-selected"() {
|
|
184
164
|
return n.day.isSelected || void 0;
|
|
@@ -195,27 +175,31 @@ function V(e) {
|
|
|
195
175
|
}, a), !1, !0), t(e, () => n.children), e;
|
|
196
176
|
})();
|
|
197
177
|
}
|
|
198
|
-
function
|
|
199
|
-
let { store: a, state: o } =
|
|
200
|
-
function
|
|
178
|
+
function U(e) {
|
|
179
|
+
let { store: a, state: o } = v(), [s, l] = h(e, ["day", "children"]), u = () => c(s.day, a.formatter, o().showGregorian, o().dateEmphasis), d = () => (o(), a.getCellTriggerProps(s.day));
|
|
180
|
+
function f() {
|
|
201
181
|
s.day.isDisabled || s.day.isUnavailable || a.select(s.day.date);
|
|
202
182
|
}
|
|
203
|
-
function
|
|
183
|
+
function p() {
|
|
204
184
|
s.day.isDisabled || s.day.isFocused || a.focusDate(s.day.date);
|
|
205
185
|
}
|
|
206
186
|
return (() => {
|
|
207
|
-
var e =
|
|
208
|
-
return i(e, r(
|
|
209
|
-
onClick:
|
|
210
|
-
onFocus:
|
|
187
|
+
var e = w();
|
|
188
|
+
return i(e, r(d, l, {
|
|
189
|
+
onClick: f,
|
|
190
|
+
onFocus: p
|
|
211
191
|
}), !1, !0), t(e, (() => {
|
|
212
192
|
var e = n(() => s.children === void 0);
|
|
213
|
-
return () => e() ?
|
|
214
|
-
dayValue:
|
|
193
|
+
return () => e() ? u().dayValue : j(s.children, () => ({
|
|
194
|
+
dayValue: u().dayValue,
|
|
195
|
+
hijriDayValue: u().hijriDayValue,
|
|
196
|
+
gregorianDayValue: u().gregorianDayValue,
|
|
197
|
+
primaryDayValue: u().primaryDayValue,
|
|
198
|
+
secondaryDayValue: u().secondaryDayValue,
|
|
215
199
|
day: s.day
|
|
216
200
|
}));
|
|
217
201
|
})()), e;
|
|
218
202
|
})();
|
|
219
203
|
}
|
|
220
204
|
//#endregion
|
|
221
|
-
export {
|
|
205
|
+
export { H as HijriCalendarCell, U as HijriCalendarCellTrigger, L as HijriCalendarGrid, z as HijriCalendarGridBody, R as HijriCalendarGridHead, B as HijriCalendarGridRow, V as HijriCalendarHeadCell, N as HijriCalendarHeader, P as HijriCalendarHeading, I as HijriCalendarNext, F as HijriCalendarPrev, M as HijriCalendarRoot, b as createCalendarStore, v as useHijriCalendarContext };
|
|
@@ -41,6 +41,10 @@ export declare function HijriCalendarCellTrigger(props: ButtonProps & {
|
|
|
41
41
|
day: CalendarDay;
|
|
42
42
|
children?: JSX.Element | ((props: {
|
|
43
43
|
dayValue: string;
|
|
44
|
+
hijriDayValue: string;
|
|
45
|
+
gregorianDayValue: string;
|
|
46
|
+
primaryDayValue: string;
|
|
47
|
+
secondaryDayValue?: string;
|
|
44
48
|
day: CalendarDay;
|
|
45
49
|
}) => JSX.Element);
|
|
46
50
|
}): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCellDisplayValues } from '@taqwim/calendar-core';
|
|
1
2
|
import { createEffect, onMount, splitProps } from 'solid-js';
|
|
2
3
|
import { HijriCalendarContext, useHijriCalendarContext } from './context';
|
|
3
4
|
import { OPTION_KEYS } from './types';
|
|
@@ -79,6 +80,12 @@ export function HijriCalendarRoot(props) {
|
|
|
79
80
|
get weekDays() {
|
|
80
81
|
return state().weekDays;
|
|
81
82
|
},
|
|
83
|
+
get modelValue() {
|
|
84
|
+
return state().value;
|
|
85
|
+
},
|
|
86
|
+
get gregorianValue() {
|
|
87
|
+
return state().gregorianValue;
|
|
88
|
+
},
|
|
82
89
|
get state() {
|
|
83
90
|
return state();
|
|
84
91
|
},
|
|
@@ -194,7 +201,7 @@ export function HijriCalendarCell(props) {
|
|
|
194
201
|
export function HijriCalendarCellTrigger(props) {
|
|
195
202
|
const { store, state } = useHijriCalendarContext();
|
|
196
203
|
const [local, rest] = splitProps(props, ['day', 'children']);
|
|
197
|
-
const
|
|
204
|
+
const display = () => getCellDisplayValues(local.day, store.formatter, state().showGregorian, state().dateEmphasis);
|
|
198
205
|
/*
|
|
199
206
|
* The prop getters read the store's snapshot directly, which is not a signal.
|
|
200
207
|
* Touching `state()` here is what makes this a tracked dependency — without
|
|
@@ -221,7 +228,14 @@ export function HijriCalendarCellTrigger(props) {
|
|
|
221
228
|
}
|
|
222
229
|
return (<button {...triggerProps()} {...rest} onClick={onClick} onFocus={onFocus}>
|
|
223
230
|
{local.children === undefined
|
|
224
|
-
?
|
|
225
|
-
: renderChildren(local.children, () => ({
|
|
231
|
+
? display().dayValue
|
|
232
|
+
: renderChildren(local.children, () => ({
|
|
233
|
+
dayValue: display().dayValue,
|
|
234
|
+
hijriDayValue: display().hijriDayValue,
|
|
235
|
+
gregorianDayValue: display().gregorianDayValue,
|
|
236
|
+
primaryDayValue: display().primaryDayValue,
|
|
237
|
+
secondaryDayValue: display().secondaryDayValue,
|
|
238
|
+
day: local.day,
|
|
239
|
+
}))}
|
|
226
240
|
</button>);
|
|
227
241
|
}
|
package/dist/source/types.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export interface HijriCalendarRootOptions {
|
|
|
33
33
|
minValue?: HijriDateObject;
|
|
34
34
|
maxValue?: HijriDateObject;
|
|
35
35
|
locale?: string;
|
|
36
|
+
showGregorian?: boolean;
|
|
37
|
+
dateEmphasis?: import('@taqwim/calendar-core').DateEmphasis;
|
|
38
|
+
gregorianLocale?: string;
|
|
36
39
|
dir?: 'ltr' | 'rtl';
|
|
37
40
|
isDateDisabled?: Matcher;
|
|
38
41
|
isDateUnavailable?: Matcher;
|
|
@@ -44,6 +47,8 @@ export interface HijriCalendarRootOptions {
|
|
|
44
47
|
export interface HijriCalendarRenderProps {
|
|
45
48
|
months: CalendarMonth[];
|
|
46
49
|
weekDays: string[];
|
|
50
|
+
modelValue: HijriDateObject | HijriDateObject[] | undefined;
|
|
51
|
+
gregorianValue: Date | Date[] | undefined;
|
|
47
52
|
state: CalendarState;
|
|
48
53
|
store: CalendarStore;
|
|
49
54
|
}
|
|
@@ -52,4 +57,4 @@ export type HijriCalendarRootProps = HijriCalendarRootOptions & Omit<JSX.HTMLAtt
|
|
|
52
57
|
children?: JSX.Element | ((props: HijriCalendarRenderProps) => JSX.Element);
|
|
53
58
|
};
|
|
54
59
|
/** The option names, so the root can tell them from DOM attributes. */
|
|
55
|
-
export declare const OPTION_KEYS: readonly ["defaultValue", "value", "onValueChange", "defaultPlaceholder", "placeholder", "onPlaceholderChange", "weekStartsOn", "weekdayFormat", "calendarLabel", "fixedWeeks", "numberOfMonths", "pagedNavigation", "multiple", "preventDeselect", "disableDaysOutsideCurrentView", "disabled", "readonly", "minValue", "maxValue", "locale", "dir", "isDateDisabled", "isDateUnavailable", "nextPage", "prevPage"];
|
|
60
|
+
export declare const OPTION_KEYS: readonly ["defaultValue", "value", "onValueChange", "defaultPlaceholder", "placeholder", "onPlaceholderChange", "weekStartsOn", "weekdayFormat", "calendarLabel", "fixedWeeks", "numberOfMonths", "pagedNavigation", "multiple", "preventDeselect", "disableDaysOutsideCurrentView", "disabled", "readonly", "minValue", "maxValue", "locale", "showGregorian", "dateEmphasis", "gregorianLocale", "dir", "isDateDisabled", "isDateUnavailable", "nextPage", "prevPage"];
|
package/dist/source/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqwim/solid",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Headless Solid components for Hijri calendars, built on @taqwim/calendar-core",
|
|
6
6
|
"keywords": [
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@taqwim/core": "0.1.0-beta.
|
|
50
|
-
"@taqwim/
|
|
49
|
+
"@taqwim/calendar-core": "0.1.0-beta.3",
|
|
50
|
+
"@taqwim/core": "0.1.0-beta.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@arethetypeswrong/cli": "^0.18.2",
|