@visitwonders/assembly 0.18.0 → 0.19.1
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,4 +1,5 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
+
import type Owner from '@ember/owner';
|
|
2
3
|
export type CalendarMode = 'single' | 'range' | 'multiple';
|
|
3
4
|
export interface DateRange {
|
|
4
5
|
start: Date;
|
|
@@ -42,15 +43,29 @@ export default class Calendar extends Component<CalendarSignature> {
|
|
|
42
43
|
/**
|
|
43
44
|
* The month the calendar is currently showing. This is the calendar's own
|
|
44
45
|
* navigation mechanics, not the consumer's domain state: the user pages
|
|
45
|
-
* through months to find a date. It seeds to the
|
|
46
|
-
* and next buttons (and keyboard month paging) drive it. When
|
|
47
|
-
* passes `@month`, that override wins and this field is
|
|
46
|
+
* through months to find a date. It seeds to the month holding the selection
|
|
47
|
+
* and the prev and next buttons (and keyboard month paging) drive it. When
|
|
48
|
+
* the consumer passes `@month`, that override wins and this field is
|
|
49
|
+
* bypassed.
|
|
48
50
|
*/
|
|
49
51
|
private _navigationMonth;
|
|
50
52
|
private focusedDate;
|
|
51
53
|
private rangeSelectionStart;
|
|
52
54
|
private hoveredDate;
|
|
53
55
|
private elementRef;
|
|
56
|
+
constructor(owner: Owner, args: CalendarSignature['Args']);
|
|
57
|
+
/**
|
|
58
|
+
* Where the visible month starts: the month holding the selection, or the
|
|
59
|
+
* current month when there is nothing selected. Read once, when the calendar
|
|
60
|
+
* is constructed, so that browsing sticks for as long as the calendar is
|
|
61
|
+
* rendered and a `@value` that changes underneath the user does not move the
|
|
62
|
+
* month out from under them. The pickers render the calendar only while their
|
|
63
|
+
* popover is open, so each open re-seeds. See
|
|
64
|
+
* `docs/decisions/0006-picker-visible-month.md`.
|
|
65
|
+
*/
|
|
66
|
+
private seedMonth;
|
|
67
|
+
/** The selected date the seed reads, per the mode the calendar is in. */
|
|
68
|
+
private get selectionAnchor();
|
|
54
69
|
get componentId(): string;
|
|
55
70
|
get mode(): CalendarMode;
|
|
56
71
|
get weekStartsOn(): WeekStartDay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/form/calendar.gts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/form/calendar.gts"],"names":[],"mappings":"AA2yBA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AA8BtC,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAE3D,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,KAAK,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAM9C,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE;QAEJ,IAAI,CAAC,EAAE,YAAY,CAAC;QAKpB,KAAK,CAAC,EAAE,IAAI,CAAC;QACb,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;QAGvC,UAAU,CAAC,EAAE,SAAS,CAAC;QACvB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,SAA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AI,CAoD1C;IAEF,WAAW,QAAO,IAAI,CAmBpB;IAEF,UAAU,QAAO,IAAI,CAEnB;IAEF,cAAc,SAAU,IAAI,KAAG,IAAI,CAKjC;IAEF,mBAAmB,SAAU,IAAI,KAAG,IAAI,CAQtC;IAEF,oBAAoB,UAAW,KAAK,KAAG,IAAI,CAKzC;IAEF,oBAAoB,UAAW,KAAK,KAAG,IAAI,CAKzC;IAMF,QAAQ;;;;;;OAML;IAMH,YAAY,SAAU,IAAI,KAAG,MAAM,CAEjC;IAEF,aAAa,SAAU,IAAI,KAAG,OAAO,CAGnC;CA8RH"}
|
package/dist/data/table.css
CHANGED
|
@@ -130,6 +130,18 @@
|
|
|
130
130
|
outline-offset: -2px;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/* The button is a flex row, so text-align can't move its label. A column's
|
|
134
|
+
alignment has to drive the button's main-axis distribution: the chevron
|
|
135
|
+
follows the label to the aligned edge. Left/unset keeps space-between, so
|
|
136
|
+
the chevron stays pinned to the trailing edge. */
|
|
137
|
+
.header-cell_e4aed93fe[data-align="center"] .sort-button_e4aed93fe {
|
|
138
|
+
justify-content: center;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.header-cell_e4aed93fe[data-align="right"] .sort-button_e4aed93fe {
|
|
142
|
+
justify-content: flex-end;
|
|
143
|
+
}
|
|
144
|
+
|
|
133
145
|
.header-text_e4aed93fe {
|
|
134
146
|
display: inline;
|
|
135
147
|
}
|
package/dist/form/calendar.js
CHANGED
|
@@ -6,7 +6,7 @@ import { on } from '@ember/modifier';
|
|
|
6
6
|
import { fn } from '@ember/helper';
|
|
7
7
|
import { not } from 'ember-truth-helpers';
|
|
8
8
|
import { modifier } from 'ember-modifier';
|
|
9
|
-
import { format, endOfMonth, addMonths, isBefore,
|
|
9
|
+
import { startOfMonth, min, format, endOfMonth, addMonths, isBefore, isAfter, startOfWeek, endOfWeek, eachDayOfInterval, getDay, isSameDay, isSameMonth, isToday, addWeeks, addDays } from 'date-fns';
|
|
10
10
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
11
11
|
import { setComponentTemplate } from '@ember/component';
|
|
12
12
|
import { g, i } from 'decorator-transforms/runtime';
|
|
@@ -18,17 +18,16 @@ import { g, i } from 'decorator-transforms/runtime';
|
|
|
18
18
|
// ============================================================================
|
|
19
19
|
class Calendar extends Component {
|
|
20
20
|
static {
|
|
21
|
-
g(this.prototype, "_navigationMonth", [tracked]
|
|
22
|
-
return new Date();
|
|
23
|
-
});
|
|
21
|
+
g(this.prototype, "_navigationMonth", [tracked]);
|
|
24
22
|
}
|
|
25
23
|
#_navigationMonth = (i(this, "_navigationMonth"), void 0);
|
|
26
24
|
/**
|
|
27
25
|
* The month the calendar is currently showing. This is the calendar's own
|
|
28
26
|
* navigation mechanics, not the consumer's domain state: the user pages
|
|
29
|
-
* through months to find a date. It seeds to the
|
|
30
|
-
* and next buttons (and keyboard month paging) drive it. When
|
|
31
|
-
* passes `@month`, that override wins and this field is
|
|
27
|
+
* through months to find a date. It seeds to the month holding the selection
|
|
28
|
+
* and the prev and next buttons (and keyboard month paging) drive it. When
|
|
29
|
+
* the consumer passes `@month`, that override wins and this field is
|
|
30
|
+
* bypassed.
|
|
32
31
|
*/
|
|
33
32
|
static {
|
|
34
33
|
g(this.prototype, "focusedDate", [tracked], function () {
|
|
@@ -51,6 +50,33 @@ class Calendar extends Component {
|
|
|
51
50
|
}
|
|
52
51
|
#hoveredDate = (i(this, "hoveredDate"), void 0);
|
|
53
52
|
elementRef = null;
|
|
53
|
+
constructor(owner, args) {
|
|
54
|
+
super(owner, args);
|
|
55
|
+
this._navigationMonth = this.seedMonth();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Where the visible month starts: the month holding the selection, or the
|
|
59
|
+
* current month when there is nothing selected. Read once, when the calendar
|
|
60
|
+
* is constructed, so that browsing sticks for as long as the calendar is
|
|
61
|
+
* rendered and a `@value` that changes underneath the user does not move the
|
|
62
|
+
* month out from under them. The pickers render the calendar only while their
|
|
63
|
+
* popover is open, so each open re-seeds. See
|
|
64
|
+
* `docs/decisions/0006-picker-visible-month.md`.
|
|
65
|
+
*/
|
|
66
|
+
seedMonth() {
|
|
67
|
+
return startOfMonth(this.selectionAnchor ?? new Date());
|
|
68
|
+
}
|
|
69
|
+
/** The selected date the seed reads, per the mode the calendar is in. */
|
|
70
|
+
get selectionAnchor() {
|
|
71
|
+
if (this.mode === 'range') {
|
|
72
|
+
return this.args.rangeValue?.start ?? null;
|
|
73
|
+
}
|
|
74
|
+
if (this.mode === 'multiple') {
|
|
75
|
+
const dates = this.args.multiValue;
|
|
76
|
+
return dates && dates.length > 0 ? min(dates) : null;
|
|
77
|
+
}
|
|
78
|
+
return this.args.value ?? null;
|
|
79
|
+
}
|
|
54
80
|
// ============================================================================
|
|
55
81
|
// Computed Properties
|
|
56
82
|
// ============================================================================
|
|
@@ -254,6 +280,12 @@ class Calendar extends Component {
|
|
|
254
280
|
// ============================================================================
|
|
255
281
|
selectDate = date => {
|
|
256
282
|
if (this.isDateDisabled(date)) return;
|
|
283
|
+
// A selection that lands outside the visible month brings the month to it,
|
|
284
|
+
// so clicking an adjacent-month day and pressing Enter on the same day
|
|
285
|
+
// agree. Keyboard focus already moves the month this way.
|
|
286
|
+
if (!isSameMonth(date, this.currentMonth)) {
|
|
287
|
+
this.currentMonth = startOfMonth(date);
|
|
288
|
+
}
|
|
257
289
|
if (this.mode === 'single') {
|
|
258
290
|
this.args.onChange?.(date);
|
|
259
291
|
} else if (this.mode === 'multiple') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visitwonders/assembly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "The default blueprint for Embroider v2 addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -77,6 +77,21 @@
|
|
|
77
77
|
"declarations",
|
|
78
78
|
"dist"
|
|
79
79
|
],
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "rollup --config",
|
|
82
|
+
"format": "prettier . --cache --write",
|
|
83
|
+
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
|
|
84
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
|
|
85
|
+
"lint:format": "prettier . --cache --check",
|
|
86
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
87
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
88
|
+
"lint:js": "eslint . --cache",
|
|
89
|
+
"lint:js:fix": "eslint . --fix",
|
|
90
|
+
"lint:types": "ember-tsc",
|
|
91
|
+
"prepack": "rm -rf declarations dist && rollup --config",
|
|
92
|
+
"start": "rollup --config --watch",
|
|
93
|
+
"test": "echo 'A v2 addon does not have tests, run tests in showcase'"
|
|
94
|
+
},
|
|
80
95
|
"dependencies": {
|
|
81
96
|
"@arthur5005/dnd-kit-ember": "^0.1.2",
|
|
82
97
|
"@embroider/addon-shim": "^1.8.9",
|
|
@@ -213,19 +228,5 @@
|
|
|
213
228
|
"./typography/heading.js": "./dist/_app_/typography/heading.js",
|
|
214
229
|
"./typography/text.js": "./dist/_app_/typography/text.js"
|
|
215
230
|
}
|
|
216
|
-
},
|
|
217
|
-
"scripts": {
|
|
218
|
-
"build": "rollup --config",
|
|
219
|
-
"format": "prettier . --cache --write",
|
|
220
|
-
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
|
|
221
|
-
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
|
|
222
|
-
"lint:format": "prettier . --cache --check",
|
|
223
|
-
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
224
|
-
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
225
|
-
"lint:js": "eslint . --cache",
|
|
226
|
-
"lint:js:fix": "eslint . --fix",
|
|
227
|
-
"lint:types": "ember-tsc",
|
|
228
|
-
"start": "rollup --config --watch",
|
|
229
|
-
"test": "echo 'A v2 addon does not have tests, run tests in showcase'"
|
|
230
231
|
}
|
|
231
|
-
}
|
|
232
|
+
}
|