@iyulab/components 1.57.1 → 2.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/CHANGELOG.md +208 -0
- package/README.md +3 -1
- package/dist/_virtual/_glob-assets_raw/dark.css.e8ac080d.js +1 -1
- package/dist/_virtual/_glob-assets_raw/light.css.637cb2f8.js +1 -1
- package/dist/assets/locales/ar.json.js +16 -2
- package/dist/assets/locales/de.json.js +16 -2
- package/dist/assets/locales/en.json.js +16 -2
- package/dist/assets/locales/es.json.js +18 -2
- package/dist/assets/locales/fr.json.js +16 -2
- package/dist/assets/locales/id.json.js +16 -2
- package/dist/assets/locales/ja.json.js +18 -2
- package/dist/assets/locales/ko.json.js +18 -2
- package/dist/assets/locales/pt-BR.json.js +16 -2
- package/dist/assets/locales/ru.json.js +16 -2
- package/dist/assets/locales/th.json.js +18 -2
- package/dist/assets/locales/vi.json.js +16 -2
- package/dist/assets/locales/zh-CN.json.js +18 -2
- package/dist/assets/locales/zh-TW.json.js +18 -2
- package/dist/components/UElement.styles.js +2 -2
- package/dist/components/alert/UAlert.d.ts +12 -7
- package/dist/components/alert/UAlert.js +3 -3
- package/dist/components/alert/UAlert.styles.js +6 -23
- package/dist/components/badge/UBadge.d.ts +5 -5
- package/dist/components/badge/UBadge.js +3 -3
- package/dist/components/badge/UBadge.styles.js +4 -4
- package/dist/components/breadcrumb-item/UBreadcrumbItem.styles.js +1 -1
- package/dist/components/button/UButton.d.ts +32 -16
- package/dist/components/button/UButton.js +38 -5
- package/dist/components/button/UButton.styles.js +67 -50
- package/dist/components/button/forwarded-aria.d.ts +6 -0
- package/dist/components/button/forwarded-aria.js +15 -0
- package/dist/components/button-group/UButtonGroup.d.ts +4 -4
- package/dist/components/button-group/UButtonGroup.js +8 -8
- package/dist/components/button-group/UButtonGroup.styles.js +2 -2
- package/dist/components/calendar/UCalendar.d.ts +4 -0
- package/dist/components/calendar/UCalendar.js +5 -4
- package/dist/components/calendar/UCalendar.styles.js +4 -3
- package/dist/components/calendar/dates.d.ts +4 -0
- package/dist/components/calendar/dates.js +5 -1
- package/dist/components/calendar/datetime.d.ts +14 -0
- package/dist/components/calendar/datetime.js +35 -0
- package/dist/components/calendar/picker.styles.js +42 -2
- package/dist/components/card/UCard.d.ts +4 -3
- package/dist/components/card/UCard.js +3 -3
- package/dist/components/card/UCard.styles.js +2 -1
- package/dist/components/carousel/UCarousel.d.ts +7 -1
- package/dist/components/carousel/UCarousel.js +10 -3
- package/dist/components/carousel/UCarousel.styles.js +17 -6
- package/dist/components/checkbox/UCheckbox.d.ts +8 -9
- package/dist/components/checkbox/UCheckbox.js +3 -3
- package/dist/components/checkbox/UCheckbox.styles.js +22 -18
- package/dist/components/chip/UChip.d.ts +2 -2
- package/dist/components/chip/UChip.js +4 -4
- package/dist/components/copy-button/UCopyButton.d.ts +2 -2
- package/dist/components/copy-button/UCopyButton.js +4 -4
- package/dist/components/date-picker/UDatePicker.d.ts +32 -1
- package/dist/components/date-picker/UDatePicker.js +96 -33
- package/dist/components/date-picker/UDatePicker.styles.js +10 -18
- package/dist/components/date-range-picker/UDateRangePicker.d.ts +72 -7
- package/dist/components/date-range-picker/UDateRangePicker.js +210 -34
- package/dist/components/date-range-picker/UDateRangePicker.styles.js +13 -3
- package/dist/components/dialog/UDialog.js +1 -1
- package/dist/components/divider/UDivider.d.ts +3 -3
- package/dist/components/divider/UDivider.js +2 -2
- package/dist/components/divider/UDivider.styles.js +5 -5
- package/dist/components/drawer/UDrawer.js +1 -1
- package/dist/components/expander/UExpander.styles.js +2 -2
- package/dist/components/file-input/UFileInput.styles.js +5 -2
- package/dist/components/icon-button/UIconButton.d.ts +4 -3
- package/dist/components/icon-button/UIconButton.js +16 -6
- package/dist/components/icon-button/UIconButton.styles.js +2 -2
- package/dist/components/input/UInput.d.ts +12 -5
- package/dist/components/input/UInput.js +7 -4
- package/dist/components/input/UInput.styles.js +60 -30
- package/dist/components/menu/UMenu.d.ts +5 -4
- package/dist/components/menu/UMenu.js +3 -3
- package/dist/components/menu/UMenu.styles.js +1 -1
- package/dist/components/menu-item/UMenuItem.styles.js +1 -1
- package/dist/components/option/UOption.d.ts +1 -0
- package/dist/components/option/UOption.js +6 -3
- package/dist/components/option/UOption.styles.js +1 -1
- package/dist/components/progress-bar/UProgressBar.styles.js +11 -0
- package/dist/components/radio/URadio.d.ts +27 -6
- package/dist/components/radio/URadio.js +48 -12
- package/dist/components/radio/URadio.styles.js +47 -13
- package/dist/components/rating/URating.styles.js +5 -1
- package/dist/components/select/USelect.d.ts +9 -2
- package/dist/components/select/USelect.js +7 -2
- package/dist/components/select/USelect.styles.js +55 -26
- package/dist/components/slider/USlider.styles.js +4 -4
- package/dist/components/spinner/USpinner.styles.js +2 -0
- package/dist/components/split-panel/USplitPanel.styles.js +2 -1
- package/dist/components/steps/USteps.d.ts +57 -0
- package/dist/components/steps/USteps.js +58 -0
- package/dist/components/steps/USteps.styles.d.ts +1 -0
- package/dist/components/steps/USteps.styles.js +110 -0
- package/dist/components/switch/USwitch.styles.js +5 -3
- package/dist/components/tab/UTab.js +2 -2
- package/dist/components/tab/UTab.styles.js +1 -1
- package/dist/components/tab-panel/UTabPanel.d.ts +11 -2
- package/dist/components/tab-panel/UTabPanel.js +33 -5
- package/dist/components/tab-panel/UTabPanel.styles.js +29 -29
- package/dist/components/tag/UTag.d.ts +14 -6
- package/dist/components/tag/UTag.js +8 -3
- package/dist/components/tag/UTag.styles.js +33 -26
- package/dist/components/textarea/UTextarea.d.ts +9 -3
- package/dist/components/textarea/UTextarea.js +7 -2
- package/dist/components/textarea/UTextarea.styles.js +41 -22
- package/dist/components/tree-item/UTreeItem.styles.js +7 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/plugins/vite-plugin-react-wrapper.js +14 -5
- package/dist/react/UAlert.d.ts +4 -2
- package/dist/react/UAvatar.d.ts +4 -2
- package/dist/react/UBadge.d.ts +4 -2
- package/dist/react/UBreadcrumb.d.ts +4 -2
- package/dist/react/UBreadcrumbItem.d.ts +4 -2
- package/dist/react/UButton.d.ts +4 -2
- package/dist/react/UButtonGroup.d.ts +4 -2
- package/dist/react/UCard.d.ts +4 -2
- package/dist/react/UCarousel.d.ts +4 -2
- package/dist/react/UCheckbox.d.ts +4 -2
- package/dist/react/UChip.d.ts +4 -2
- package/dist/react/UCopyButton.d.ts +4 -2
- package/dist/react/UDatePicker.d.ts +4 -2
- package/dist/react/UDateRangePicker.d.ts +4 -2
- package/dist/react/UDialog.d.ts +4 -2
- package/dist/react/UDivider.d.ts +4 -2
- package/dist/react/UDrawer.d.ts +4 -2
- package/dist/react/UExpander.d.ts +4 -2
- package/dist/react/UField.d.ts +4 -2
- package/dist/react/UFileInput.d.ts +4 -2
- package/dist/react/UForm.d.ts +4 -2
- package/dist/react/UIcon.d.ts +4 -2
- package/dist/react/UIconButton.d.ts +4 -2
- package/dist/react/UInput.d.ts +4 -2
- package/dist/react/UMenu.d.ts +4 -2
- package/dist/react/UMenuItem.d.ts +4 -2
- package/dist/react/UOption.d.ts +4 -2
- package/dist/react/UPanel.d.ts +4 -2
- package/dist/react/UPopover.d.ts +4 -2
- package/dist/react/UProgressBar.d.ts +4 -2
- package/dist/react/UProgressRing.d.ts +4 -2
- package/dist/react/URadio.d.ts +4 -2
- package/dist/react/URating.d.ts +4 -2
- package/dist/react/USelect.d.ts +4 -2
- package/dist/react/USkeleton.d.ts +4 -2
- package/dist/react/USlider.d.ts +4 -2
- package/dist/react/USpinner.d.ts +4 -2
- package/dist/react/USplitPanel.d.ts +4 -2
- package/dist/react/USteps.d.ts +14 -0
- package/dist/react/USteps.js +10 -0
- package/dist/react/USwitch.d.ts +4 -2
- package/dist/react/UTab.d.ts +4 -2
- package/dist/react/UTabPanel.d.ts +4 -2
- package/dist/react/UTag.d.ts +4 -2
- package/dist/react/UText.d.ts +4 -2
- package/dist/react/UTextarea.d.ts +4 -2
- package/dist/react/UTooltip.d.ts +4 -2
- package/dist/react/UTree.d.ts +4 -2
- package/dist/react/UTreeItem.d.ts +4 -2
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/styles/dark.css +42 -0
- package/dist/styles/light.css +44 -0
- package/dist/utilities/Dialog.d.ts +2 -2
- package/dist/utilities/Dialog.js +3 -3
- package/dist/utilities/Locale.d.ts +2 -2
- package/dist/utilities/Locale.js +2 -2
- package/dist/utilities/Toast.d.ts +2 -2
- package/dist/utilities/Toast.js +1 -1
- package/dist/utilities/format.d.ts +32 -4
- package/dist/utilities/format.js +131 -15
- package/dist/utilities/icons.d.ts +12 -3
- package/dist/utilities/icons.js +24 -6
- package/package.json +1 -1
- package/skills/iyulab-components/SKILL.md +3 -3
- package/skills/iyulab-components/references/components/alert.md +5 -5
- package/skills/iyulab-components/references/components/badge.md +3 -3
- package/skills/iyulab-components/references/components/button-group.md +3 -3
- package/skills/iyulab-components/references/components/button.md +34 -19
- package/skills/iyulab-components/references/components/card.md +3 -3
- package/skills/iyulab-components/references/components/carousel.md +3 -1
- package/skills/iyulab-components/references/components/checkbox.md +5 -5
- package/skills/iyulab-components/references/components/chip.md +2 -2
- package/skills/iyulab-components/references/components/copy-button.md +1 -1
- package/skills/iyulab-components/references/components/date-picker.md +35 -2
- package/skills/iyulab-components/references/components/date-range-picker.md +53 -5
- package/skills/iyulab-components/references/components/dialog.md +2 -2
- package/skills/iyulab-components/references/components/divider.md +2 -2
- package/skills/iyulab-components/references/components/drawer.md +1 -1
- package/skills/iyulab-components/references/components/field.md +1 -1
- package/skills/iyulab-components/references/components/icon-button.md +8 -2
- package/skills/iyulab-components/references/components/input.md +4 -2
- package/skills/iyulab-components/references/components/menu.md +1 -1
- package/skills/iyulab-components/references/components/radio.md +16 -4
- package/skills/iyulab-components/references/components/select.md +2 -1
- package/skills/iyulab-components/references/components/steps.md +66 -0
- package/skills/iyulab-components/references/components/tab-panel.md +10 -3
- package/skills/iyulab-components/references/components/tag.md +11 -7
- package/skills/iyulab-components/references/components/textarea.md +2 -1
- package/skills/iyulab-components/references/usage.md +1 -1
- package/skills/iyulab-components/references/utilities/dialog.md +2 -2
- package/skills/iyulab-components/references/utilities/icons.md +2 -2
- package/skills/iyulab-components/references/utilities/locale.md +1 -1
- package/skills/iyulab-components/references/utilities/theme.md +9 -5
- package/skills/iyulab-components/references/utilities/toast.md +2 -2
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import { UElement } from '../UElement.js';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 외형 정도(chrome) — 컴포넌트 공통 어휘. `solid` 꽉 찬 면 · `soft` 옅은 틴트 면 · `outlined` 테두리 ·
|
|
5
|
+
* `plain` 외형 없음 · `link` 링크처럼(버튼류만).
|
|
6
|
+
*/
|
|
7
|
+
export type ButtonAppearance = "solid" | "soft" | "outlined" | "plain" | "link";
|
|
4
8
|
export type ButtonType = "button" | "submit" | "reset";
|
|
5
9
|
/**
|
|
6
10
|
* 두 축이 한 속성에 병존한다.
|
|
@@ -28,26 +32,26 @@ export type ButtonSize = "sm" | "md" | "lg";
|
|
|
28
32
|
* @csspart content - 콘텐츠 영역
|
|
29
33
|
* @csspart mask - 로딩 마스크 영역
|
|
30
34
|
*
|
|
31
|
-
* @cssprop --u-primary-color - color="
|
|
35
|
+
* @cssprop --u-primary-color - 기본(color="primary") 버튼의 기준색. 지정 시 hover/active/soft 톤이 color-mix()로 자동 파생.
|
|
32
36
|
* @cssprop --btn-padding-block - 내부 버튼의 상하 여백 (기본: 0.5em)
|
|
33
|
-
* @cssprop --btn-padding-inline - 내부 버튼의 좌우 여백 (기본: 1em,
|
|
37
|
+
* @cssprop --btn-padding-inline - 내부 버튼의 좌우 여백 (기본: 1em, appearance="link"는 0).
|
|
34
38
|
* ⚠1.20.0 에서 0.5em → 1em. 세로와 같은 값이라 글자가 테두리에 붙어 있었다.
|
|
35
39
|
* 최소높이는 상하 여백에서 파생되므로(`1.5em + 상하×2 + 2px`) 이 값을 덮어도 높이는 안 변한다.
|
|
36
|
-
* @cssprop --btn-border-color - 내부 버튼의 테두리 색.
|
|
40
|
+
* @cssprop --btn-border-color - 내부 버튼의 테두리 색. appearance/hover/active 규칙이 이 값을 정한다
|
|
37
41
|
* (기본: transparent)
|
|
38
42
|
* @cssprop --btn-color - 버튼의 **면** 색. 아래 파생 토큰이 전부 이 값에서 color-mix()로 계산된다 —
|
|
39
43
|
* 보통 이것 하나만 덮으면 된다.
|
|
40
|
-
* @cssprop --btn-txt-color - 그 **면 위**의 글자색 —
|
|
44
|
+
* @cssprop --btn-txt-color - 그 **면 위**의 글자색 — appearance="solid" 가 읽는다
|
|
41
45
|
* (기본: #fff · 역할 값 지정 시 --u-{role}-txt-color)
|
|
42
|
-
* @cssprop --btn-color-strong - **바탕 위**의 글자색 —
|
|
46
|
+
* @cssprop --btn-color-strong - **바탕 위**의 글자색 — appearance="link"·"plain" 이 읽는다.
|
|
43
47
|
* 면과 요구가 반대라 슬롯이 따로 있다 (기본: --btn-color 와 동일 · 역할 값 지정 시 --u-{role}-color-strong)
|
|
44
48
|
* @cssprop --btn-color-strong-hover - 바탕 위 글자 hover (기본: 85% + black · 역할 값은 움직이지 않고 밑줄로 강조)
|
|
45
49
|
* @cssprop --btn-color-strong-active - 바탕 위 글자 active (기본: 70% + black · 역할 값은 고정)
|
|
46
50
|
* @cssprop --btn-color-hover - solid 배경 hover (기본: --btn-color 85% + black)
|
|
47
51
|
* @cssprop --btn-color-active - solid 배경 active (기본: --btn-color 70% + black)
|
|
48
|
-
* @cssprop --btn-color-surface -
|
|
49
|
-
* @cssprop --btn-color-surface-hover -
|
|
50
|
-
* @cssprop --btn-color-surface-active -
|
|
52
|
+
* @cssprop --btn-color-surface - soft 배경 (역할 색: --u-{role}-bg-color · 그 밖: --btn-color 12% + 배경색)
|
|
53
|
+
* @cssprop --btn-color-surface-hover - soft 배경 hover (역할 색: 면에 --btn-color 18% · 그 밖: 22%)
|
|
54
|
+
* @cssprop --btn-color-surface-active - soft 배경 active (역할 색: 면에 --btn-color 30% · 그 밖: 32%)
|
|
51
55
|
* @cssprop --btn-color-border - 테두리 (기본: --btn-color 45% + 배경색)
|
|
52
56
|
* @cssprop --btn-color-border-hover - 테두리 hover (기본: 60%)
|
|
53
57
|
* @cssprop --btn-color-border-active - 테두리 active (기본: 75%)
|
|
@@ -63,14 +67,18 @@ export declare class UButton extends UElement {
|
|
|
63
67
|
* 네이티브 버튼을 대체하는 요소가 잃으면 안 되는 계약이다.
|
|
64
68
|
*/
|
|
65
69
|
static shadowRootOptions: ShadowRootInit;
|
|
66
|
-
/**
|
|
67
|
-
|
|
70
|
+
/** 외형 정도 — `solid`(기본) · `soft` · `outlined` · `plain` · `link` */
|
|
71
|
+
appearance: ButtonAppearance;
|
|
68
72
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* `link
|
|
73
|
+
* 색. 주지 않으면 `primary` 로 칠한다(`--u-primary-color` 역할 토큰) — 브랜드 색을 덮으면 맨 버튼이
|
|
74
|
+
* 함께 따라온다. `neutral` 은 **무채색**(회색) 버튼이다(모든 컴포넌트에서 같은 뜻).
|
|
75
|
+
* `plain`·`link` 는 글자만 있는 외형이라 색을 주지 않았거나 `neutral` 이면 본문/링크 색을 쓰고,
|
|
76
|
+
* 그 밖의 색을 주면 글자가 그 색을 따른다 — `plain` 에 `primary` 를 **명시**하면 브랜드색 글자다.
|
|
77
|
+
*
|
|
78
|
+
* ⚠기본값을 두지 않는다(반영되는 속성이라, 기본값을 두면 맨 버튼도 `color="primary"` 를 달아
|
|
79
|
+
* «명시한 primary» 와 구별되지 않는다).
|
|
72
80
|
*/
|
|
73
|
-
color
|
|
81
|
+
color?: ButtonColor;
|
|
74
82
|
/** 버튼 크기. `font-size`만 변경하며 나머지는 `em` 단위라 비례 조정됨. */
|
|
75
83
|
size: ButtonSize;
|
|
76
84
|
/** 경계선 둥글게 여부 */
|
|
@@ -118,6 +126,14 @@ export declare class UButton extends UElement {
|
|
|
118
126
|
*/
|
|
119
127
|
static get observedAttributes(): string[];
|
|
120
128
|
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
129
|
+
protected updated(changed: PropertyValues): void;
|
|
130
|
+
/**
|
|
131
|
+
* `aria-controls` 는 id 참조라 섀도 경계를 넘지 못한다 — 안쪽 버튼에 문자열로 옮기면 아무것도
|
|
132
|
+
* 가리키지 않는다. 호스트의 트리에서 id 를 풀어 **요소 참조**(`ariaControlsElements`)로 싣는다.
|
|
133
|
+
* 섀도 안에서 바깥 트리의 요소를 가리키는 것은 요소 참조가 허용하는 방향이다. 그 API 가 없는
|
|
134
|
+
* 브라우저에서는 옮기지 않는다(호스트의 속성은 그대로 남는다).
|
|
135
|
+
*/
|
|
136
|
+
private forwardControls;
|
|
121
137
|
render(): TemplateResult<1>;
|
|
122
138
|
private renderContent;
|
|
123
139
|
private renderMask;
|
|
@@ -3,6 +3,7 @@ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/hel
|
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
4
|
import "../spinner/USpinner.js";
|
|
5
5
|
import { styles } from "./UButton.styles.js";
|
|
6
|
+
import { FORWARDED_ARIA } from "./forwarded-aria.js";
|
|
6
7
|
import { html } from "lit";
|
|
7
8
|
import { customElement, property } from "lit/decorators.js";
|
|
8
9
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
@@ -10,8 +11,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
10
11
|
var UButton = class UButton extends UElement {
|
|
11
12
|
constructor(..._args) {
|
|
12
13
|
super(..._args);
|
|
13
|
-
this.
|
|
14
|
-
this.color = "neutral";
|
|
14
|
+
this.appearance = "solid";
|
|
15
15
|
this.size = "md";
|
|
16
16
|
this.rounded = false;
|
|
17
17
|
this.disabled = false;
|
|
@@ -82,17 +82,47 @@ var UButton = class UButton extends UElement {
|
|
|
82
82
|
* 않았다 — 목록에 명시적으로 추가해야 한다.
|
|
83
83
|
*/
|
|
84
84
|
static get observedAttributes() {
|
|
85
|
-
return [...super.observedAttributes,
|
|
85
|
+
return [...super.observedAttributes, ...FORWARDED_ARIA];
|
|
86
86
|
}
|
|
87
87
|
attributeChangedCallback(name, old, value) {
|
|
88
88
|
super.attributeChangedCallback(name, old, value);
|
|
89
|
-
if (name
|
|
89
|
+
if (FORWARDED_ARIA.includes(name)) this.requestUpdate();
|
|
90
|
+
}
|
|
91
|
+
updated(changed) {
|
|
92
|
+
super.updated(changed);
|
|
93
|
+
this.forwardControls();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `aria-controls` 는 id 참조라 섀도 경계를 넘지 못한다 — 안쪽 버튼에 문자열로 옮기면 아무것도
|
|
97
|
+
* 가리키지 않는다. 호스트의 트리에서 id 를 풀어 **요소 참조**(`ariaControlsElements`)로 싣는다.
|
|
98
|
+
* 섀도 안에서 바깥 트리의 요소를 가리키는 것은 요소 참조가 허용하는 방향이다. 그 API 가 없는
|
|
99
|
+
* 브라우저에서는 옮기지 않는다(호스트의 속성은 그대로 남는다).
|
|
100
|
+
*/
|
|
101
|
+
forwardControls() {
|
|
102
|
+
const inner = this.shadowRoot?.querySelector("button, a");
|
|
103
|
+
if (!inner || !("ariaControlsElements" in inner)) return;
|
|
104
|
+
const ids = this.getAttribute("aria-controls")?.split(/\s+/).filter(Boolean) ?? [];
|
|
105
|
+
const find = (id) => {
|
|
106
|
+
for (let root = this.getRootNode();;) {
|
|
107
|
+
const hit = root.getElementById?.(id);
|
|
108
|
+
if (hit) return hit;
|
|
109
|
+
if (!(root instanceof ShadowRoot)) return null;
|
|
110
|
+
root = root.host.getRootNode();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const targets = ids.map(find).filter((el) => !!el);
|
|
114
|
+
inner.ariaControlsElements = targets.length ? targets : null;
|
|
90
115
|
}
|
|
91
116
|
render() {
|
|
92
117
|
const ariaLabel = this.getAttribute("aria-label") ?? void 0;
|
|
118
|
+
const pressed = this.getAttribute("aria-pressed") ?? void 0;
|
|
119
|
+
const expanded = this.getAttribute("aria-expanded") ?? void 0;
|
|
120
|
+
const haspopup = this.getAttribute("aria-haspopup") ?? void 0;
|
|
93
121
|
if (this.href) return html`
|
|
94
122
|
<a part="link"
|
|
95
123
|
aria-label=${ifDefined(ariaLabel)}
|
|
124
|
+
aria-expanded=${ifDefined(expanded)}
|
|
125
|
+
aria-haspopup=${ifDefined(haspopup)}
|
|
96
126
|
?disabled=${this.effectivelyDisabled || this.loading}
|
|
97
127
|
tabindex=${this.effectivelyDisabled || this.loading ? -1 : 0}
|
|
98
128
|
href=${ifDefined(this.effectivelyDisabled || this.loading ? void 0 : this.href)}
|
|
@@ -107,6 +137,9 @@ var UButton = class UButton extends UElement {
|
|
|
107
137
|
return html`
|
|
108
138
|
<button part="button"
|
|
109
139
|
aria-label=${ifDefined(ariaLabel)}
|
|
140
|
+
aria-pressed=${ifDefined(pressed)}
|
|
141
|
+
aria-expanded=${ifDefined(expanded)}
|
|
142
|
+
aria-haspopup=${ifDefined(haspopup)}
|
|
110
143
|
type=${this.type}
|
|
111
144
|
?disabled=${this.effectivelyDisabled || this.loading}
|
|
112
145
|
>
|
|
@@ -136,7 +169,7 @@ var UButton = class UButton extends UElement {
|
|
|
136
169
|
__decorate([property({
|
|
137
170
|
type: String,
|
|
138
171
|
reflect: true
|
|
139
|
-
}), __decorateMetadata("design:type", Object)], UButton.prototype, "
|
|
172
|
+
}), __decorateMetadata("design:type", Object)], UButton.prototype, "appearance", void 0);
|
|
140
173
|
__decorate([property({
|
|
141
174
|
type: String,
|
|
142
175
|
reflect: true
|
|
@@ -2,7 +2,7 @@ import { css } from "lit";
|
|
|
2
2
|
//#region src/components/button/UButton.styles.ts
|
|
3
3
|
var styles = css`
|
|
4
4
|
:host {
|
|
5
|
-
/* --btn-color 하나만 정해지면 hover/active/
|
|
5
|
+
/* --btn-color 하나만 정해지면 hover/active/soft/outline 톤이 전부 자동 파생 */
|
|
6
6
|
--btn-color: var(--u-primary-color, #1976D2);
|
|
7
7
|
|
|
8
8
|
/* ★색 슬롯이 셋인 이유 — 같은 색이 세 자리에서 요구가 다르다.
|
|
@@ -57,35 +57,48 @@ var styles = css`
|
|
|
57
57
|
★장식 램프(shade-600)로 해석하면 안 된다 — 라이트에서 그 단 위의 흰 글자는 8색 중
|
|
58
58
|
6색이 AA 미달이다(green 3.30 · orange 2.37 · cyan 2.74 …). 역할 값을 쓰는 이유가
|
|
59
59
|
*의미 이름*인데 그 대가로 대비를 잃으면 앞뒤가 맞지 않는다. */
|
|
60
|
+
/* 기본(색 미지정)도 이 경로다 — color 는 기본값을 반영하지 않는다(UButton.ts 참조). */
|
|
61
|
+
:host(:not([color])),
|
|
60
62
|
:host([color="primary"]) {
|
|
61
63
|
--btn-color: var(--u-primary-color, #1976D2);
|
|
62
64
|
--btn-color-strong: var(--u-primary-color-strong, #1565C0);
|
|
63
65
|
--btn-txt-color: var(--u-primary-txt-color, #FFFFFF);
|
|
66
|
+
--btn-color-surface: var(--u-primary-bg-color, #E3F2FD);
|
|
64
67
|
}
|
|
65
68
|
:host([color="info"]) {
|
|
66
69
|
--btn-color: var(--u-info-color, #1976D2);
|
|
67
70
|
--btn-color-strong: var(--u-info-color-strong, #1565C0);
|
|
68
71
|
--btn-txt-color: var(--u-info-txt-color, #FFFFFF);
|
|
72
|
+
--btn-color-surface: var(--u-info-bg-color, #E3F2FD);
|
|
69
73
|
}
|
|
70
74
|
:host([color="success"]) {
|
|
71
75
|
--btn-color: var(--u-success-color, #2E7D32);
|
|
72
76
|
--btn-color-strong: var(--u-success-color-strong, #1B5E20);
|
|
73
77
|
--btn-txt-color: var(--u-success-txt-color, #FFFFFF);
|
|
78
|
+
--btn-color-surface: var(--u-success-bg-color, #E8F5E9);
|
|
74
79
|
}
|
|
75
80
|
:host([color="warning"]) {
|
|
76
81
|
--btn-color: var(--u-warning-color, #FDD835);
|
|
77
82
|
--btn-color-strong: var(--u-warning-color-strong, #8A4A00);
|
|
78
83
|
--btn-txt-color: var(--u-warning-txt-color, #000000);
|
|
84
|
+
--btn-color-surface: var(--u-warning-bg-color, #FFF59D);
|
|
79
85
|
}
|
|
80
86
|
:host([color="danger"]) {
|
|
81
87
|
--btn-color: var(--u-danger-color, #D32F2F);
|
|
82
88
|
--btn-color-strong: var(--u-danger-color-strong, #C62828);
|
|
83
89
|
--btn-txt-color: var(--u-danger-txt-color, #FFFFFF);
|
|
90
|
+
--btn-color-surface: var(--u-danger-bg-color, #FFEBEE);
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
/* 역할 축의 link 는 쉬는 상태가 **이미 대비로 선택된 단**(-strong)이라 더 어둡게 하면
|
|
87
94
|
계약을 벗어난다. 강조는 밑줄이 맡는다 — neutral link 가 쓰는 어법과 같다.
|
|
88
|
-
장식 축은 종전대로 혼합 파생을 유지한다.
|
|
95
|
+
장식 축은 종전대로 혼합 파생을 유지한다.
|
|
96
|
+
|
|
97
|
+
★soft 면도 같은 이유로 역할 층에서 읽는다 — --u-{role}-bg-color 는 «그 위 본문 대비가
|
|
98
|
+
보증된 유채색 표면» 이고, 태그·알림의 soft 가 이미 그 토큰을 쓴다. 혼합 12% 로 두면 같은
|
|
99
|
+
«soft warning» 이 태그와 버튼에서 다른 면이 되고(노랑 12% 는 거의 흰색), 다크 짝도 따로
|
|
100
|
+
놀았다. hover/active 는 그 면 위에 면 색을 더 섞어 진해지는 방향으로 파생한다. */
|
|
101
|
+
:host(:not([color])),
|
|
89
102
|
:host([color="primary"]),
|
|
90
103
|
:host([color="info"]),
|
|
91
104
|
:host([color="success"]),
|
|
@@ -93,9 +106,20 @@ var styles = css`
|
|
|
93
106
|
:host([color="danger"]) {
|
|
94
107
|
--btn-color-strong-hover: var(--btn-color-strong);
|
|
95
108
|
--btn-color-strong-active: var(--btn-color-strong);
|
|
109
|
+
--btn-color-surface-hover: color-mix(in srgb, var(--btn-color) 18%, var(--btn-color-surface));
|
|
110
|
+
--btn-color-surface-active: color-mix(in srgb, var(--btn-color) 30%, var(--btn-color-surface));
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
/* === Color tokens (장식 축) === */
|
|
114
|
+
/* neutral — 무채색 버튼. 면 = 중립 램프 700, 그 위 글자 = 반전 글자, 바탕 위 글자 = 본문색.
|
|
115
|
+
(2.0 전에는 neutral 이 «기본 = 브랜드 경로»였다 — 같은 낱말이 배지·체크박스에서는 회색이라
|
|
116
|
+
뜻이 정반대였다. 브랜드는 이제 primary 다.) */
|
|
117
|
+
:host([color="neutral"]) {
|
|
118
|
+
--btn-color: var(--u-neutral-700, #616161);
|
|
119
|
+
--btn-txt-color: var(--u-txt-color-inverse, #FFFFFF);
|
|
120
|
+
--btn-color-strong: var(--u-txt-color, #212121);
|
|
121
|
+
}
|
|
122
|
+
|
|
99
123
|
:host([color="blue"]) { --btn-color: var(--u-blue-600, #1E88E5); }
|
|
100
124
|
:host([color="green"]) { --btn-color: var(--u-green-600, #43A047); }
|
|
101
125
|
:host([color="red"]) { --btn-color: var(--u-red-600, #E53935); }
|
|
@@ -155,122 +179,113 @@ var styles = css`
|
|
|
155
179
|
display: none;
|
|
156
180
|
}
|
|
157
181
|
|
|
158
|
-
/* ===
|
|
182
|
+
/* === Appearance === */
|
|
159
183
|
|
|
160
|
-
/* solid: 강한 채움 (기본
|
|
161
|
-
:host([
|
|
184
|
+
/* solid: 강한 채움 (기본) */
|
|
185
|
+
:host([appearance="solid"]) {
|
|
162
186
|
color: var(--btn-txt-color);
|
|
163
187
|
background-color: var(--btn-color);
|
|
164
188
|
--btn-border-color: var(--btn-color);
|
|
165
189
|
}
|
|
166
|
-
:host([
|
|
190
|
+
:host([appearance="solid"]:hover) {
|
|
167
191
|
background-color: var(--btn-color-hover);
|
|
168
192
|
--btn-border-color: var(--btn-color-hover);
|
|
169
193
|
}
|
|
170
|
-
:host([
|
|
194
|
+
:host([appearance="solid"]:active) {
|
|
171
195
|
background-color: var(--btn-color-active);
|
|
172
196
|
--btn-border-color: var(--btn-color-active);
|
|
173
197
|
}
|
|
174
198
|
|
|
175
|
-
/*
|
|
176
|
-
:host([
|
|
177
|
-
color: var(--u-txt-color, #212121);
|
|
178
|
-
background-color: var(--btn-color-surface);
|
|
179
|
-
--btn-border-color: var(--btn-color-border);
|
|
180
|
-
}
|
|
181
|
-
:host([variant="surface"]:hover) {
|
|
182
|
-
background-color: var(--btn-color-surface-hover);
|
|
183
|
-
--btn-border-color: var(--btn-color-border-hover);
|
|
184
|
-
}
|
|
185
|
-
:host([variant="surface"]:active) {
|
|
186
|
-
background-color: var(--btn-color-surface-active);
|
|
187
|
-
--btn-border-color: var(--btn-color-border-active);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/* filled: 채우기만 */
|
|
191
|
-
:host([variant="filled"]) {
|
|
199
|
+
/* soft: 옅은 틴트 면, 테두리 없음 */
|
|
200
|
+
:host([appearance="soft"]) {
|
|
192
201
|
color: var(--u-txt-color, #212121);
|
|
193
202
|
background-color: var(--btn-color-surface);
|
|
194
203
|
--btn-border-color: transparent;
|
|
195
204
|
}
|
|
196
|
-
:host([
|
|
205
|
+
:host([appearance="soft"]:hover) {
|
|
197
206
|
background-color: var(--btn-color-surface-hover);
|
|
198
207
|
}
|
|
199
|
-
:host([
|
|
208
|
+
:host([appearance="soft"]:active) {
|
|
200
209
|
background-color: var(--btn-color-surface-active);
|
|
201
210
|
}
|
|
202
211
|
|
|
203
212
|
/* outlined: 경계만 */
|
|
204
|
-
:host([
|
|
213
|
+
:host([appearance="outlined"]) {
|
|
205
214
|
color: var(--u-txt-color, #212121);
|
|
206
215
|
--btn-border-color: var(--btn-color-border);
|
|
207
216
|
background-color: transparent;
|
|
208
217
|
}
|
|
209
|
-
:host([
|
|
218
|
+
:host([appearance="outlined"]:hover) {
|
|
210
219
|
--btn-border-color: var(--btn-color-border-hover);
|
|
211
220
|
background-color: var(--btn-color-outline-hover);
|
|
212
221
|
}
|
|
213
|
-
:host([
|
|
222
|
+
:host([appearance="outlined"]:active) {
|
|
214
223
|
--btn-border-color: var(--btn-color-border-active);
|
|
215
224
|
background-color: var(--btn-color-outline-active);
|
|
216
225
|
}
|
|
217
226
|
|
|
218
|
-
/*
|
|
219
|
-
:host([
|
|
227
|
+
/* plain: 외형 없음 (chromeless) */
|
|
228
|
+
:host([appearance="plain"]) {
|
|
220
229
|
color: var(--u-txt-color, #212121);
|
|
221
230
|
--btn-border-color: transparent;
|
|
222
231
|
background-color: transparent;
|
|
223
232
|
}
|
|
224
|
-
:host([
|
|
233
|
+
:host([appearance="plain"]:hover) {
|
|
225
234
|
background-color: var(--u-bg-color-hover, #F5F5F5);
|
|
226
235
|
}
|
|
227
|
-
:host([
|
|
236
|
+
:host([appearance="plain"]:active) {
|
|
228
237
|
background-color: var(--u-bg-color-active, #EEEEEE);
|
|
229
238
|
}
|
|
230
|
-
/*
|
|
231
|
-
|
|
239
|
+
/* plain + 색을 «명시» 한 것(neutral 제외): 글자색이 색 축을 따른다 (link 와 같은 어법)
|
|
240
|
+
맨 버튼(색 미지정)은 본문 글자다. 명시한 primary 는 브랜드색 글자다 — 기본값을 반영하지
|
|
241
|
+
않으므로 둘이 구별된다(2.0 첫 판은 기본값이 color="primary" 로 반영돼 그 둘이 같았고,
|
|
242
|
+
그래서 브랜드색 plain 버튼을 만들 길이 없었다).
|
|
243
|
+
★**plain 은 색이 «필요 없는» 외형이 아니라 색이 «유일한 신호»인 외형이다.**
|
|
232
244
|
면도 테두리도 없으므로 글자색이 사라지면 남는 구분이 없다 — 파괴적 액션을 ghost 로
|
|
233
245
|
두는 화면에서 위험 신호가 통째로 없어진다.
|
|
234
|
-
|
|
246
|
+
⚠1.22.0 전에는 이 세 줄이 없어 color 속성을 무엇으로 주든 중립색이 나왔다. solid·outlined
|
|
235
247
|
는 따르고 link 도 아래에서 따르는데 여기만 빠져 있었다 — 축이 **한 자리에서만**
|
|
236
248
|
끊긴 형태라, 12조합을 격자로 대조하기 전에는 드러나지 않는다.
|
|
237
249
|
link 와 같은 이유로 면 슬롯(--btn-color)이 아니라 --btn-color-strong 을 읽는다. */
|
|
238
|
-
:host([
|
|
250
|
+
:host([appearance="plain"][color]:not([color="neutral"])) {
|
|
239
251
|
color: var(--btn-color-strong);
|
|
240
252
|
}
|
|
241
|
-
|
|
253
|
+
/* 호버 면도 그 색의 soft 면이다 — 회색 호버는 «색이 유일한 신호» 를 누르는 순간 지운다. */
|
|
254
|
+
:host([appearance="plain"][color]:not([color="neutral"]):hover) {
|
|
242
255
|
color: var(--btn-color-strong-hover);
|
|
256
|
+
background-color: var(--btn-color-surface);
|
|
243
257
|
}
|
|
244
|
-
:host([
|
|
258
|
+
:host([appearance="plain"][color]:not([color="neutral"]):active) {
|
|
245
259
|
color: var(--btn-color-strong-active);
|
|
260
|
+
background-color: var(--btn-color-surface-hover);
|
|
246
261
|
}
|
|
247
262
|
|
|
248
|
-
/* link:
|
|
263
|
+
/* link: 링크 스타일 (기본 primary·neutral 에서는 링크 색)
|
|
249
264
|
★종전 3단(weak → color → strong)은 쉬는 상태가 --u-primary-color-weak (흰 바탕 3.12)라
|
|
250
265
|
링크 글자가 AA 미달이었고, 그 사이 토큰 층의 --u-link-txt-color 는 어디에서도 쓰이지
|
|
251
266
|
않았다. 링크 색을 정의해 둔 토큰을 링크가 무시하고 있었던 셈이다.
|
|
252
267
|
쉬는 상태를 그 토큰으로 되돌리고, 강조는 밑줄과 -strong 한 단으로 표현한다. */
|
|
253
|
-
:host([
|
|
268
|
+
:host([appearance="link"]) {
|
|
254
269
|
color: var(--u-link-txt-color, #1565C0);
|
|
255
270
|
--btn-border-color: transparent;
|
|
256
271
|
background-color: transparent;
|
|
257
272
|
--btn-padding-inline: 0;
|
|
258
273
|
}
|
|
259
|
-
:host([
|
|
260
|
-
:host([
|
|
274
|
+
:host([appearance="link"]:hover),
|
|
275
|
+
:host([appearance="link"]:active) {
|
|
261
276
|
color: var(--u-primary-color-strong, #1565C0);
|
|
262
277
|
text-decoration: underline;
|
|
263
278
|
}
|
|
264
|
-
/* link +
|
|
279
|
+
/* link + 기본(primary)·neutral 밖의 색: 링크 자체 색상을 재정의 (예: 파괴적 액션 링크)
|
|
265
280
|
★여기는 **바탕 위의 글자**다 — 면 슬롯(--btn-color)이 아니라 --btn-color-strong 을
|
|
266
281
|
읽는다. 장식 축에서는 둘이 같은 값이라 렌더가 변하지 않고, 역할 축에서만 갈린다. */
|
|
267
|
-
:host([
|
|
282
|
+
:host([appearance="link"][color]:not([color="primary"]):not([color="neutral"])) {
|
|
268
283
|
color: var(--btn-color-strong);
|
|
269
284
|
}
|
|
270
|
-
:host([
|
|
285
|
+
:host([appearance="link"][color]:not([color="primary"]):not([color="neutral"]):hover) {
|
|
271
286
|
color: var(--btn-color-strong-hover);
|
|
272
287
|
}
|
|
273
|
-
:host([
|
|
288
|
+
:host([appearance="link"][color]:not([color="primary"]):not([color="neutral"]):active) {
|
|
274
289
|
color: var(--btn-color-strong-active);
|
|
275
290
|
}
|
|
276
291
|
|
|
@@ -281,8 +296,8 @@ var styles = css`
|
|
|
281
296
|
* 호스트 요소에 대해서는 문서 작성자 스타일이 섀도의 :host 규칙을 이기기 때문이며,
|
|
282
297
|
* 그 결과 버튼이 글자 높이만 남는다(에러는 없다). 내부 요소는 문서 리셋의 사정권 밖이다.
|
|
283
298
|
*
|
|
284
|
-
* 테두리 색은 여전히 :host([
|
|
285
|
-
*
|
|
299
|
+
* 테두리 색은 여전히 :host([appearance=...]) 가 정한다 — --btn-border-color 로 내려보내므로
|
|
300
|
+
* appearance/hover/active 규칙은 호스트에 그대로 남는다.
|
|
286
301
|
*/
|
|
287
302
|
button, a {
|
|
288
303
|
all: unset;
|
|
@@ -305,7 +320,9 @@ var styles = css`
|
|
|
305
320
|
* 그래서 글자 버튼의 높이는 **변하지 않고**(sm 32 · md 37 · lg 42 그대로),
|
|
306
321
|
* 아이콘만 든 버튼이 같은 높이로 올라온다. 상수를 박으면 이 성질이 깨진다 —
|
|
307
322
|
* 소비자가 --btn-padding-block 을 덮는 순간 둘이 다시 갈라진다. */
|
|
308
|
-
min-height: calc(1.5em + 2 * var(--btn-padding-block, 0.5em) + 2px);
|
|
323
|
+
min-height: max(calc(1.5em + 2 * var(--btn-padding-block, 0.5em) + 2px), var(--u-target-size, 0px));
|
|
324
|
+
/* 호스트 하한(--u-target-size, 미설정 = 0) — 글자와 독립된 터치 하한. 아이콘만 든 버튼은 폭도 따른다. */
|
|
325
|
+
min-width: var(--u-target-size, 0px);
|
|
309
326
|
|
|
310
327
|
}
|
|
311
328
|
a {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 호스트에서 안쪽 포커스 대상(`<button>`/`<a>`)으로 옮기는 ARIA — 이름과 버튼 계열의 상태다.
|
|
3
|
+
* 상태 속성은 포커스된 요소에 있어야 보조기기가 읽는다(WCAG 4.1.2). `aria-pressed` 는 링크에
|
|
4
|
+
* 허용되지 않아 `<button>` 에만 싣는다. `aria-controls` 는 id 참조라 `forwardControls()` 가 따로 옮긴다.
|
|
5
|
+
*/
|
|
6
|
+
export declare const FORWARDED_ARIA: readonly ["aria-label", "aria-pressed", "aria-expanded", "aria-haspopup", "aria-controls"];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/components/button/forwarded-aria.ts
|
|
2
|
+
/**
|
|
3
|
+
* 호스트에서 안쪽 포커스 대상(`<button>`/`<a>`)으로 옮기는 ARIA — 이름과 버튼 계열의 상태다.
|
|
4
|
+
* 상태 속성은 포커스된 요소에 있어야 보조기기가 읽는다(WCAG 4.1.2). `aria-pressed` 는 링크에
|
|
5
|
+
* 허용되지 않아 `<button>` 에만 싣는다. `aria-controls` 는 id 참조라 `forwardControls()` 가 따로 옮긴다.
|
|
6
|
+
*/
|
|
7
|
+
var FORWARDED_ARIA = [
|
|
8
|
+
"aria-label",
|
|
9
|
+
"aria-pressed",
|
|
10
|
+
"aria-expanded",
|
|
11
|
+
"aria-haspopup",
|
|
12
|
+
"aria-controls"
|
|
13
|
+
];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { FORWARDED_ARIA };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { PropertyValues } from 'lit';
|
|
2
2
|
import { UElement } from '../UElement.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ButtonAppearance } from '../button/UButton.js';
|
|
4
4
|
/**
|
|
5
5
|
* 여러 버튼을 묶어 그룹으로 표시하는 컴포넌트입니다.
|
|
6
|
-
*
|
|
6
|
+
* appearance 또는 disabled 속성을 설정하면 하위 u-button, u-icon-button에 자동 적용됩니다.
|
|
7
7
|
*
|
|
8
8
|
* @slot - u-button 또는 u-icon-button 요소들
|
|
9
9
|
*/
|
|
10
10
|
export declare class UButtonGroup extends UElement {
|
|
11
11
|
static styles: import('lit').CSSResultGroup[];
|
|
12
|
-
/** 하위 버튼에 자동 적용할
|
|
13
|
-
|
|
12
|
+
/** 하위 버튼에 자동 적용할 외형 */
|
|
13
|
+
appearance: ButtonAppearance;
|
|
14
14
|
/** 세로 방향 배치 여부 */
|
|
15
15
|
vertical: boolean;
|
|
16
16
|
/** 하위 버튼 자동 비활성화 */
|
|
@@ -10,7 +10,7 @@ import { customElement, property } from "lit/decorators.js";
|
|
|
10
10
|
var UButtonGroup = class UButtonGroup extends UElement {
|
|
11
11
|
constructor(..._args) {
|
|
12
12
|
super(..._args);
|
|
13
|
-
this.
|
|
13
|
+
this.appearance = "solid";
|
|
14
14
|
this.vertical = false;
|
|
15
15
|
this.disabled = false;
|
|
16
16
|
this.handleSlotChange = () => {
|
|
@@ -23,7 +23,7 @@ var UButtonGroup = class UButtonGroup extends UElement {
|
|
|
23
23
|
updated(changedProperties) {
|
|
24
24
|
super.updated(changedProperties);
|
|
25
25
|
if ([
|
|
26
|
-
"
|
|
26
|
+
"appearance",
|
|
27
27
|
"disabled",
|
|
28
28
|
"vertical"
|
|
29
29
|
].some((k) => changedProperties.has(k))) this.propagate();
|
|
@@ -36,16 +36,16 @@ var UButtonGroup = class UButtonGroup extends UElement {
|
|
|
36
36
|
propagate() {
|
|
37
37
|
const buttons = (this.shadowRoot?.querySelector("slot"))?.assignedElements({ flatten: true }).filter((el) => el instanceof UButton || el instanceof UIconButton);
|
|
38
38
|
if (!buttons?.length) return;
|
|
39
|
-
const
|
|
39
|
+
const appearance = this.appearance;
|
|
40
40
|
const vertical = this.vertical;
|
|
41
41
|
const lastIndex = buttons.length - 1;
|
|
42
|
-
const
|
|
43
|
-
const isSolid =
|
|
42
|
+
const isPlain = appearance === "plain" || appearance === "link";
|
|
43
|
+
const isSolid = appearance === "solid" || appearance === "soft";
|
|
44
44
|
buttons.forEach((button, index) => {
|
|
45
|
-
button.
|
|
45
|
+
button.appearance = appearance;
|
|
46
46
|
button.disabled = this.disabled;
|
|
47
47
|
const radius = this.getRadius(index, lastIndex, vertical);
|
|
48
|
-
const margin = index > 0 && !
|
|
48
|
+
const margin = index > 0 && !isPlain ? "-1px" : "";
|
|
49
49
|
const borderCollapse = isSolid && button instanceof UButton;
|
|
50
50
|
if (button instanceof UIconButton) {
|
|
51
51
|
const inner = button.shadowRoot?.querySelector("u-button");
|
|
@@ -80,7 +80,7 @@ var UButtonGroup = class UButtonGroup extends UElement {
|
|
|
80
80
|
__decorate([property({
|
|
81
81
|
type: String,
|
|
82
82
|
reflect: true
|
|
83
|
-
}), __decorateMetadata("design:type", Object)], UButtonGroup.prototype, "
|
|
83
|
+
}), __decorateMetadata("design:type", Object)], UButtonGroup.prototype, "appearance", void 0);
|
|
84
84
|
__decorate([property({
|
|
85
85
|
type: Boolean,
|
|
86
86
|
reflect: true
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropertyValues } from 'lit';
|
|
2
2
|
import { UElement } from '../UElement.js';
|
|
3
|
+
import { DateDisabledFn } from './dates.js';
|
|
3
4
|
export interface CalendarDaySelectDetail {
|
|
4
5
|
/** The chosen day as ISO `YYYY-MM-DD`. */
|
|
5
6
|
date: string;
|
|
@@ -57,6 +58,9 @@ export declare class UCalendar extends UElement {
|
|
|
57
58
|
min?: string;
|
|
58
59
|
/** Latest selectable day (ISO), inclusive. */
|
|
59
60
|
max?: string;
|
|
61
|
+
/** App rule for days that cannot be chosen (ISO in, `true` = unavailable) — drawn and refused like
|
|
62
|
+
* a day outside `min`/`max`. */
|
|
63
|
+
isDateDisabled?: DateDisabledFn;
|
|
60
64
|
/** How many consecutive months to show side by side. */
|
|
61
65
|
visibleMonths: number;
|
|
62
66
|
/** First visible month (always the 1st of a month). */
|
|
@@ -4,7 +4,7 @@ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm
|
|
|
4
4
|
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../icon-button/UIconButton.js";
|
|
6
6
|
import { formatDate } from "../../utilities/format.js";
|
|
7
|
-
import { addDays, addMonths, daysInMonth,
|
|
7
|
+
import { addDays, addMonths, daysInMonth, isDayUnavailable, isSameDay, monthDiff, parseISODate, startOfMonth, toISODate } from "./dates.js";
|
|
8
8
|
import { styles } from "./UCalendar.styles.js";
|
|
9
9
|
import { html } from "lit";
|
|
10
10
|
import { customElement, property, state } from "lit/decorators.js";
|
|
@@ -139,7 +139,7 @@ var UCalendar = class UCalendar extends UElement {
|
|
|
139
139
|
if (this.start && this.end) return ordered(parseISODate(this.start), parseISODate(this.end));
|
|
140
140
|
}
|
|
141
141
|
renderDay(date, range) {
|
|
142
|
-
const
|
|
142
|
+
const unavailable = isDayUnavailable(date, this.min, this.max, this.isDateDisabled);
|
|
143
143
|
const t = date.getTime();
|
|
144
144
|
const inRange = !!range && t >= range[0].getTime() && t <= range[1].getTime();
|
|
145
145
|
const selected = this.selection === "range" ? this.anchor ? isSameDay(date, this.anchor) : inRange : this.value ? isSameDay(date, parseISODate(this.value)) : false;
|
|
@@ -149,7 +149,7 @@ var UCalendar = class UCalendar extends UElement {
|
|
|
149
149
|
data-iso=${toISODate(date)}
|
|
150
150
|
tabindex=${isSameDay(date, this.focusedDate) ? 0 : -1}
|
|
151
151
|
aria-selected=${selected}
|
|
152
|
-
aria-disabled=${
|
|
152
|
+
aria-disabled=${unavailable}
|
|
153
153
|
?data-today=${isSameDay(date, /* @__PURE__ */ new Date())}
|
|
154
154
|
?data-in-range=${inRange}
|
|
155
155
|
?data-range-start=${!!range && isSameDay(date, range[0])}
|
|
@@ -170,7 +170,7 @@ var UCalendar = class UCalendar extends UElement {
|
|
|
170
170
|
return this.renderRoot.querySelector(`button.day[data-iso="${toISODate(date)}"]`);
|
|
171
171
|
}
|
|
172
172
|
activate(date) {
|
|
173
|
-
if (
|
|
173
|
+
if (isDayUnavailable(date, this.min, this.max, this.isDateDisabled)) return;
|
|
174
174
|
if (this.selection !== "range") {
|
|
175
175
|
this.fire("day-select", { detail: { date: toISODate(date) } });
|
|
176
176
|
return;
|
|
@@ -210,6 +210,7 @@ __decorate([property({ type: String }), __decorateMetadata("design:type", String
|
|
|
210
210
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "end", void 0);
|
|
211
211
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "min", void 0);
|
|
212
212
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "max", void 0);
|
|
213
|
+
__decorate([property({ attribute: false }), __decorateMetadata("design:type", Object)], UCalendar.prototype, "isDateDisabled", void 0);
|
|
213
214
|
__decorate([property({
|
|
214
215
|
type: Number,
|
|
215
216
|
attribute: "visible-months"
|
|
@@ -17,7 +17,7 @@ var styles = css`
|
|
|
17
17
|
gap: 16px;
|
|
18
18
|
}
|
|
19
19
|
.month {
|
|
20
|
-
flex: 1 1 224px;
|
|
20
|
+
flex: 1 1 max(224px, calc(7 * var(--u-target-size, 0px)));
|
|
21
21
|
min-width: 0;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -41,7 +41,8 @@ var styles = css`
|
|
|
41
41
|
.calendar-weekdays,
|
|
42
42
|
.calendar-grid {
|
|
43
43
|
display: grid;
|
|
44
|
-
|
|
44
|
+
/* 칸 하한은 32px — 호스트 하한(--u-target-size)이 더 크면 그 값. */
|
|
45
|
+
grid-template-columns: repeat(7, minmax(max(32px, var(--u-target-size, 0px)), 1fr));
|
|
45
46
|
}
|
|
46
47
|
.calendar-weekdays {
|
|
47
48
|
padding-bottom: 4px;
|
|
@@ -80,7 +81,7 @@ var styles = css`
|
|
|
80
81
|
}
|
|
81
82
|
.day:focus-visible {
|
|
82
83
|
outline: none;
|
|
83
|
-
box-shadow: 0 0 0 2px var(--u-
|
|
84
|
+
box-shadow: 0 0 0 2px var(--u-focus-ring-color, #1565C0);
|
|
84
85
|
}
|
|
85
86
|
.day[data-today] {
|
|
86
87
|
font-weight: 700;
|
|
@@ -9,5 +9,9 @@ export declare function addDays(date: Date, delta: number): Date;
|
|
|
9
9
|
export declare function daysInMonth(date: Date): number;
|
|
10
10
|
/** 두 날의 달 차이(`b` 가 `a` 보다 몇 달 뒤인가). 일자는 무시한다. */
|
|
11
11
|
export declare function monthDiff(a: Date, b: Date): number;
|
|
12
|
+
/** 앱이 정하는 날짜별 비활성 규칙 — ISO `YYYY-MM-DD` 를 받아 고를 수 없으면 `true`. */
|
|
13
|
+
export type DateDisabledFn = (date: string) => boolean;
|
|
14
|
+
/** 고를 수 없는 날인가 — `min`/`max` 밖이거나 앱 규칙이 막았다. */
|
|
15
|
+
export declare function isDayUnavailable(date: Date, min?: string, max?: string, isDateDisabled?: DateDisabledFn): boolean;
|
|
12
16
|
/** `min`/`max`(ISO 날짜, 둘 다 선택)를 벗어나는가 — 경계일은 포함이다. */
|
|
13
17
|
export declare function isOutOfRange(date: Date, min?: string, max?: string): boolean;
|