@arclux/arc-ui 1.0.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/LICENSE +21 -0
- package/README.md +64 -0
- package/package.json +186 -0
- package/src/content/accordion-item.js +27 -0
- package/src/content/accordion.js +151 -0
- package/src/content/animated-number.js +160 -0
- package/src/content/aspect-ratio.js +78 -0
- package/src/content/avatar-group.js +101 -0
- package/src/content/avatar.js +92 -0
- package/src/content/badge.js +98 -0
- package/src/content/callout.js +141 -0
- package/src/content/card.js +75 -0
- package/src/content/carousel.js +300 -0
- package/src/content/code-block.js +152 -0
- package/src/content/collapsible.js +142 -0
- package/src/content/color-swatch.js +86 -0
- package/src/content/column.js +28 -0
- package/src/content/data-table.js +332 -0
- package/src/content/divider.js +153 -0
- package/src/content/empty-state.js +78 -0
- package/src/content/feature-card.js +142 -0
- package/src/content/highlight.js +63 -0
- package/src/content/icon-library.js +30 -0
- package/src/content/icon-registry.js +39 -0
- package/src/content/icon.js +95 -0
- package/src/content/index.js +44 -0
- package/src/content/infinite-scroll.js +144 -0
- package/src/content/kbd.js +40 -0
- package/src/content/markdown.js +294 -0
- package/src/content/marquee.js +166 -0
- package/src/content/meter.js +167 -0
- package/src/content/scroll-area.js +107 -0
- package/src/content/skeleton.js +85 -0
- package/src/content/spinner.js +77 -0
- package/src/content/stack.js +68 -0
- package/src/content/stat.js +72 -0
- package/src/content/step.js +22 -0
- package/src/content/stepper.js +202 -0
- package/src/content/table.js +134 -0
- package/src/content/tag.js +156 -0
- package/src/content/text.js +111 -0
- package/src/content/timeline-item.js +29 -0
- package/src/content/timeline.js +170 -0
- package/src/content/truncate.js +161 -0
- package/src/content/value-card.js +94 -0
- package/src/feedback/alert.js +187 -0
- package/src/feedback/command-item.js +28 -0
- package/src/feedback/command-palette.js +346 -0
- package/src/feedback/context-menu.js +299 -0
- package/src/feedback/dialog.js +298 -0
- package/src/feedback/dropdown-menu.js +259 -0
- package/src/feedback/hover-card.js +186 -0
- package/src/feedback/index.js +17 -0
- package/src/feedback/modal.js +226 -0
- package/src/feedback/notification-panel.js +196 -0
- package/src/feedback/popover.js +184 -0
- package/src/feedback/progress.js +169 -0
- package/src/feedback/sheet.js +249 -0
- package/src/feedback/toast.js +207 -0
- package/src/feedback/tooltip.js +189 -0
- package/src/icons/lucide.d.ts +1915 -0
- package/src/icons/lucide.js +1915 -0
- package/src/icons/phosphor.d.ts +1517 -0
- package/src/icons/phosphor.js +1517 -0
- package/src/icons/types.d.ts +8 -0
- package/src/index.js +9 -0
- package/src/input/button.js +127 -0
- package/src/input/calendar.js +340 -0
- package/src/input/checkbox.js +159 -0
- package/src/input/chip.js +120 -0
- package/src/input/color-picker.js +461 -0
- package/src/input/combobox.js +295 -0
- package/src/input/copy-button.js +144 -0
- package/src/input/date-picker.js +534 -0
- package/src/input/file-upload.js +333 -0
- package/src/input/form.js +179 -0
- package/src/input/icon-button.js +179 -0
- package/src/input/index.js +31 -0
- package/src/input/input.js +158 -0
- package/src/input/multi-select.js +392 -0
- package/src/input/number-input.js +239 -0
- package/src/input/otp-input.js +221 -0
- package/src/input/pin-input.js +294 -0
- package/src/input/radio-group.js +177 -0
- package/src/input/radio.js +28 -0
- package/src/input/rating.js +195 -0
- package/src/input/search.js +371 -0
- package/src/input/segmented-control.js +174 -0
- package/src/input/select.js +267 -0
- package/src/input/slider.js +217 -0
- package/src/input/sortable-list.js +345 -0
- package/src/input/suggestion.js +26 -0
- package/src/input/textarea.js +203 -0
- package/src/input/theme-toggle.js +196 -0
- package/src/input/toggle.js +166 -0
- package/src/layout/app-shell.js +266 -0
- package/src/layout/auth-shell.js +153 -0
- package/src/layout/container.js +37 -0
- package/src/layout/dashboard-grid.js +62 -0
- package/src/layout/index.js +15 -0
- package/src/layout/page-header.js +100 -0
- package/src/layout/page-layout.js +112 -0
- package/src/layout/resizable.js +221 -0
- package/src/layout/section.js +54 -0
- package/src/layout/settings-layout.js +91 -0
- package/src/layout/split-pane.js +172 -0
- package/src/layout/status-bar.js +84 -0
- package/src/layout/toolbar.js +92 -0
- package/src/navigation/breadcrumb-item.js +26 -0
- package/src/navigation/breadcrumb.js +129 -0
- package/src/navigation/drawer.js +183 -0
- package/src/navigation/footer.js +99 -0
- package/src/navigation/index.js +22 -0
- package/src/navigation/link.js +120 -0
- package/src/navigation/nav-item.js +46 -0
- package/src/navigation/navigation-menu.js +687 -0
- package/src/navigation/pagination.js +186 -0
- package/src/navigation/scroll-spy.js +198 -0
- package/src/navigation/scroll-to-top.js +163 -0
- package/src/navigation/sidebar-link.js +28 -0
- package/src/navigation/sidebar-section.js +45 -0
- package/src/navigation/sidebar.js +336 -0
- package/src/navigation/spy-link.js +26 -0
- package/src/navigation/tab.js +26 -0
- package/src/navigation/tabs.js +202 -0
- package/src/navigation/top-bar.js +263 -0
- package/src/navigation/tree-item.js +38 -0
- package/src/navigation/tree-view.js +255 -0
- package/src/shared/index.js +6 -0
- package/src/shared/menu-divider.js +9 -0
- package/src/shared/menu-item.js +30 -0
- package/src/shared/option.js +31 -0
- package/src/shared-styles.js +81 -0
- package/src/tokens.js +445 -0
- package/types/index.d.ts +973 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Auto-generated — do not edit manually.
|
|
2
|
+
export type { PhosphorIconName } from './phosphor.js';
|
|
3
|
+
export type { LucideIconName } from './lucide.js';
|
|
4
|
+
|
|
5
|
+
import type { PhosphorIconName } from './phosphor.js';
|
|
6
|
+
import type { LucideIconName } from './lucide.js';
|
|
7
|
+
|
|
8
|
+
export type IconName = PhosphorIconName | LucideIconName;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// ARC UI — Web Components
|
|
2
|
+
// Re-exports from all tiers
|
|
3
|
+
|
|
4
|
+
export { ArcAccordion, ArcAccordionItem, ArcAnimatedNumber, ArcAspectRatio, ArcAvatar, ArcAvatarGroup, ArcBadge, ArcCallout, ArcCard, ArcCarousel, ArcCodeBlock, ArcCollapsible, ArcColorSwatch, ArcColumn, ArcDataTable, ArcDivider, ArcEmptyState, ArcFeatureCard, ArcHighlight, ArcIcon, ArcIconLibrary, iconRegistry, ArcInfiniteScroll, ArcKbd, ArcMarkdown, ArcMarquee, ArcMeter, ArcScrollArea, ArcSkeleton, ArcSpinner, ArcStack, ArcStat, ArcStep, ArcStepper, ArcTable, ArcTag, ArcText, ArcTimeline, ArcTimelineItem, ArcTruncate, ArcValueCard } from './content/index.js';
|
|
5
|
+
export { ArcButton, ArcCalendar, ArcCheckbox, ArcChip, ArcColorPicker, ArcCombobox, ArcCopyButton, ArcDatePicker, ArcFileUpload, ArcForm, ArcIconButton, ArcInput, ArcMultiSelect, ArcNumberInput, ArcOtpInput, ArcPinInput, ArcRadio, ArcRadioGroup, ArcRating, ArcSearch, ArcSegmentedControl, ArcSelect, ArcSlider, ArcSortableList, ArcSuggestion, ArcTextarea, ArcThemeToggle, ArcToggle } from './input/index.js';
|
|
6
|
+
export { ArcAlert, ArcCommandItem, ArcCommandPalette, ArcContextMenu, ArcDialog, ArcDropdownMenu, ArcHoverCard, ArcModal, ArcNotificationPanel, ArcPopover, ArcProgress, ArcSheet, ArcToast, ArcTooltip } from './feedback/index.js';
|
|
7
|
+
export { ArcBreadcrumb, ArcBreadcrumbItem, ArcDrawer, ArcFooter, ArcLink, ArcNavItem, ArcNavigationMenu, ArcPagination, ArcScrollSpy, ArcScrollToTop, ArcSidebar, ArcSidebarLink, ArcSidebarSection, ArcSpyLink, ArcTab, ArcTabs, ArcTopBar, ArcTreeItem, ArcTreeView } from './navigation/index.js';
|
|
8
|
+
export { ArcAppShell, ArcAuthShell, ArcContainer, ArcDashboardGrid, ArcPageHeader, ArcPageLayout, ArcResizable, ArcSection, ArcSettingsLayout, ArcSplitPane, ArcStatusBar, ArcToolbar } from './layout/index.js';
|
|
9
|
+
export { ArcOption, ArcMenuItem, ArcMenuDivider } from './shared/index.js';
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcButton extends LitElement {
|
|
5
|
+
static properties = {
|
|
6
|
+
variant: { type: String, reflect: true },
|
|
7
|
+
size: { type: String, reflect: true },
|
|
8
|
+
href: { type: String },
|
|
9
|
+
disabled: { type: Boolean, reflect: true },
|
|
10
|
+
type: { type: String },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
static styles = [
|
|
14
|
+
tokenStyles,
|
|
15
|
+
css`
|
|
16
|
+
:host { display: inline-flex; }
|
|
17
|
+
:host([disabled]) { pointer-events: none; }
|
|
18
|
+
|
|
19
|
+
.btn {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
gap: var(--space-sm);
|
|
24
|
+
font-family: var(--font-accent);
|
|
25
|
+
font-weight: 600;
|
|
26
|
+
text-transform: uppercase;
|
|
27
|
+
letter-spacing: 2px;
|
|
28
|
+
border: 1px solid transparent;
|
|
29
|
+
border-radius: var(--radius-md);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
transition:
|
|
32
|
+
background var(--transition-base),
|
|
33
|
+
border-color var(--transition-base),
|
|
34
|
+
box-shadow var(--transition-base),
|
|
35
|
+
color var(--transition-base),
|
|
36
|
+
transform var(--transition-fast);
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
min-height: var(--touch-min);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Sizes */
|
|
44
|
+
:host([size="sm"]) .btn { font-size: var(--text-xs); padding: var(--space-xs) var(--space-md); }
|
|
45
|
+
:host(:not([size])) .btn,
|
|
46
|
+
:host([size="md"]) .btn { font-size: var(--text-xs); padding: var(--space-sm) var(--space-lg); }
|
|
47
|
+
:host([size="lg"]) .btn { font-size: var(--text-xs); padding: var(--space-md) var(--space-xl); letter-spacing: 3px; }
|
|
48
|
+
|
|
49
|
+
/* Primary */
|
|
50
|
+
:host(:not([variant])) .btn,
|
|
51
|
+
:host([variant="primary"]) .btn {
|
|
52
|
+
background: var(--accent-primary);
|
|
53
|
+
color: var(--bg-deep);
|
|
54
|
+
border-color: var(--accent-primary);
|
|
55
|
+
}
|
|
56
|
+
:host(:not([variant])) .btn:hover,
|
|
57
|
+
:host([variant="primary"]) .btn:hover { box-shadow: var(--glow-primary); }
|
|
58
|
+
:host(:not([variant])) .btn:active,
|
|
59
|
+
:host([variant="primary"]) .btn:active { transform: scale(0.97); box-shadow: 0 0 8px rgba(var(--accent-primary-rgb),0.5); }
|
|
60
|
+
|
|
61
|
+
/* Secondary */
|
|
62
|
+
:host([variant="secondary"]) .btn {
|
|
63
|
+
background: transparent;
|
|
64
|
+
color: var(--text-primary);
|
|
65
|
+
border-color: var(--border-default);
|
|
66
|
+
}
|
|
67
|
+
:host([variant="secondary"]) .btn:hover {
|
|
68
|
+
border-color: var(--accent-primary);
|
|
69
|
+
color: var(--accent-primary);
|
|
70
|
+
box-shadow: 0 0 20px var(--accent-primary-ring);
|
|
71
|
+
}
|
|
72
|
+
:host([variant="secondary"]) .btn:active {
|
|
73
|
+
transform: scale(0.97);
|
|
74
|
+
background: rgba(var(--accent-primary-rgb),0.05);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Ghost */
|
|
78
|
+
:host([variant="ghost"]) .btn {
|
|
79
|
+
background: transparent;
|
|
80
|
+
color: var(--text-muted);
|
|
81
|
+
border-color: transparent;
|
|
82
|
+
}
|
|
83
|
+
:host([variant="ghost"]) .btn:hover {
|
|
84
|
+
color: var(--text-primary);
|
|
85
|
+
background: var(--bg-hover);
|
|
86
|
+
}
|
|
87
|
+
:host([variant="ghost"]) .btn:active {
|
|
88
|
+
transform: scale(0.97);
|
|
89
|
+
background: var(--bg-elevated);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Focus */
|
|
93
|
+
.btn:focus-visible { outline: none; box-shadow: var(--focus-glow); }
|
|
94
|
+
|
|
95
|
+
/* Disabled */
|
|
96
|
+
:host([disabled]) .btn { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
|
|
97
|
+
|
|
98
|
+
@media (prefers-reduced-motion: reduce) {
|
|
99
|
+
:host *,
|
|
100
|
+
:host *::before,
|
|
101
|
+
:host *::after {
|
|
102
|
+
animation-duration: 0.01ms !important;
|
|
103
|
+
animation-iteration-count: 1 !important;
|
|
104
|
+
transition-duration: 0.01ms !important;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`,
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
constructor() {
|
|
111
|
+
super();
|
|
112
|
+
this.variant = 'primary';
|
|
113
|
+
this.size = 'md';
|
|
114
|
+
this.href = '';
|
|
115
|
+
this.disabled = false;
|
|
116
|
+
this.type = 'button';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
render() {
|
|
120
|
+
if (this.href) {
|
|
121
|
+
return html`<a class="btn" href=${this.href} part="button"><slot></slot></a>`;
|
|
122
|
+
}
|
|
123
|
+
return html`<button class="btn" type=${this.type} ?disabled=${this.disabled} part="button"><slot></slot></button>`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
customElements.define('arc-button', ArcButton);
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcCalendar extends LitElement {
|
|
5
|
+
static properties = {
|
|
6
|
+
value: { type: String },
|
|
7
|
+
min: { type: String },
|
|
8
|
+
max: { type: String },
|
|
9
|
+
month: { type: Number },
|
|
10
|
+
year: { type: Number },
|
|
11
|
+
_focusedDay: { state: true },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
static styles = [
|
|
15
|
+
tokenStyles,
|
|
16
|
+
css`
|
|
17
|
+
:host {
|
|
18
|
+
display: inline-block;
|
|
19
|
+
font-family: var(--font-body);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.calendar {
|
|
23
|
+
background: var(--bg-card);
|
|
24
|
+
border: 1px solid var(--border-default);
|
|
25
|
+
border-radius: var(--radius-lg);
|
|
26
|
+
padding: var(--space-md);
|
|
27
|
+
min-width: 280px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.calendar__header {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
margin-bottom: var(--space-md);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.calendar__title {
|
|
38
|
+
font-family: var(--font-body);
|
|
39
|
+
font-size: var(--text-sm);
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
color: var(--text-primary);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.calendar__nav {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
width: 28px;
|
|
49
|
+
height: 28px;
|
|
50
|
+
background: none;
|
|
51
|
+
border: 1px solid var(--border-default);
|
|
52
|
+
border-radius: var(--radius-sm);
|
|
53
|
+
color: var(--text-secondary);
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
transition: background var(--transition-fast), color var(--transition-fast);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.calendar__nav:hover {
|
|
59
|
+
background: var(--bg-elevated);
|
|
60
|
+
color: var(--text-primary);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.calendar__nav:focus-visible {
|
|
64
|
+
outline: none;
|
|
65
|
+
box-shadow: var(--focus-glow);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.calendar__grid {
|
|
69
|
+
display: grid;
|
|
70
|
+
grid-template-columns: repeat(7, 1fr);
|
|
71
|
+
gap: 2px;
|
|
72
|
+
text-align: center;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.calendar__dow {
|
|
76
|
+
font-family: var(--font-mono);
|
|
77
|
+
font-size: var(--text-xs);
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
color: var(--text-muted);
|
|
80
|
+
padding: var(--space-xs) 0;
|
|
81
|
+
text-transform: uppercase;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.calendar__day {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
width: 36px;
|
|
89
|
+
height: 36px;
|
|
90
|
+
margin: 0 auto;
|
|
91
|
+
font-family: var(--font-mono);
|
|
92
|
+
font-size: var(--text-sm);
|
|
93
|
+
color: var(--text-secondary);
|
|
94
|
+
background: none;
|
|
95
|
+
border: none;
|
|
96
|
+
border-radius: var(--radius-full);
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
transition: background var(--transition-fast), color var(--transition-fast);
|
|
99
|
+
position: relative;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.calendar__day:hover:not(:disabled) {
|
|
103
|
+
background: rgba(var(--accent-primary-rgb), 0.1);
|
|
104
|
+
color: var(--text-primary);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.calendar__day--today {
|
|
108
|
+
box-shadow: inset 0 0 0 1px var(--border-bright);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.calendar__day--selected {
|
|
112
|
+
background: var(--accent-primary) !important;
|
|
113
|
+
color: var(--text-primary) !important;
|
|
114
|
+
font-weight: 600;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.calendar__day--outside {
|
|
118
|
+
color: var(--text-muted);
|
|
119
|
+
opacity: 0.3;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.calendar__day:disabled {
|
|
123
|
+
opacity: 0.25;
|
|
124
|
+
cursor: not-allowed;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.calendar__day:focus-visible {
|
|
128
|
+
outline: none;
|
|
129
|
+
box-shadow: var(--focus-glow);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.calendar__day--focused {
|
|
133
|
+
box-shadow: inset 0 0 0 2px var(--accent-primary);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@media (prefers-reduced-motion: reduce) {
|
|
137
|
+
:host *,
|
|
138
|
+
:host *::before,
|
|
139
|
+
:host *::after {
|
|
140
|
+
animation-duration: 0.01ms !important;
|
|
141
|
+
animation-iteration-count: 1 !important;
|
|
142
|
+
transition-duration: 0.01ms !important;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
`,
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
static _DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
149
|
+
static _MONTHS = ['January', 'February', 'March', 'April', 'May', 'June',
|
|
150
|
+
'July', 'August', 'September', 'October', 'November', 'December'];
|
|
151
|
+
|
|
152
|
+
constructor() {
|
|
153
|
+
super();
|
|
154
|
+
const now = new Date();
|
|
155
|
+
this.value = '';
|
|
156
|
+
this.min = '';
|
|
157
|
+
this.max = '';
|
|
158
|
+
this.month = now.getMonth();
|
|
159
|
+
this.year = now.getFullYear();
|
|
160
|
+
this._focusedDay = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
get _todayISO() {
|
|
164
|
+
const d = new Date();
|
|
165
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_toISO(year, month, day) {
|
|
169
|
+
return `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
_isDisabled(iso) {
|
|
173
|
+
if (this.min && iso < this.min) return true;
|
|
174
|
+
if (this.max && iso > this.max) return true;
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_getCalendarDays() {
|
|
179
|
+
const firstDay = new Date(this.year, this.month, 1).getDay();
|
|
180
|
+
const daysInMonth = new Date(this.year, this.month + 1, 0).getDate();
|
|
181
|
+
const daysInPrev = new Date(this.year, this.month, 0).getDate();
|
|
182
|
+
|
|
183
|
+
const days = [];
|
|
184
|
+
|
|
185
|
+
// Previous month fill
|
|
186
|
+
for (let i = firstDay - 1; i >= 0; i--) {
|
|
187
|
+
const day = daysInPrev - i;
|
|
188
|
+
const m = this.month === 0 ? 11 : this.month - 1;
|
|
189
|
+
const y = this.month === 0 ? this.year - 1 : this.year;
|
|
190
|
+
days.push({ day, month: m, year: y, outside: true });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Current month
|
|
194
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
195
|
+
days.push({ day: d, month: this.month, year: this.year, outside: false });
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Next month fill
|
|
199
|
+
const remaining = 42 - days.length;
|
|
200
|
+
for (let d = 1; d <= remaining; d++) {
|
|
201
|
+
const m = this.month === 11 ? 0 : this.month + 1;
|
|
202
|
+
const y = this.month === 11 ? this.year + 1 : this.year;
|
|
203
|
+
days.push({ day: d, month: m, year: y, outside: true });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return days;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_prevMonth() {
|
|
210
|
+
if (this.month === 0) {
|
|
211
|
+
this.month = 11;
|
|
212
|
+
this.year--;
|
|
213
|
+
} else {
|
|
214
|
+
this.month--;
|
|
215
|
+
}
|
|
216
|
+
this._dispatchMonthChange();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
_nextMonth() {
|
|
220
|
+
if (this.month === 11) {
|
|
221
|
+
this.month = 0;
|
|
222
|
+
this.year++;
|
|
223
|
+
} else {
|
|
224
|
+
this.month++;
|
|
225
|
+
}
|
|
226
|
+
this._dispatchMonthChange();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
_dispatchMonthChange() {
|
|
230
|
+
this.dispatchEvent(new CustomEvent('arc-navigate', {
|
|
231
|
+
detail: { month: this.month, year: this.year },
|
|
232
|
+
bubbles: true,
|
|
233
|
+
composed: true,
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
_selectDate(iso) {
|
|
238
|
+
if (this._isDisabled(iso)) return;
|
|
239
|
+
this.value = iso;
|
|
240
|
+
|
|
241
|
+
this.dispatchEvent(new CustomEvent('arc-change', {
|
|
242
|
+
detail: { value: iso },
|
|
243
|
+
bubbles: true,
|
|
244
|
+
composed: true,
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_onKeyDown(e) {
|
|
249
|
+
if (!this._focusedDay) {
|
|
250
|
+
// Initialize focused day from value or today
|
|
251
|
+
const v = this.value || this._todayISO;
|
|
252
|
+
const parts = v.split('-');
|
|
253
|
+
this._focusedDay = { year: +parts[0], month: +parts[1] - 1, day: +parts[2] };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let { year, month, day } = this._focusedDay;
|
|
257
|
+
let handled = true;
|
|
258
|
+
|
|
259
|
+
switch (e.key) {
|
|
260
|
+
case 'ArrowRight': day++; break;
|
|
261
|
+
case 'ArrowLeft': day--; break;
|
|
262
|
+
case 'ArrowDown': day += 7; break;
|
|
263
|
+
case 'ArrowUp': day -= 7; break;
|
|
264
|
+
case 'Enter':
|
|
265
|
+
case ' ':
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
this._selectDate(this._toISO(year, month, day));
|
|
268
|
+
return;
|
|
269
|
+
default:
|
|
270
|
+
handled = false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (!handled) return;
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
|
|
276
|
+
// Normalize date
|
|
277
|
+
const d = new Date(year, month, day);
|
|
278
|
+
this._focusedDay = { year: d.getFullYear(), month: d.getMonth(), day: d.getDate() };
|
|
279
|
+
|
|
280
|
+
// Navigate months if needed
|
|
281
|
+
if (d.getMonth() !== this.month || d.getFullYear() !== this.year) {
|
|
282
|
+
this.month = d.getMonth();
|
|
283
|
+
this.year = d.getFullYear();
|
|
284
|
+
this._dispatchMonthChange();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
this.requestUpdate();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
render() {
|
|
291
|
+
const days = this._getCalendarDays();
|
|
292
|
+
const today = this._todayISO;
|
|
293
|
+
|
|
294
|
+
return html`
|
|
295
|
+
<div class="calendar" part="calendar" @keydown=${this._onKeyDown} tabindex="0">
|
|
296
|
+
<div class="calendar__header" part="header">
|
|
297
|
+
<button class="calendar__nav" @click=${this._prevMonth} aria-label="Previous month" part="nav-prev">
|
|
298
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" aria-hidden="true">
|
|
299
|
+
<path d="M6.5 1.5L3 5L6.5 8.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
300
|
+
</svg>
|
|
301
|
+
</button>
|
|
302
|
+
<span class="calendar__title" part="title">${ArcCalendar._MONTHS[this.month]} ${this.year}</span>
|
|
303
|
+
<button class="calendar__nav" @click=${this._nextMonth} aria-label="Next month" part="nav-next">
|
|
304
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" aria-hidden="true">
|
|
305
|
+
<path d="M3.5 1.5L7 5L3.5 8.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
306
|
+
</svg>
|
|
307
|
+
</button>
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
<div class="calendar__grid" role="grid" part="grid">
|
|
311
|
+
${ArcCalendar._DAYS.map(d => html`<div class="calendar__dow" part="dow">${d}</div>`)}
|
|
312
|
+
|
|
313
|
+
${days.map(({ day, month, year, outside }) => {
|
|
314
|
+
const iso = this._toISO(year, month, day);
|
|
315
|
+
const isToday = iso === today;
|
|
316
|
+
const isSelected = iso === this.value;
|
|
317
|
+
const isDisabled = this._isDisabled(iso);
|
|
318
|
+
const isFocused = this._focusedDay &&
|
|
319
|
+
this._focusedDay.year === year &&
|
|
320
|
+
this._focusedDay.month === month &&
|
|
321
|
+
this._focusedDay.day === day;
|
|
322
|
+
|
|
323
|
+
return html`
|
|
324
|
+
<button
|
|
325
|
+
class="calendar__day ${outside ? 'calendar__day--outside' : ''} ${isToday ? 'calendar__day--today' : ''} ${isSelected ? 'calendar__day--selected' : ''} ${isFocused ? 'calendar__day--focused' : ''}"
|
|
326
|
+
?disabled=${isDisabled}
|
|
327
|
+
@click=${() => this._selectDate(iso)}
|
|
328
|
+
aria-label="${ArcCalendar._MONTHS[month]} ${day}, ${year}"
|
|
329
|
+
aria-pressed=${isSelected ? 'true' : 'false'}
|
|
330
|
+
part="day"
|
|
331
|
+
>${day}</button>
|
|
332
|
+
`;
|
|
333
|
+
})}
|
|
334
|
+
</div>
|
|
335
|
+
</div>
|
|
336
|
+
`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
customElements.define('arc-calendar', ArcCalendar);
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcCheckbox extends LitElement {
|
|
5
|
+
static formAssociated = true;
|
|
6
|
+
|
|
7
|
+
static properties = {
|
|
8
|
+
checked: { type: Boolean, reflect: true },
|
|
9
|
+
indeterminate: { type: Boolean, reflect: true },
|
|
10
|
+
disabled: { type: Boolean, reflect: true },
|
|
11
|
+
label: { type: String },
|
|
12
|
+
name: { type: String },
|
|
13
|
+
value: { type: String },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
static styles = [
|
|
17
|
+
tokenStyles,
|
|
18
|
+
css`
|
|
19
|
+
:host { display: inline-flex; }
|
|
20
|
+
:host([disabled]) { pointer-events: none; opacity: 0.4; }
|
|
21
|
+
|
|
22
|
+
.checkbox {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: var(--space-sm);
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
min-height: var(--touch-min);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.checkbox__box {
|
|
31
|
+
position: relative;
|
|
32
|
+
width: 18px;
|
|
33
|
+
height: 18px;
|
|
34
|
+
border-radius: var(--radius-sm);
|
|
35
|
+
border: 1px solid var(--border-bright);
|
|
36
|
+
background: var(--bg-surface);
|
|
37
|
+
transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:host([checked]) .checkbox__box,
|
|
45
|
+
:host([indeterminate]) .checkbox__box {
|
|
46
|
+
background: var(--accent-primary);
|
|
47
|
+
border-color: var(--accent-primary);
|
|
48
|
+
box-shadow: 0 0 8px rgba(var(--accent-primary-rgb), 0.3);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.checkbox__icon {
|
|
52
|
+
position: absolute;
|
|
53
|
+
width: 12px;
|
|
54
|
+
height: 12px;
|
|
55
|
+
fill: none;
|
|
56
|
+
stroke: var(--bg-deep);
|
|
57
|
+
stroke-width: 2.5;
|
|
58
|
+
stroke-linecap: round;
|
|
59
|
+
stroke-linejoin: round;
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transform: scale(0.5);
|
|
62
|
+
transition: opacity var(--transition-fast), transform var(--transition-fast);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([checked]) .checkbox__icon--check,
|
|
66
|
+
:host([indeterminate]) .checkbox__icon--dash {
|
|
67
|
+
transform: scale(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:host([checked]) .checkbox__icon--check,
|
|
71
|
+
:host([indeterminate]) .checkbox__icon--dash { opacity: 1; }
|
|
72
|
+
|
|
73
|
+
.checkbox__label {
|
|
74
|
+
font-family: var(--font-body);
|
|
75
|
+
font-size: var(--body-size);
|
|
76
|
+
color: var(--text-secondary);
|
|
77
|
+
user-select: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.checkbox__box:focus-visible {
|
|
81
|
+
outline: none;
|
|
82
|
+
box-shadow: var(--focus-glow);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (prefers-reduced-motion: reduce) {
|
|
86
|
+
:host *,
|
|
87
|
+
:host *::before,
|
|
88
|
+
:host *::after {
|
|
89
|
+
animation-duration: 0.01ms !important;
|
|
90
|
+
animation-iteration-count: 1 !important;
|
|
91
|
+
transition-duration: 0.01ms !important;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
constructor() {
|
|
98
|
+
super();
|
|
99
|
+
this._internals = this.attachInternals();
|
|
100
|
+
this.checked = false;
|
|
101
|
+
this.indeterminate = false;
|
|
102
|
+
this.disabled = false;
|
|
103
|
+
this.label = '';
|
|
104
|
+
this.name = '';
|
|
105
|
+
this.value = '';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
updated(changed) {
|
|
109
|
+
if (changed.has('checked') || changed.has('value')) {
|
|
110
|
+
this._internals.setFormValue(this.checked ? (this.value || 'on') : null);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_toggle() {
|
|
115
|
+
if (this.disabled) return;
|
|
116
|
+
this.indeterminate = false;
|
|
117
|
+
this.checked = !this.checked;
|
|
118
|
+
this._internals.setFormValue(this.checked ? (this.value || 'on') : null);
|
|
119
|
+
this.dispatchEvent(new CustomEvent('arc-change', {
|
|
120
|
+
detail: { checked: this.checked },
|
|
121
|
+
bubbles: true,
|
|
122
|
+
composed: true,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_handleKeydown(e) {
|
|
127
|
+
if (e.key === ' ') {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
this._toggle();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
render() {
|
|
134
|
+
return html`
|
|
135
|
+
<label class="checkbox" part="checkbox">
|
|
136
|
+
<div
|
|
137
|
+
class="checkbox__box"
|
|
138
|
+
role="checkbox"
|
|
139
|
+
aria-checked=${this.indeterminate ? 'mixed' : this.checked ? 'true' : 'false'}
|
|
140
|
+
aria-label=${this.label || ''}
|
|
141
|
+
tabindex=${this.disabled ? '-1' : '0'}
|
|
142
|
+
@click=${this._toggle}
|
|
143
|
+
@keydown=${this._handleKeydown}
|
|
144
|
+
part="box"
|
|
145
|
+
>
|
|
146
|
+
<svg class="checkbox__icon checkbox__icon--check" viewBox="0 0 12 12">
|
|
147
|
+
<polyline points="2.5,6 5,8.5 9.5,3.5"></polyline>
|
|
148
|
+
</svg>
|
|
149
|
+
<svg class="checkbox__icon checkbox__icon--dash" viewBox="0 0 12 12">
|
|
150
|
+
<line x1="3" y1="6" x2="9" y2="6"></line>
|
|
151
|
+
</svg>
|
|
152
|
+
</div>
|
|
153
|
+
${this.label ? html`<span class="checkbox__label" part="label">${this.label}</span>` : ''}
|
|
154
|
+
</label>
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
customElements.define('arc-checkbox', ArcCheckbox);
|