@mellow.io/ds 0.1.0 → 0.2.0
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/README.md +230 -0
- package/dist/components/datepicker/datepicker-utils.d.ts +37 -0
- package/dist/components/datepicker/datepicker-utils.d.ts.map +1 -0
- package/dist/components/datepicker/datepicker-utils.js +157 -0
- package/dist/components/datepicker/datepicker-utils.js.map +1 -0
- package/dist/components/datepicker/datepicker.d.ts +62 -0
- package/dist/components/datepicker/datepicker.d.ts.map +1 -0
- package/dist/components/datepicker/datepicker.js +380 -0
- package/dist/components/datepicker/datepicker.js.map +1 -0
- package/dist/components/datepicker/datepicker.styles.d.ts +2 -0
- package/dist/components/datepicker/datepicker.styles.d.ts.map +1 -0
- package/dist/components/datepicker/datepicker.styles.js +384 -0
- package/dist/components/datepicker/datepicker.styles.js.map +1 -0
- package/dist/components/datepicker/index.d.ts +4 -0
- package/dist/components/datepicker/index.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -65
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +9 -0
- package/dist/react/index.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# @mellow.io/ds
|
|
2
|
+
|
|
3
|
+
Mellow Design System — a library of 32 UI components built with [Lit 3](https://lit.dev/) Web Components. Works with any framework or no framework at all.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mellow.io/ds
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### HTML / Vanilla JS
|
|
14
|
+
|
|
15
|
+
Import the components you need. Each import auto-registers the custom element.
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script type="module">
|
|
19
|
+
import '@mellow.io/ds/button'
|
|
20
|
+
import '@mellow.io/ds/input'
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<mellow-button variant="primary" size="md">Save</mellow-button>
|
|
24
|
+
<mellow-input label="Email" placeholder="you@example.com"></mellow-input>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### React
|
|
28
|
+
|
|
29
|
+
React wrappers handle property binding and event mapping via `@lit/react`.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { MellowButtonReact, MellowInputReact } from '@mellow.io/ds/react'
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<MellowButtonReact variant="primary" size="md">
|
|
38
|
+
Save
|
|
39
|
+
</MellowButtonReact>
|
|
40
|
+
<MellowInputReact
|
|
41
|
+
label="Email"
|
|
42
|
+
placeholder="you@example.com"
|
|
43
|
+
onMellowChange={(e) => console.log(e.detail.value)}
|
|
44
|
+
/>
|
|
45
|
+
</>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Import Strategies
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// Full bundle — registers all 32 components at once
|
|
54
|
+
import '@mellow.io/ds'
|
|
55
|
+
|
|
56
|
+
// Per-component (tree-shakeable, recommended)
|
|
57
|
+
import '@mellow.io/ds/button'
|
|
58
|
+
import '@mellow.io/ds/tabs'
|
|
59
|
+
|
|
60
|
+
// React wrappers
|
|
61
|
+
import { MellowButtonReact } from '@mellow.io/ds/react'
|
|
62
|
+
|
|
63
|
+
// TypeScript types only
|
|
64
|
+
import type { ButtonVariant, ButtonSize } from '@mellow.io/ds/button'
|
|
65
|
+
|
|
66
|
+
// Design tokens as CSS
|
|
67
|
+
import '@mellow.io/ds/tokens'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Components
|
|
71
|
+
|
|
72
|
+
### Forms
|
|
73
|
+
|
|
74
|
+
| Component | Tag | Description |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| [Button](docs/components.md#button) | `<mellow-button>` | Primary, secondary, brand, link variants with loading state |
|
|
77
|
+
| [Input](docs/components.md#input) | `<mellow-input>` | Text input with label, error, helper, clearable, icon slots |
|
|
78
|
+
| [Textarea](docs/components.md#textarea) | `<mellow-textarea>` | Multi-line input with character count |
|
|
79
|
+
| [Checkbox](docs/components.md#checkbox) | `<mellow-checkbox>` | Checkbox with indeterminate state |
|
|
80
|
+
| [Radio](docs/components.md#radio) | `<mellow-radio>` | Radio button (use inside `<mellow-radio-group>`) |
|
|
81
|
+
| [Switch](docs/components.md#switch) | `<mellow-switch>` | Toggle switch |
|
|
82
|
+
| [Select](docs/components.md#select) | `<mellow-select>` | Dropdown select with searchable option |
|
|
83
|
+
| [Form Field](docs/components.md#form-field) | `<mellow-form-field>` | Wrapper providing label, error, hint for any input |
|
|
84
|
+
| [Datepicker](docs/components.md#datepicker) | `<mellow-datepicker>` | Calendar with single/range selection, presets, min/max |
|
|
85
|
+
|
|
86
|
+
### Primitives
|
|
87
|
+
|
|
88
|
+
| Component | Tag | Description |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| [Badge](docs/components.md#badge) | `<mellow-badge>` | Status badge with 7 semantic variants |
|
|
91
|
+
| [Tag](docs/components.md#tag) | `<mellow-tag>` | Selectable/removable chip |
|
|
92
|
+
| [Icon](docs/components.md#icon) | `<mellow-icon>` | SVG icon with registry system |
|
|
93
|
+
| [Divider](docs/components.md#divider) | `<mellow-divider>` | Horizontal/vertical separator |
|
|
94
|
+
|
|
95
|
+
### Layout
|
|
96
|
+
|
|
97
|
+
| Component | Tag | Description |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| [Card](docs/components.md#card) | `<mellow-card>` | Content container with header, icon, actions |
|
|
100
|
+
| [Stack](docs/components.md#stack) | `<mellow-stack>` | Flex layout (row/column) |
|
|
101
|
+
| [Grid](docs/components.md#grid) | `<mellow-grid>` | CSS grid layout |
|
|
102
|
+
|
|
103
|
+
### Feedback
|
|
104
|
+
|
|
105
|
+
| Component | Tag | Description |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| [Alert](docs/components.md#alert) | `<mellow-alert>` | Inline notification with 5 variants |
|
|
108
|
+
| [Toast](docs/components.md#toast) | `<mellow-toast>` | Floating notification with auto-dismiss |
|
|
109
|
+
| [Spinner](docs/components.md#spinner) | `<mellow-spinner>` | Loading spinner |
|
|
110
|
+
| [Skeleton](docs/components.md#skeleton) | `<mellow-skeleton>` | Content placeholder |
|
|
111
|
+
| [Progress](docs/components.md#progress) | `<mellow-progress>` | Progress bar |
|
|
112
|
+
| [Stepper](docs/components.md#stepper) | `<mellow-stepper>` | Segmented step indicator |
|
|
113
|
+
|
|
114
|
+
### Overlay
|
|
115
|
+
|
|
116
|
+
| Component | Tag | Description |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| [Dialog](docs/components.md#dialog) | `<mellow-dialog>` | Modal dialog |
|
|
119
|
+
| [Tooltip](docs/components.md#tooltip) | `<mellow-tooltip>` | Hover/focus tooltip with subtitle |
|
|
120
|
+
| [Popover](docs/components.md#popover) | `<mellow-popover>` | Click/hover popover |
|
|
121
|
+
| [Dropdown](docs/components.md#dropdown) | `<mellow-dropdown>` | Dropdown menu with search |
|
|
122
|
+
|
|
123
|
+
### Navigation
|
|
124
|
+
|
|
125
|
+
| Component | Tag | Description |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| [Tabs](docs/components.md#tabs) | `<mellow-tabs>` | Segmented tab navigation |
|
|
128
|
+
| [Breadcrumb](docs/components.md#breadcrumb) | `<mellow-breadcrumb>` | Breadcrumb trail |
|
|
129
|
+
| [Pagination](docs/components.md#pagination) | `<mellow-pagination>` | Page navigation |
|
|
130
|
+
| [Link](docs/components.md#link) | `<mellow-link>` | Styled anchor |
|
|
131
|
+
|
|
132
|
+
### Data
|
|
133
|
+
|
|
134
|
+
| Component | Tag | Description |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| [Table](docs/components.md#table) | `<mellow-table>` | Data table with sorting, pagination, selection |
|
|
137
|
+
| [Avatar](docs/components.md#avatar) | `<mellow-avatar>` | User avatar (image, initials, fallback) |
|
|
138
|
+
| [Accordion](docs/components.md#accordion) | `<mellow-accordion>` | Collapsible sections |
|
|
139
|
+
|
|
140
|
+
## Theming
|
|
141
|
+
|
|
142
|
+
All visual values are exposed as CSS custom properties with sensible defaults. Override them at any scope.
|
|
143
|
+
|
|
144
|
+
```css
|
|
145
|
+
/* Global theme override */
|
|
146
|
+
:root {
|
|
147
|
+
--mellow-colors-primary-mellow-orange: #ff6f23;
|
|
148
|
+
--mellow-text-primary: #232222;
|
|
149
|
+
--mellow-text-secondary: #8a8686;
|
|
150
|
+
--mellow-typography-font-family-body: 'Suisse Int\'l', system-ui, sans-serif;
|
|
151
|
+
--mellow-space-5: 20px;
|
|
152
|
+
--mellow-radius-2: 8px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Per-component override */
|
|
156
|
+
mellow-button {
|
|
157
|
+
--mellow-button-primary-default: #1a1a2e;
|
|
158
|
+
--mellow-button-primary-hovered: #16213e;
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Token Categories
|
|
163
|
+
|
|
164
|
+
| Prefix | Purpose | Examples |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `--mellow-colors-*` | Color palette | `--mellow-colors-primary-mellow-orange` |
|
|
167
|
+
| `--mellow-text-*` | Text colors | `--mellow-text-primary`, `--mellow-text-brand` |
|
|
168
|
+
| `--mellow-bg-*` | Background colors | `--mellow-bg-surface-primary` |
|
|
169
|
+
| `--mellow-button-*` | Button-specific colors | `--mellow-button-primary-default` |
|
|
170
|
+
| `--mellow-space-*` | Spacing scale | `--mellow-space-1` (4px) through `--mellow-space-6` (24px) |
|
|
171
|
+
| `--mellow-radius-*` | Border radius | `--mellow-radius-1` (4px) through `--mellow-radius-full` (9999px) |
|
|
172
|
+
| `--mellow-font-size-*` | Font sizes | `--mellow-font-size-12` through `--mellow-font-size-18` |
|
|
173
|
+
| `--mellow-line-height-*` | Line heights | `--mellow-line-height-14` through `--mellow-line-height-24` |
|
|
174
|
+
| `--mellow-font-weight-*` | Font weights | `--mellow-font-weight-regular` (400), `--mellow-font-weight-medium` (500) |
|
|
175
|
+
| `--mellow-typography-font-family-*` | Font families | `--mellow-typography-font-family-body` |
|
|
176
|
+
|
|
177
|
+
## Events
|
|
178
|
+
|
|
179
|
+
All custom events use the `mellow-` prefix, bubble, and are composed (cross shadow DOM boundaries).
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
// Vanilla JS
|
|
183
|
+
document.querySelector('mellow-input')
|
|
184
|
+
.addEventListener('mellow-change', (e) => {
|
|
185
|
+
console.log(e.detail.value)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
// React (via wrappers)
|
|
189
|
+
<MellowInputReact onMellowChange={(e) => console.log(e.detail.value)} />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
| Event | Components | Detail |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `mellow-change` | input, textarea, checkbox, radio-group, select, switch, datepicker | `{ value }` or `{ checked }` |
|
|
195
|
+
| `mellow-input` | input, textarea | `{ value }` |
|
|
196
|
+
| `mellow-select` | dropdown, tag, datepicker | `{ value }` or `{ selected }` |
|
|
197
|
+
| `mellow-dismiss` | alert, toast | — |
|
|
198
|
+
| `mellow-close` | dialog | — |
|
|
199
|
+
| `mellow-toggle` | accordion-item, popover | `{ open }` |
|
|
200
|
+
| `mellow-sort` | table | `{ column, direction }` |
|
|
201
|
+
| `mellow-page-change` | pagination, table | `{ page }` |
|
|
202
|
+
| `mellow-tab-change` | tabs | `{ index }` |
|
|
203
|
+
| `mellow-remove` | tag | — |
|
|
204
|
+
| `mellow-search` | dropdown | `{ query }` |
|
|
205
|
+
| `mellow-page-size-change` | table | `{ pageSize }` |
|
|
206
|
+
|
|
207
|
+
## Browser Support
|
|
208
|
+
|
|
209
|
+
Works in all browsers that support Web Components (Custom Elements v1 + Shadow DOM):
|
|
210
|
+
- Chrome / Edge 67+
|
|
211
|
+
- Firefox 63+
|
|
212
|
+
- Safari 13.1+
|
|
213
|
+
|
|
214
|
+
## API Reference
|
|
215
|
+
|
|
216
|
+
See [docs/components.md](docs/components.md) for the full API of every component — properties, slots, events, and types.
|
|
217
|
+
|
|
218
|
+
## Development
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npm install # Install dependencies
|
|
222
|
+
npm run dev # Start Storybook on :6006
|
|
223
|
+
npm test # Run 497 tests
|
|
224
|
+
npm run build # Vite build + type declarations
|
|
225
|
+
npm run typecheck # TypeScript check
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
UNLICENSED
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface CalendarDay {
|
|
2
|
+
date: Date;
|
|
3
|
+
day: number;
|
|
4
|
+
currentMonth: boolean;
|
|
5
|
+
today: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DatepickerPreset {
|
|
9
|
+
label: string;
|
|
10
|
+
getValue: () => {
|
|
11
|
+
start: string;
|
|
12
|
+
end: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare function parseISO(value: string): Date | null;
|
|
16
|
+
export declare function formatISO(date: Date): string;
|
|
17
|
+
export declare function isSameDay(a: Date, b: Date): boolean;
|
|
18
|
+
export declare function isBefore(a: Date, b: Date): boolean;
|
|
19
|
+
export declare function isAfter(a: Date, b: Date): boolean;
|
|
20
|
+
export declare function isBetween(date: Date, start: Date, end: Date): boolean;
|
|
21
|
+
export declare function stripTime(date: Date): Date;
|
|
22
|
+
export declare function addMonths(date: Date, months: number): Date;
|
|
23
|
+
export declare function addYears(date: Date, years: number): Date;
|
|
24
|
+
export declare function startOfMonth(date: Date): Date;
|
|
25
|
+
export declare function endOfMonth(date: Date): Date;
|
|
26
|
+
export declare function getCalendarGrid(viewDate: Date, weekStart: 0 | 1, minDate: Date | null, maxDate: Date | null): CalendarDay[];
|
|
27
|
+
export declare function getWeekdayNames(locale: string, weekStart: 0 | 1): string[];
|
|
28
|
+
export declare function getMonthNames(locale: string): string[];
|
|
29
|
+
export declare function getMonthName(locale: string, month: number): string;
|
|
30
|
+
export declare function getYearsGrid(centerYear: number): number[];
|
|
31
|
+
export declare function getDefaultPresets(locale: string): DatepickerPreset[];
|
|
32
|
+
export declare function parseRangeValue(value: string): {
|
|
33
|
+
start: Date | null;
|
|
34
|
+
end: Date | null;
|
|
35
|
+
};
|
|
36
|
+
export declare function orderDates(a: Date, b: Date): [Date, Date];
|
|
37
|
+
//# sourceMappingURL=datepicker-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datepicker-utils.d.ts","sourceRoot":"","sources":["../../../src/components/datepicker/datepicker-utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAQnD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAK5C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO,CAMnD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO,CAElD;AAED,wBA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AG,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAMvF;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAEzD"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
function h(t) {
|
|
2
|
+
if (!t) return null;
|
|
3
|
+
const n = t.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4
|
+
if (!n) return null;
|
|
5
|
+
const [, a, o, l] = n, e = new Date(Number(a), Number(o) - 1, Number(l));
|
|
6
|
+
return isNaN(e.getTime()) ? null : e;
|
|
7
|
+
}
|
|
8
|
+
function u(t) {
|
|
9
|
+
const n = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), o = String(t.getDate()).padStart(2, "0");
|
|
10
|
+
return `${n}-${a}-${o}`;
|
|
11
|
+
}
|
|
12
|
+
function S(t, n) {
|
|
13
|
+
return t.getFullYear() === n.getFullYear() && t.getMonth() === n.getMonth() && t.getDate() === n.getDate();
|
|
14
|
+
}
|
|
15
|
+
function Y(t, n) {
|
|
16
|
+
return s(t).getTime() < s(n).getTime();
|
|
17
|
+
}
|
|
18
|
+
function T(t, n) {
|
|
19
|
+
return s(t).getTime() > s(n).getTime();
|
|
20
|
+
}
|
|
21
|
+
function b(t, n, a) {
|
|
22
|
+
const o = s(t).getTime(), l = s(n).getTime(), e = s(a).getTime(), r = Math.min(l, e), c = Math.max(l, e);
|
|
23
|
+
return o >= r && o <= c;
|
|
24
|
+
}
|
|
25
|
+
function s(t) {
|
|
26
|
+
return new Date(t.getFullYear(), t.getMonth(), t.getDate());
|
|
27
|
+
}
|
|
28
|
+
function M(t, n) {
|
|
29
|
+
return new Date(t.getFullYear(), t.getMonth() + n, 1);
|
|
30
|
+
}
|
|
31
|
+
function N(t, n) {
|
|
32
|
+
return new Date(t.getFullYear() + n, t.getMonth(), 1);
|
|
33
|
+
}
|
|
34
|
+
function m(t) {
|
|
35
|
+
return new Date(t.getFullYear(), t.getMonth(), 1);
|
|
36
|
+
}
|
|
37
|
+
function w(t) {
|
|
38
|
+
return new Date(t.getFullYear(), t.getMonth() + 1, 0);
|
|
39
|
+
}
|
|
40
|
+
function V(t, n, a, o) {
|
|
41
|
+
const l = s(/* @__PURE__ */ new Date()), e = t.getFullYear(), r = t.getMonth();
|
|
42
|
+
let i = new Date(e, r, 1).getDay() - n;
|
|
43
|
+
i < 0 && (i += 7);
|
|
44
|
+
const D = new Date(e, r, 1 - i), f = [];
|
|
45
|
+
for (let d = 0; d < 42; d++) {
|
|
46
|
+
const g = new Date(D.getFullYear(), D.getMonth(), D.getDate() + d), F = g.getMonth() === r, p = a !== null && Y(g, a) || o !== null && T(g, o);
|
|
47
|
+
f.push({
|
|
48
|
+
date: g,
|
|
49
|
+
day: g.getDate(),
|
|
50
|
+
currentMonth: F,
|
|
51
|
+
today: S(g, l),
|
|
52
|
+
disabled: p
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return f;
|
|
56
|
+
}
|
|
57
|
+
function L(t, n) {
|
|
58
|
+
const a = new Date(2024, 0, n === 0 ? 7 : 1), o = [];
|
|
59
|
+
for (let l = 0; l < 7; l++) {
|
|
60
|
+
const e = new Date(a.getFullYear(), a.getMonth(), a.getDate() + l);
|
|
61
|
+
o.push(e.toLocaleDateString(t, { weekday: "short" }).slice(0, 2));
|
|
62
|
+
}
|
|
63
|
+
return o;
|
|
64
|
+
}
|
|
65
|
+
function y(t, n) {
|
|
66
|
+
return new Date(2024, n, 1).toLocaleDateString(t, { month: "long" });
|
|
67
|
+
}
|
|
68
|
+
function O(t) {
|
|
69
|
+
const n = t - 7, a = [];
|
|
70
|
+
for (let o = 0; o < 15; o++)
|
|
71
|
+
a.push(n + o);
|
|
72
|
+
return a;
|
|
73
|
+
}
|
|
74
|
+
function $(t) {
|
|
75
|
+
const n = s(/* @__PURE__ */ new Date()), a = y(t, n.getMonth()), o = M(n, -1), l = y(t, o.getMonth());
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
label: "Today",
|
|
79
|
+
getValue: () => {
|
|
80
|
+
const e = s(/* @__PURE__ */ new Date()), r = u(e);
|
|
81
|
+
return { start: r, end: r };
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: "Last 7 days",
|
|
86
|
+
getValue: () => {
|
|
87
|
+
const e = s(/* @__PURE__ */ new Date()), r = new Date(e.getFullYear(), e.getMonth(), e.getDate() - 6);
|
|
88
|
+
return { start: u(r), end: u(e) };
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: "Last 30 days",
|
|
93
|
+
getValue: () => {
|
|
94
|
+
const e = s(/* @__PURE__ */ new Date()), r = new Date(e.getFullYear(), e.getMonth(), e.getDate() - 29);
|
|
95
|
+
return { start: u(r), end: u(e) };
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
label: "Last 60 days",
|
|
100
|
+
getValue: () => {
|
|
101
|
+
const e = s(/* @__PURE__ */ new Date()), r = new Date(e.getFullYear(), e.getMonth(), e.getDate() - 59);
|
|
102
|
+
return { start: u(r), end: u(e) };
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: "Last 90 days",
|
|
107
|
+
getValue: () => {
|
|
108
|
+
const e = s(/* @__PURE__ */ new Date()), r = new Date(e.getFullYear(), e.getMonth(), e.getDate() - 89);
|
|
109
|
+
return { start: u(r), end: u(e) };
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: a,
|
|
114
|
+
getValue: () => {
|
|
115
|
+
const e = s(/* @__PURE__ */ new Date()), r = m(e), c = w(e);
|
|
116
|
+
return { start: u(r), end: u(c) };
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: l,
|
|
121
|
+
getValue: () => {
|
|
122
|
+
const e = s(/* @__PURE__ */ new Date()), r = M(e, -1), c = m(r), i = w(r);
|
|
123
|
+
return { start: u(c), end: u(i) };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
function k(t) {
|
|
129
|
+
if (!t.includes("/"))
|
|
130
|
+
return { start: h(t), end: null };
|
|
131
|
+
const [n, a] = t.split("/");
|
|
132
|
+
return { start: h(n), end: h(a) };
|
|
133
|
+
}
|
|
134
|
+
function x(t, n) {
|
|
135
|
+
return Y(t, n) ? [t, n] : [n, t];
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
M as addMonths,
|
|
139
|
+
N as addYears,
|
|
140
|
+
w as endOfMonth,
|
|
141
|
+
u as formatISO,
|
|
142
|
+
V as getCalendarGrid,
|
|
143
|
+
$ as getDefaultPresets,
|
|
144
|
+
y as getMonthName,
|
|
145
|
+
L as getWeekdayNames,
|
|
146
|
+
O as getYearsGrid,
|
|
147
|
+
T as isAfter,
|
|
148
|
+
Y as isBefore,
|
|
149
|
+
b as isBetween,
|
|
150
|
+
S as isSameDay,
|
|
151
|
+
x as orderDates,
|
|
152
|
+
h as parseISO,
|
|
153
|
+
k as parseRangeValue,
|
|
154
|
+
m as startOfMonth,
|
|
155
|
+
s as stripTime
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=datepicker-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datepicker-utils.js","sources":["../../../src/components/datepicker/datepicker-utils.ts"],"sourcesContent":["export interface CalendarDay {\n date: Date\n day: number\n currentMonth: boolean\n today: boolean\n disabled: boolean\n}\n\nexport interface DatepickerPreset {\n label: string\n getValue: () => { start: string; end: string }\n}\n\nexport function parseISO(value: string): Date | null {\n if (!value) return null\n const match = value.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/)\n if (!match) return null\n const [, y, m, d] = match\n const date = new Date(Number(y), Number(m) - 1, Number(d))\n if (isNaN(date.getTime())) return null\n return date\n}\n\nexport function formatISO(date: Date): string {\n const y = date.getFullYear()\n const m = String(date.getMonth() + 1).padStart(2, '0')\n const d = String(date.getDate()).padStart(2, '0')\n return `${y}-${m}-${d}`\n}\n\nexport function isSameDay(a: Date, b: Date): boolean {\n return (\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n )\n}\n\nexport function isBefore(a: Date, b: Date): boolean {\n return stripTime(a).getTime() < stripTime(b).getTime()\n}\n\nexport function isAfter(a: Date, b: Date): boolean {\n return stripTime(a).getTime() > stripTime(b).getTime()\n}\n\nexport function isBetween(date: Date, start: Date, end: Date): boolean {\n const t = stripTime(date).getTime()\n const s = stripTime(start).getTime()\n const e = stripTime(end).getTime()\n const min = Math.min(s, e)\n const max = Math.max(s, e)\n return t >= min && t <= max\n}\n\nexport function stripTime(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\nexport function addMonths(date: Date, months: number): Date {\n const result = new Date(date.getFullYear(), date.getMonth() + months, 1)\n return result\n}\n\nexport function addYears(date: Date, years: number): Date {\n return new Date(date.getFullYear() + years, date.getMonth(), 1)\n}\n\nexport function startOfMonth(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), 1)\n}\n\nexport function endOfMonth(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0)\n}\n\nexport function getCalendarGrid(\n viewDate: Date,\n weekStart: 0 | 1,\n minDate: Date | null,\n maxDate: Date | null,\n): CalendarDay[] {\n const today = stripTime(new Date())\n const year = viewDate.getFullYear()\n const month = viewDate.getMonth()\n\n const firstDay = new Date(year, month, 1)\n let dayOfWeek = firstDay.getDay() - weekStart\n if (dayOfWeek < 0) dayOfWeek += 7\n\n const gridStart = new Date(year, month, 1 - dayOfWeek)\n const days: CalendarDay[] = []\n\n for (let i = 0; i < 42; i++) {\n const date = new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i)\n const isCurrentMonth = date.getMonth() === month\n const isDisabled =\n (minDate !== null && isBefore(date, minDate)) ||\n (maxDate !== null && isAfter(date, maxDate))\n\n days.push({\n date,\n day: date.getDate(),\n currentMonth: isCurrentMonth,\n today: isSameDay(date, today),\n disabled: isDisabled,\n })\n }\n\n return days\n}\n\nexport function getWeekdayNames(locale: string, weekStart: 0 | 1): string[] {\n const base = new Date(2024, 0, weekStart === 0 ? 7 : 1) // Sun Jan 7 or Mon Jan 1\n const names: string[] = []\n for (let i = 0; i < 7; i++) {\n const d = new Date(base.getFullYear(), base.getMonth(), base.getDate() + i)\n names.push(d.toLocaleDateString(locale, { weekday: 'short' }).slice(0, 2))\n }\n return names\n}\n\nexport function getMonthNames(locale: string): string[] {\n const names: string[] = []\n for (let i = 0; i < 12; i++) {\n names.push(new Date(2024, i, 1).toLocaleDateString(locale, { month: 'long' }))\n }\n return names\n}\n\nexport function getMonthName(locale: string, month: number): string {\n return new Date(2024, month, 1).toLocaleDateString(locale, { month: 'long' })\n}\n\nexport function getYearsGrid(centerYear: number): number[] {\n const start = centerYear - 7\n const years: number[] = []\n for (let i = 0; i < 15; i++) {\n years.push(start + i)\n }\n return years\n}\n\nexport function getDefaultPresets(locale: string): DatepickerPreset[] {\n const today = stripTime(new Date())\n const currentMonthName = getMonthName(locale, today.getMonth())\n const prevMonthDate = addMonths(today, -1)\n const prevMonthName = getMonthName(locale, prevMonthDate.getMonth())\n\n return [\n {\n label: 'Today',\n getValue: () => {\n const t = stripTime(new Date())\n const iso = formatISO(t)\n return { start: iso, end: iso }\n },\n },\n {\n label: 'Last 7 days',\n getValue: () => {\n const t = stripTime(new Date())\n const start = new Date(t.getFullYear(), t.getMonth(), t.getDate() - 6)\n return { start: formatISO(start), end: formatISO(t) }\n },\n },\n {\n label: 'Last 30 days',\n getValue: () => {\n const t = stripTime(new Date())\n const start = new Date(t.getFullYear(), t.getMonth(), t.getDate() - 29)\n return { start: formatISO(start), end: formatISO(t) }\n },\n },\n {\n label: 'Last 60 days',\n getValue: () => {\n const t = stripTime(new Date())\n const start = new Date(t.getFullYear(), t.getMonth(), t.getDate() - 59)\n return { start: formatISO(start), end: formatISO(t) }\n },\n },\n {\n label: 'Last 90 days',\n getValue: () => {\n const t = stripTime(new Date())\n const start = new Date(t.getFullYear(), t.getMonth(), t.getDate() - 89)\n return { start: formatISO(start), end: formatISO(t) }\n },\n },\n {\n label: currentMonthName,\n getValue: () => {\n const t = stripTime(new Date())\n const s = startOfMonth(t)\n const e = endOfMonth(t)\n return { start: formatISO(s), end: formatISO(e) }\n },\n },\n {\n label: prevMonthName,\n getValue: () => {\n const t = stripTime(new Date())\n const pm = addMonths(t, -1)\n const s = startOfMonth(pm)\n const e = endOfMonth(pm)\n return { start: formatISO(s), end: formatISO(e) }\n },\n },\n ]\n}\n\nexport function parseRangeValue(value: string): { start: Date | null; end: Date | null } {\n if (!value.includes('/')) {\n return { start: parseISO(value), end: null }\n }\n const [startStr, endStr] = value.split('/')\n return { start: parseISO(startStr), end: parseISO(endStr) }\n}\n\nexport function orderDates(a: Date, b: Date): [Date, Date] {\n return isBefore(a, b) ? [a, b] : [b, a]\n}\n"],"names":["parseISO","value","match","y","m","d","date","formatISO","isSameDay","a","b","isBefore","stripTime","isAfter","isBetween","start","end","t","s","min","max","addMonths","months","addYears","years","startOfMonth","endOfMonth","getCalendarGrid","viewDate","weekStart","minDate","maxDate","today","year","month","dayOfWeek","gridStart","days","i","isCurrentMonth","isDisabled","getWeekdayNames","locale","base","names","getMonthName","getYearsGrid","centerYear","getDefaultPresets","currentMonthName","prevMonthDate","prevMonthName","iso","e","pm","parseRangeValue","startStr","endStr","orderDates"],"mappings":"AAaO,SAASA,EAASC,GAA4B;AACnD,MAAI,CAACA,EAAO,QAAO;AACnB,QAAMC,IAAQD,EAAM,MAAM,2BAA2B;AACrD,MAAI,CAACC,EAAO,QAAO;AACnB,QAAM,GAAGC,GAAGC,GAAGC,CAAC,IAAIH,GACdI,IAAO,IAAI,KAAK,OAAOH,CAAC,GAAG,OAAOC,CAAC,IAAI,GAAG,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,CAAE,GACnBD,IAAI3B,EAAW4B,CAAE;AACvB,eAAO,EAAE,OAAO/C,EAAUW,CAAC,GAAG,KAAKX,EAAU8C,CAAC,EAAA;AAAA,MAChD;AAAA,IAAA;AAAA,EACF;AAEJ;AAEO,SAASE,EAAgBtD,GAAyD;AACvF,MAAI,CAACA,EAAM,SAAS,GAAG;AACrB,WAAO,EAAE,OAAOD,EAASC,CAAK,GAAG,KAAK,KAAA;AAExC,QAAM,CAACuD,GAAUC,CAAM,IAAIxD,EAAM,MAAM,GAAG;AAC1C,SAAO,EAAE,OAAOD,EAASwD,CAAQ,GAAG,KAAKxD,EAASyD,CAAM,EAAA;AAC1D;AAEO,SAASC,EAAWjD,GAASC,GAAuB;AACzD,SAAOC,EAASF,GAAGC,CAAC,IAAI,CAACD,GAAGC,CAAC,IAAI,CAACA,GAAGD,CAAC;AACxC;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { type DatepickerPreset } from './datepicker-utils.js';
|
|
3
|
+
export type DatepickerMode = 'single' | 'range';
|
|
4
|
+
export declare class MellowDatepicker extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
mode: DatepickerMode;
|
|
7
|
+
value: string;
|
|
8
|
+
minDate: string;
|
|
9
|
+
maxDate: string;
|
|
10
|
+
presets: boolean;
|
|
11
|
+
presetItems: DatepickerPreset[];
|
|
12
|
+
weekStart: 0 | 1;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
locale: string;
|
|
15
|
+
private _view;
|
|
16
|
+
private _viewDate;
|
|
17
|
+
private _hoveredDate;
|
|
18
|
+
private _rangeStart;
|
|
19
|
+
private _pendingValue;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
22
|
+
private _syncFromValue;
|
|
23
|
+
private get _minDateParsed();
|
|
24
|
+
private get _maxDateParsed();
|
|
25
|
+
private get _effectivePresets();
|
|
26
|
+
private _prevMonth;
|
|
27
|
+
private _nextMonth;
|
|
28
|
+
private _prevYear;
|
|
29
|
+
private _nextYear;
|
|
30
|
+
private _prevYearRange;
|
|
31
|
+
private _nextYearRange;
|
|
32
|
+
private _showMonths;
|
|
33
|
+
private _showYears;
|
|
34
|
+
private _selectDay;
|
|
35
|
+
private _selectMonth;
|
|
36
|
+
private _selectYear;
|
|
37
|
+
private _handleDayHover;
|
|
38
|
+
private _handleDayMouseLeave;
|
|
39
|
+
private _goToToday;
|
|
40
|
+
private _selectPreset;
|
|
41
|
+
private _save;
|
|
42
|
+
private _fireSelect;
|
|
43
|
+
private _isDaySelected;
|
|
44
|
+
private _isDayInRange;
|
|
45
|
+
private _isRangeStart;
|
|
46
|
+
private _isRangeEnd;
|
|
47
|
+
private _isPresetActive;
|
|
48
|
+
private _handleKeydown;
|
|
49
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
50
|
+
private _renderPresets;
|
|
51
|
+
private _renderHeader;
|
|
52
|
+
private _renderDays;
|
|
53
|
+
private _renderMonths;
|
|
54
|
+
private _renderYears;
|
|
55
|
+
private _renderFooter;
|
|
56
|
+
}
|
|
57
|
+
declare global {
|
|
58
|
+
interface HTMLElementTagNameMap {
|
|
59
|
+
'mellow-datepicker': MellowDatepicker;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=datepicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datepicker.d.ts","sourceRoot":"","sources":["../../../src/components/datepicker/datepicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAA;AAI/C,OAAO,EAEL,KAAK,gBAAgB,EAetB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,CAAA;AAM/C,qBACa,gBAAiB,SAAQ,UAAU;IAC9C,OAAgB,MAAM,4BAAqB;IAG3C,IAAI,EAAE,cAAc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