ds-one 0.2.5-alpha.8 → 0.3.0-alpha.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.
- package/DS1/0-face/device.ts +138 -0
- package/DS1/0-face/i18n.ts +36 -89
- package/DS1/0-face/scaling.ts +152 -0
- package/DS1/1-root/fonts/Iosevka-Regular.woff2 +0 -0
- package/DS1/1-root/one.css +124 -77
- package/DS1/2-core/ds-banner.ts +120 -1
- package/DS1/2-core/ds-button.ts +16 -96
- package/DS1/2-core/ds-card.ts +137 -0
- package/DS1/2-core/ds-cycle.ts +82 -184
- package/DS1/2-core/ds-date.ts +3 -10
- package/DS1/2-core/ds-gap.ts +38 -0
- package/DS1/2-core/ds-icon.ts +6 -35
- package/DS1/2-core/ds-input.ts +306 -1
- package/DS1/2-core/ds-pagedots.ts +52 -0
- package/DS1/2-core/ds-text.ts +55 -28
- package/DS1/2-core/ds-tooltip.ts +14 -66
- package/DS1/2-core/styles/ds-banner.css +77 -0
- package/DS1/2-core/styles/ds-button.css +67 -0
- package/DS1/2-core/styles/ds-cycle.css +21 -0
- package/DS1/2-core/styles/ds-date.css +9 -0
- package/DS1/2-core/styles/ds-gap.css +93 -0
- package/DS1/2-core/styles/ds-icon.css +30 -0
- package/DS1/2-core/styles/ds-input.css +46 -0
- package/DS1/2-core/styles/ds-pagedots.css +31 -0
- package/DS1/2-core/styles/ds-text.css +29 -0
- package/DS1/2-core/styles/ds-tooltip.css +49 -0
- package/DS1/3-unit/ds-accordion.ts +95 -0
- package/DS1/3-unit/ds-form.ts +304 -0
- package/DS1/3-unit/ds-list.ts +5 -14
- package/DS1/3-unit/ds-row.ts +3 -19
- package/DS1/3-unit/ds-table.ts +3 -86
- package/DS1/3-unit/styles/ds-accordion.css +46 -0
- package/DS1/3-unit/styles/ds-list.css +9 -0
- package/DS1/3-unit/styles/ds-row.css +19 -0
- package/DS1/3-unit/styles/ds-table.css +80 -0
- package/DS1/4-page/ds-container.ts +28 -0
- package/DS1/4-page/ds-grid.ts +37 -50
- package/DS1/4-page/ds-layout.ts +652 -163
- package/DS1/4-page/styles/ds-container.css +35 -0
- package/DS1/4-page/styles/ds-grid.css +56 -0
- package/DS1/4-page/styles/ds-layout.css +246 -0
- package/DS1/index.ts +9 -1
- package/DS1/vite-env.d.ts +13 -0
- package/DS1/x-icon/2x.svg +4 -0
- package/DS1/x-icon/2xdots.svg +18 -0
- package/DS1/x-icon/2xgrid.svg +6 -0
- package/DS1/x-icon/2xlines.svg +6 -0
- package/DS1/x-icon/4x4.svg +18 -0
- package/DS1/x-icon/apple.svg +4 -0
- package/DS1/x-icon/avatar.svg +4 -0
- package/DS1/x-icon/big.svg +4 -0
- package/DS1/x-icon/blank.svg +3 -0
- package/DS1/x-icon/check.svg +3 -0
- package/DS1/x-icon/close.svg +3 -0
- package/DS1/x-icon/collapse.svg +3 -0
- package/DS1/x-icon/color.svg +4 -0
- package/DS1/x-icon/column.svg +5 -0
- package/DS1/x-icon/default.svg +3 -0
- package/DS1/x-icon/delete.svg +5 -0
- package/DS1/x-icon/dictate.svg +6 -0
- package/DS1/x-icon/do.svg +3 -0
- package/DS1/x-icon/down.svg +3 -0
- package/DS1/x-icon/duplicate.svg +4 -0
- package/DS1/x-icon/gallery.svg +5 -0
- package/DS1/x-icon/google.svg +6 -0
- package/DS1/x-icon/head.svg +5 -0
- package/DS1/x-icon/home.svg +3 -0
- package/DS1/x-icon/icon.svg +4 -0
- package/DS1/x-icon/in.svg +4 -0
- package/DS1/x-icon/lock.svg +5 -0
- package/DS1/x-icon/loop.svg +5 -0
- package/DS1/x-icon/mic.svg +5 -0
- package/DS1/x-icon/minimize.svg +3 -0
- package/DS1/x-icon/more.svg +5 -0
- package/DS1/x-icon/neutral.svg +6 -0
- package/DS1/x-icon/note.svg +6 -0
- package/DS1/x-icon/page.svg +4 -0
- package/DS1/x-icon/plus.svg +3 -0
- package/DS1/x-icon/rewind.svg +4 -0
- package/DS1/x-icon/row.svg +5 -0
- package/DS1/x-icon/sdown.svg +3 -0
- package/DS1/x-icon/search.svg +4 -0
- package/DS1/x-icon/see.svg +4 -0
- package/DS1/x-icon/ship.svg +5 -0
- package/DS1/x-icon/star.svg +3 -0
- package/DS1/x-icon/status.svg +4 -0
- package/DS1/x-icon/sup.svg +3 -0
- package/DS1/x-icon/title.svg +3 -0
- package/DS1/x-icon/undo.svg +3 -0
- package/DS1/x-icon/ungroup.svg +4 -0
- package/DS1/x-icon/unhead.svg +3 -0
- package/DS1/x-icon/unicon.svg +3 -0
- package/DS1/x-icon/unlock.svg +5 -0
- package/DS1/x-icon/unmic.svg +6 -0
- package/DS1/x-icon/unsee.svg +5 -0
- package/DS1/x-icon/unstar.svg +3 -0
- package/DS1/x-icon/untitle.svg +3 -0
- package/DS1/x-icon/up.svg +3 -0
- package/LICENSE +1 -1
- package/README.md +4 -4
- package/dist/0-face/device.d.ts +5 -0
- package/dist/0-face/device.d.ts.map +1 -1
- package/dist/0-face/device.js +111 -0
- package/dist/0-face/i18n.d.ts +0 -2
- package/dist/0-face/i18n.d.ts.map +1 -1
- package/dist/0-face/i18n.js +36 -73
- package/dist/0-face/scaling.d.ts +48 -0
- package/dist/0-face/scaling.d.ts.map +1 -0
- package/dist/0-face/scaling.js +114 -0
- package/dist/2-core/ds-banner.d.ts +67 -0
- package/dist/2-core/ds-banner.d.ts.map +1 -1
- package/dist/2-core/ds-banner.js +97 -1
- package/dist/2-core/ds-button.d.ts +4 -20
- package/dist/2-core/ds-button.d.ts.map +1 -1
- package/dist/2-core/ds-button.js +14 -88
- package/dist/2-core/ds-card.d.ts +39 -0
- package/dist/2-core/ds-card.d.ts.map +1 -0
- package/dist/2-core/ds-card.js +119 -0
- package/dist/2-core/ds-cycle.d.ts +1 -5
- package/dist/2-core/ds-cycle.d.ts.map +1 -1
- package/dist/2-core/ds-cycle.js +79 -166
- package/dist/2-core/ds-date.d.ts.map +1 -1
- package/dist/2-core/ds-date.js +3 -9
- package/dist/2-core/ds-gap.d.ts +28 -0
- package/dist/2-core/ds-gap.d.ts.map +1 -0
- package/dist/2-core/ds-gap.js +25 -0
- package/dist/2-core/ds-icon.d.ts.map +1 -1
- package/dist/2-core/ds-icon.js +6 -35
- package/dist/2-core/ds-input.d.ts +127 -0
- package/dist/2-core/ds-input.d.ts.map +1 -1
- package/dist/2-core/ds-input.js +252 -1
- package/dist/2-core/ds-pagedots.d.ts +32 -0
- package/dist/2-core/ds-pagedots.d.ts.map +1 -0
- package/dist/2-core/ds-pagedots.js +36 -0
- package/dist/2-core/ds-text.d.ts +5 -3
- package/dist/2-core/ds-text.d.ts.map +1 -1
- package/dist/2-core/ds-text.js +49 -27
- package/dist/2-core/ds-tooltip.d.ts +3 -3
- package/dist/2-core/ds-tooltip.d.ts.map +1 -1
- package/dist/2-core/ds-tooltip.js +13 -65
- package/dist/2-core/styles/ds-banner.css +77 -0
- package/dist/2-core/styles/ds-button.css +67 -0
- package/dist/2-core/styles/ds-cycle.css +21 -0
- package/dist/2-core/styles/ds-date.css +9 -0
- package/dist/2-core/styles/ds-gap.css +93 -0
- package/dist/2-core/styles/ds-icon.css +30 -0
- package/dist/2-core/styles/ds-input.css +46 -0
- package/dist/2-core/styles/ds-pagedots.css +26 -0
- package/dist/2-core/styles/ds-text.css +29 -0
- package/dist/2-core/styles/ds-tooltip.css +49 -0
- package/dist/3-unit/ds-accordion.d.ts +47 -0
- package/dist/3-unit/ds-accordion.d.ts.map +1 -0
- package/dist/3-unit/ds-accordion.js +75 -0
- package/dist/3-unit/ds-form.d.ts +70 -0
- package/dist/3-unit/ds-form.d.ts.map +1 -0
- package/dist/3-unit/ds-form.js +232 -0
- package/dist/3-unit/ds-list.d.ts.map +1 -1
- package/dist/3-unit/ds-list.js +5 -11
- package/dist/3-unit/ds-row.d.ts.map +1 -1
- package/dist/3-unit/ds-row.js +3 -19
- package/dist/3-unit/ds-table.d.ts.map +1 -1
- package/dist/3-unit/ds-table.js +3 -86
- package/dist/3-unit/styles/ds-accordion.css +46 -0
- package/dist/3-unit/styles/ds-list.css +9 -0
- package/dist/3-unit/styles/ds-row.css +19 -0
- package/dist/3-unit/styles/ds-table.css +80 -0
- package/dist/{3-unit/row-v1.d.ts → 4-page/ds-container.d.ts} +3 -11
- package/dist/4-page/ds-container.d.ts.map +1 -0
- package/dist/4-page/ds-container.js +11 -0
- package/dist/4-page/ds-grid.d.ts +5 -0
- package/dist/4-page/ds-grid.d.ts.map +1 -1
- package/dist/4-page/ds-grid.js +38 -56
- package/dist/4-page/ds-layout.d.ts +3 -3
- package/dist/4-page/ds-layout.d.ts.map +1 -1
- package/dist/4-page/ds-layout.js +651 -162
- package/dist/4-page/styles/ds-container.css +35 -0
- package/dist/4-page/styles/ds-grid.css +56 -0
- package/dist/4-page/styles/ds-layout.css +251 -0
- package/dist/ds-one.bundle.css +700 -0
- package/dist/ds-one.bundle.css.map +7 -0
- package/dist/ds-one.bundle.js +2728 -1597
- package/dist/ds-one.bundle.js.map +1 -7
- package/dist/ds-one.bundle.min.css +2 -0
- package/dist/ds-one.bundle.min.css.map +7 -0
- package/dist/ds-one.bundle.min.js +3850 -546
- package/dist/ds-one.bundle.min.js.map +1 -7
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/package.json +4 -3
- package/dist/3-unit/doublenav-v1.d.ts +0 -51
- package/dist/3-unit/doublenav-v1.d.ts.map +0 -1
- package/dist/3-unit/doublenav-v1.js +0 -88
- package/dist/3-unit/ds-portfolio-doublenav.d.ts +0 -51
- package/dist/3-unit/ds-portfolio-doublenav.d.ts.map +0 -1
- package/dist/3-unit/ds-portfolio-doublenav.js +0 -88
- package/dist/3-unit/ds-portfolio-panel.d.ts +0 -11
- package/dist/3-unit/ds-portfolio-panel.d.ts.map +0 -1
- package/dist/3-unit/ds-portfolio-panel.js +0 -16
- package/dist/3-unit/ds-portfolio-singlenav.d.ts +0 -32
- package/dist/3-unit/ds-portfolio-singlenav.d.ts.map +0 -1
- package/dist/3-unit/ds-portfolio-singlenav.js +0 -62
- package/dist/3-unit/list-v1.d.ts +0 -11
- package/dist/3-unit/list-v1.d.ts.map +0 -1
- package/dist/3-unit/list-v1.js +0 -15
- package/dist/3-unit/panel-v1.d.ts +0 -11
- package/dist/3-unit/panel-v1.d.ts.map +0 -1
- package/dist/3-unit/panel-v1.js +0 -16
- package/dist/3-unit/row-v1.d.ts.map +0 -1
- package/dist/3-unit/row-v1.js +0 -32
- package/dist/3-unit/singlenav-v1.d.ts +0 -32
- package/dist/3-unit/singlenav-v1.d.ts.map +0 -1
- package/dist/3-unit/singlenav-v1.js +0 -62
package/DS1/2-core/ds-input.ts
CHANGED
|
@@ -1 +1,306 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ds-input.ts
|
|
2
|
+
// Input component for text and other input types
|
|
3
|
+
|
|
4
|
+
import { LitElement, html, css } from "lit";
|
|
5
|
+
import "./ds-text";
|
|
6
|
+
|
|
7
|
+
export class Input extends LitElement {
|
|
8
|
+
static properties = {
|
|
9
|
+
type: { type: String, reflect: true },
|
|
10
|
+
name: { type: String, reflect: true },
|
|
11
|
+
value: { type: String },
|
|
12
|
+
placeholder: { type: String },
|
|
13
|
+
placeholderKey: { type: String, attribute: "placeholder-key" },
|
|
14
|
+
label: { type: String },
|
|
15
|
+
labelText: { type: String, attribute: "label-text" },
|
|
16
|
+
disabled: { type: Boolean, reflect: true },
|
|
17
|
+
readonly: { type: Boolean, reflect: true },
|
|
18
|
+
required: { type: Boolean, reflect: true },
|
|
19
|
+
autofocus: { type: Boolean },
|
|
20
|
+
autocomplete: { type: String },
|
|
21
|
+
pattern: { type: String },
|
|
22
|
+
minlength: { type: Number },
|
|
23
|
+
maxlength: { type: Number },
|
|
24
|
+
min: { type: String },
|
|
25
|
+
max: { type: String },
|
|
26
|
+
step: { type: String },
|
|
27
|
+
variant: { type: String, reflect: true },
|
|
28
|
+
error: { type: String },
|
|
29
|
+
errorText: { type: String, attribute: "error-text" },
|
|
30
|
+
_focused: { type: Boolean, state: true },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare type:
|
|
34
|
+
| "text"
|
|
35
|
+
| "password"
|
|
36
|
+
| "email"
|
|
37
|
+
| "number"
|
|
38
|
+
| "tel"
|
|
39
|
+
| "url"
|
|
40
|
+
| "search"
|
|
41
|
+
| "date"
|
|
42
|
+
| "time"
|
|
43
|
+
| "datetime-local";
|
|
44
|
+
declare name: string;
|
|
45
|
+
declare value: string;
|
|
46
|
+
declare placeholder: string;
|
|
47
|
+
declare placeholderKey: string;
|
|
48
|
+
declare label: string;
|
|
49
|
+
declare labelText: string;
|
|
50
|
+
declare disabled: boolean;
|
|
51
|
+
declare readonly: boolean;
|
|
52
|
+
declare required: boolean;
|
|
53
|
+
declare autofocus: boolean;
|
|
54
|
+
declare autocomplete: string;
|
|
55
|
+
declare pattern: string;
|
|
56
|
+
declare minlength: number;
|
|
57
|
+
declare maxlength: number;
|
|
58
|
+
declare min: string;
|
|
59
|
+
declare max: string;
|
|
60
|
+
declare step: string;
|
|
61
|
+
declare variant: "default" | "filled" | "outlined";
|
|
62
|
+
declare error: string;
|
|
63
|
+
declare errorText: string;
|
|
64
|
+
declare _focused: boolean;
|
|
65
|
+
|
|
66
|
+
constructor() {
|
|
67
|
+
super();
|
|
68
|
+
this.type = "text";
|
|
69
|
+
this.name = "";
|
|
70
|
+
this.value = "";
|
|
71
|
+
this.placeholder = "";
|
|
72
|
+
this.placeholderKey = "";
|
|
73
|
+
this.label = "";
|
|
74
|
+
this.labelText = "";
|
|
75
|
+
this.disabled = false;
|
|
76
|
+
this.readonly = false;
|
|
77
|
+
this.required = false;
|
|
78
|
+
this.autofocus = false;
|
|
79
|
+
this.autocomplete = "off";
|
|
80
|
+
this.pattern = "";
|
|
81
|
+
this.minlength = 0;
|
|
82
|
+
this.maxlength = 0;
|
|
83
|
+
this.min = "";
|
|
84
|
+
this.max = "";
|
|
85
|
+
this.step = "";
|
|
86
|
+
this.variant = "default";
|
|
87
|
+
this.error = "";
|
|
88
|
+
this.errorText = "";
|
|
89
|
+
this._focused = false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static styles = css`
|
|
93
|
+
:host {
|
|
94
|
+
display: block;
|
|
95
|
+
width: 100%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.input-wrapper {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: calc(var(--025) * var(--sf, 1));
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
label {
|
|
106
|
+
font-family: var(--typeface-regular);
|
|
107
|
+
font-size: calc(12px * var(--sf, 1));
|
|
108
|
+
color: var(--text-color-secondary);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.input-container {
|
|
112
|
+
position: relative;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
width: 100%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
input {
|
|
119
|
+
width: 100%;
|
|
120
|
+
height: calc(var(--1) * var(--sf, 1));
|
|
121
|
+
padding: 0 calc(var(--025) * var(--sf, 1));
|
|
122
|
+
font-family: var(--typeface-regular);
|
|
123
|
+
font-size: calc(14px * var(--sf, 1));
|
|
124
|
+
color: var(--text-color-primary);
|
|
125
|
+
background-color: var(--input-background, transparent);
|
|
126
|
+
border: 1px solid var(--input-border-color, var(--border-color, #ccc));
|
|
127
|
+
border-radius: calc(var(--025) * var(--sf, 1));
|
|
128
|
+
outline: none;
|
|
129
|
+
transition:
|
|
130
|
+
border-color 0.2s ease,
|
|
131
|
+
box-shadow 0.2s ease;
|
|
132
|
+
box-sizing: border-box;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
input::placeholder {
|
|
136
|
+
color: var(--text-color-tertiary, #999);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
input:focus {
|
|
140
|
+
border-color: var(--accent-color, #007aff);
|
|
141
|
+
box-shadow: 0 0 0 2px var(--input-focus-ring, rgba(0, 122, 255, 0.2));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
input:disabled {
|
|
145
|
+
opacity: 0.5;
|
|
146
|
+
cursor: not-allowed;
|
|
147
|
+
background-color: var(--input-disabled-background, #f5f5f5);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
input:read-only {
|
|
151
|
+
background-color: var(--input-readonly-background, #fafafa);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
:host([variant="filled"]) input {
|
|
155
|
+
background-color: var(
|
|
156
|
+
--input-filled-background,
|
|
157
|
+
var(--surface-color-secondary, #f5f5f5)
|
|
158
|
+
);
|
|
159
|
+
border: none;
|
|
160
|
+
border-bottom: 2px solid var(--border-color, #ccc);
|
|
161
|
+
border-radius: calc(var(--025) * var(--sf, 1))
|
|
162
|
+
calc(var(--025) * var(--sf, 1)) 0 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
:host([variant="filled"]) input:focus {
|
|
166
|
+
border-bottom-color: var(--accent-color, #007aff);
|
|
167
|
+
box-shadow: none;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
:host([variant="outlined"]) input {
|
|
171
|
+
background-color: transparent;
|
|
172
|
+
border: 2px solid var(--border-color, #ccc);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:host([variant="outlined"]) input:focus {
|
|
176
|
+
border-color: var(--accent-color, #007aff);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.error-message {
|
|
180
|
+
font-family: var(--typeface-regular);
|
|
181
|
+
font-size: calc(12px * var(--sf, 1));
|
|
182
|
+
color: var(--error-color, #ff3b30);
|
|
183
|
+
margin-top: calc(var(--025) * var(--sf, 1));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
:host([required]) label::after {
|
|
187
|
+
content: " *";
|
|
188
|
+
color: var(--error-color, #ff3b30);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Error state */
|
|
192
|
+
input.has-error {
|
|
193
|
+
border-color: var(--error-color, #ff3b30);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
input.has-error:focus {
|
|
197
|
+
box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.2);
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
private _handleInput(e: Event): void {
|
|
202
|
+
const target = e.target as HTMLInputElement;
|
|
203
|
+
this.value = target.value;
|
|
204
|
+
this.dispatchEvent(
|
|
205
|
+
new CustomEvent("input-change", {
|
|
206
|
+
detail: { value: this.value, name: this.name },
|
|
207
|
+
bubbles: true,
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private _handleFocus(): void {
|
|
213
|
+
this._focused = true;
|
|
214
|
+
this.dispatchEvent(new CustomEvent("input-focus", { bubbles: true }));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private _handleBlur(): void {
|
|
218
|
+
this._focused = false;
|
|
219
|
+
this.dispatchEvent(new CustomEvent("input-blur", { bubbles: true }));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Focus the input element
|
|
224
|
+
*/
|
|
225
|
+
focus(): void {
|
|
226
|
+
const input = this.shadowRoot?.querySelector("input");
|
|
227
|
+
input?.focus();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Blur the input element
|
|
232
|
+
*/
|
|
233
|
+
blur(): void {
|
|
234
|
+
const input = this.shadowRoot?.querySelector("input");
|
|
235
|
+
input?.blur();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Select all text in the input
|
|
240
|
+
*/
|
|
241
|
+
select(): void {
|
|
242
|
+
const input = this.shadowRoot?.querySelector("input");
|
|
243
|
+
input?.select();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
render() {
|
|
247
|
+
const hasError = Boolean(this.error || this.errorText);
|
|
248
|
+
|
|
249
|
+
return html`
|
|
250
|
+
<div class="input-wrapper">
|
|
251
|
+
${this.label || this.labelText
|
|
252
|
+
? html`
|
|
253
|
+
<label for="input">
|
|
254
|
+
${this.labelText
|
|
255
|
+
? html`<ds-text .text=${this.labelText}></ds-text>`
|
|
256
|
+
: this.label}
|
|
257
|
+
</label>
|
|
258
|
+
`
|
|
259
|
+
: null}
|
|
260
|
+
|
|
261
|
+
<div class="input-container">
|
|
262
|
+
<input
|
|
263
|
+
id="input"
|
|
264
|
+
.type=${this.type}
|
|
265
|
+
.name=${this.name}
|
|
266
|
+
.value=${this.value}
|
|
267
|
+
.placeholder=${this.placeholder}
|
|
268
|
+
?disabled=${this.disabled}
|
|
269
|
+
?readonly=${this.readonly}
|
|
270
|
+
?required=${this.required}
|
|
271
|
+
?autofocus=${this.autofocus}
|
|
272
|
+
autocomplete=${this.autocomplete}
|
|
273
|
+
pattern=${this.pattern || ""}
|
|
274
|
+
minlength=${this.minlength || ""}
|
|
275
|
+
maxlength=${this.maxlength || ""}
|
|
276
|
+
min=${this.min}
|
|
277
|
+
max=${this.max}
|
|
278
|
+
step=${this.step}
|
|
279
|
+
class=${hasError ? "has-error" : ""}
|
|
280
|
+
@input=${this._handleInput}
|
|
281
|
+
@focus=${this._handleFocus}
|
|
282
|
+
@blur=${this._handleBlur}
|
|
283
|
+
/>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
${hasError
|
|
287
|
+
? html`
|
|
288
|
+
<div class="error-message">
|
|
289
|
+
${this.errorText
|
|
290
|
+
? html`<ds-text .text=${this.errorText}></ds-text>`
|
|
291
|
+
: this.error}
|
|
292
|
+
</div>
|
|
293
|
+
`
|
|
294
|
+
: null}
|
|
295
|
+
</div>
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
customElements.define("ds-input", Input);
|
|
301
|
+
|
|
302
|
+
declare global {
|
|
303
|
+
interface HTMLElementTagNameMap {
|
|
304
|
+
"ds-input": Input;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LitElement, html, unsafeCSS } from "lit";
|
|
2
|
+
import styles from "./styles/ds-pagedots.css?inline";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Page dots indicator component for carousels and pagination.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* - <ds-pagedots count="3" active="0"></ds-pagedots>
|
|
9
|
+
*/
|
|
10
|
+
export class Pagedots extends LitElement {
|
|
11
|
+
static properties = {
|
|
12
|
+
/** Number of dots to display */
|
|
13
|
+
count: { type: Number, reflect: true },
|
|
14
|
+
/** Index of the active dot (0-based) */
|
|
15
|
+
active: { type: Number, reflect: true },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare count: number;
|
|
19
|
+
declare active: number;
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.count = 3;
|
|
24
|
+
this.active = 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static styles = unsafeCSS(styles);
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
const dots = Array.from({ length: this.count }, (_, i) => i);
|
|
31
|
+
return html`
|
|
32
|
+
${dots.map(
|
|
33
|
+
(index) => html`
|
|
34
|
+
<span
|
|
35
|
+
class="dot ${index === this.active ? "active" : ""}"
|
|
36
|
+
role="button"
|
|
37
|
+
aria-label="Slide ${index + 1}"
|
|
38
|
+
aria-current="${index === this.active ? "true" : "false"}"
|
|
39
|
+
></span>
|
|
40
|
+
`
|
|
41
|
+
)}
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
customElements.define("ds-pagedots", Pagedots);
|
|
47
|
+
|
|
48
|
+
declare global {
|
|
49
|
+
interface HTMLElementTagNameMap {
|
|
50
|
+
"ds-pagedots": Pagedots;
|
|
51
|
+
}
|
|
52
|
+
}
|
package/DS1/2-core/ds-text.ts
CHANGED
|
@@ -1,64 +1,58 @@
|
|
|
1
|
-
import { LitElement, html,
|
|
2
|
-
import { getText } from "../0-face/i18n";
|
|
1
|
+
import { LitElement, html, unsafeCSS } from "lit";
|
|
2
|
+
import { getText, currentLanguage } from "../0-face/i18n";
|
|
3
|
+
import styles from "./styles/ds-text.css?inline";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A component for displaying text from translations
|
|
6
7
|
*
|
|
7
8
|
* @element ds-text
|
|
8
|
-
* @prop {string}
|
|
9
|
+
* @prop {string} text - The translation text to use
|
|
9
10
|
* @prop {string} defaultValue - Default value if translation is not found
|
|
10
11
|
* @prop {string} fallback - Optional fallback text if translation is not found (deprecated, use defaultValue)
|
|
11
12
|
*/
|
|
12
13
|
export class Text extends LitElement {
|
|
13
14
|
static get properties() {
|
|
14
15
|
return {
|
|
15
|
-
|
|
16
|
+
text: { type: String, reflect: true },
|
|
16
17
|
defaultValue: { type: String, reflect: true, attribute: "default-value" },
|
|
17
18
|
fallback: { type: String, reflect: true }, // Kept for backward compatibility
|
|
18
19
|
_text: { type: String, state: true },
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
declare
|
|
23
|
+
declare text: string;
|
|
23
24
|
declare defaultValue: string;
|
|
24
25
|
declare fallback: string;
|
|
25
26
|
declare _text: string;
|
|
27
|
+
declare _currentLanguage: string;
|
|
26
28
|
private boundHandlers: { languageChanged: EventListener };
|
|
27
29
|
|
|
28
30
|
constructor() {
|
|
29
31
|
super();
|
|
30
|
-
this.
|
|
32
|
+
this.text = "";
|
|
31
33
|
this.defaultValue = "";
|
|
32
34
|
this.fallback = "";
|
|
33
35
|
this._text = "";
|
|
36
|
+
this._currentLanguage = currentLanguage.value;
|
|
34
37
|
|
|
35
38
|
// Create bound event handlers for proper cleanup
|
|
36
39
|
this.boundHandlers = {
|
|
37
40
|
languageChanged: (() => {
|
|
38
41
|
console.log("Language changed event received in ds-text");
|
|
42
|
+
this._currentLanguage = currentLanguage.value;
|
|
43
|
+
this._updateLanguageAttribute();
|
|
39
44
|
this._loadText();
|
|
45
|
+
this.requestUpdate();
|
|
40
46
|
}) as EventListener,
|
|
41
47
|
};
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
static styles =
|
|
45
|
-
:host {
|
|
46
|
-
display: inline;
|
|
47
|
-
font-family: var(--typeface);
|
|
48
|
-
font-size: calc(var(--type-size-default) * var(--scaling-factor));
|
|
49
|
-
font-weight: var(--type-weight-default);
|
|
50
|
-
line-height: calc(var(--type-lineheight-default) * var(--scaling-factor));
|
|
51
|
-
letter-spacing: calc(
|
|
52
|
-
var(--type-letterspacing-default) * var(--scaling-factor)
|
|
53
|
-
);
|
|
54
|
-
text-align: var(--text-align-default);
|
|
55
|
-
text-transform: var(--text-transform-default);
|
|
56
|
-
text-decoration: var(--text-decoration-default);
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
50
|
+
static styles = unsafeCSS(styles);
|
|
59
51
|
|
|
60
52
|
connectedCallback() {
|
|
61
53
|
super.connectedCallback();
|
|
54
|
+
this._currentLanguage = currentLanguage.value;
|
|
55
|
+
this._updateLanguageAttribute();
|
|
62
56
|
this._loadText();
|
|
63
57
|
|
|
64
58
|
// Listen for language changes
|
|
@@ -92,29 +86,62 @@ export class Text extends LitElement {
|
|
|
92
86
|
updated(changedProperties: Map<string, unknown>) {
|
|
93
87
|
super.updated(changedProperties);
|
|
94
88
|
|
|
95
|
-
if (changedProperties.has("
|
|
89
|
+
if (changedProperties.has("text") || changedProperties.has("defaultValue")) {
|
|
96
90
|
this._loadText();
|
|
97
91
|
}
|
|
98
92
|
}
|
|
99
93
|
|
|
94
|
+
_updateLanguageAttribute() {
|
|
95
|
+
const lang = this._currentLanguage || currentLanguage.value;
|
|
96
|
+
// Handles "ja", "ja-JP", "zh-Hant", "zh-Hans", etc.
|
|
97
|
+
const parts = (lang || "").toLowerCase().split(/[-_]/).filter(Boolean);
|
|
98
|
+
const primaryLang = parts[0] || "";
|
|
99
|
+
|
|
100
|
+
if (primaryLang === "ja") {
|
|
101
|
+
this.setAttribute("data-language", "ja");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (primaryLang === "zh") {
|
|
106
|
+
// Prefer explicit script; otherwise infer from common regions.
|
|
107
|
+
const hasHans =
|
|
108
|
+
parts.includes("hans") || parts.includes("cn") || parts.includes("sg");
|
|
109
|
+
const hasHant =
|
|
110
|
+
parts.includes("hant") ||
|
|
111
|
+
parts.includes("tw") ||
|
|
112
|
+
parts.includes("hk") ||
|
|
113
|
+
parts.includes("mo");
|
|
114
|
+
|
|
115
|
+
if (hasHans) this.setAttribute("data-language", "zh-hans");
|
|
116
|
+
else if (hasHant) this.setAttribute("data-language", "zh-hant");
|
|
117
|
+
else this.setAttribute("data-language", "zh");
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.removeAttribute("data-language");
|
|
122
|
+
}
|
|
123
|
+
|
|
100
124
|
_loadText() {
|
|
101
|
-
if (!this.
|
|
125
|
+
if (!this.text) {
|
|
102
126
|
this._text = this.defaultValue || this.fallback || "";
|
|
127
|
+
this._updateLanguageAttribute();
|
|
128
|
+
this.requestUpdate();
|
|
103
129
|
return;
|
|
104
130
|
}
|
|
105
131
|
|
|
106
132
|
try {
|
|
107
|
-
const
|
|
108
|
-
this._text =
|
|
133
|
+
const translatedText = getText(this.text);
|
|
134
|
+
this._text = translatedText || this.defaultValue || this.fallback || this.text;
|
|
109
135
|
} catch (error) {
|
|
110
|
-
console.error("Error loading text for
|
|
111
|
-
this._text = this.defaultValue || this.fallback || this.
|
|
136
|
+
console.error("Error loading text for text:", this.text, error);
|
|
137
|
+
this._text = this.defaultValue || this.fallback || this.text;
|
|
112
138
|
}
|
|
139
|
+
this._updateLanguageAttribute();
|
|
113
140
|
this.requestUpdate();
|
|
114
141
|
}
|
|
115
142
|
|
|
116
143
|
render() {
|
|
117
|
-
return html`<span>${this._text || this.defaultValue || this.
|
|
144
|
+
return html`<span>${this._text || this.defaultValue || this.text}</span>`;
|
|
118
145
|
}
|
|
119
146
|
}
|
|
120
147
|
|
package/DS1/2-core/ds-tooltip.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { LitElement, html,
|
|
2
|
-
import { translate
|
|
1
|
+
import { LitElement, html, unsafeCSS } from "lit";
|
|
2
|
+
import { translate } from "../0-face/i18n";
|
|
3
|
+
import styles from "./styles/ds-tooltip.css?inline";
|
|
3
4
|
|
|
4
5
|
export class Tooltip extends LitElement {
|
|
5
6
|
static properties = {
|
|
6
|
-
|
|
7
|
+
text: { type: String, reflect: true },
|
|
7
8
|
defaultValue: { type: String, reflect: true, attribute: "default-value" },
|
|
8
9
|
_text: { state: true },
|
|
9
10
|
_visible: { state: true },
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
declare
|
|
13
|
+
declare text: string;
|
|
13
14
|
declare defaultValue: string;
|
|
14
15
|
private _text: string;
|
|
15
16
|
private _visible: boolean;
|
|
@@ -27,7 +28,7 @@ export class Tooltip extends LitElement {
|
|
|
27
28
|
|
|
28
29
|
constructor() {
|
|
29
30
|
super();
|
|
30
|
-
this.
|
|
31
|
+
this.text = "";
|
|
31
32
|
this.defaultValue = "";
|
|
32
33
|
this._text = "";
|
|
33
34
|
this._visible = false;
|
|
@@ -61,54 +62,7 @@ export class Tooltip extends LitElement {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
static styles =
|
|
65
|
-
:host {
|
|
66
|
-
position: relative;
|
|
67
|
-
display: inline-block;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.slot-wrapper {
|
|
71
|
-
display: inline-flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.bubble {
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
position: absolute;
|
|
80
|
-
left: 50%;
|
|
81
|
-
bottom: 100%;
|
|
82
|
-
transform: translate(-50%, calc(-2px * var(--sf)));
|
|
83
|
-
z-index: 1000;
|
|
84
|
-
pointer-events: none;
|
|
85
|
-
height: calc(var(--08) * var(--sf));
|
|
86
|
-
opacity: 0;
|
|
87
|
-
transition:
|
|
88
|
-
opacity 120ms ease,
|
|
89
|
-
transform 120ms ease;
|
|
90
|
-
background-color: light-dark(var(--black), var(--white));
|
|
91
|
-
color: light-dark(var(--white), var(--black));
|
|
92
|
-
border-radius: 0;
|
|
93
|
-
font-size: var(--type-size-default);
|
|
94
|
-
padding: 0px calc(1px * var(--sf));
|
|
95
|
-
font-family: var(
|
|
96
|
-
--typeface,
|
|
97
|
-
-apple-system,
|
|
98
|
-
BlinkMacSystemFont,
|
|
99
|
-
"Segoe UI",
|
|
100
|
-
Roboto,
|
|
101
|
-
sans-serif
|
|
102
|
-
);
|
|
103
|
-
font-weight: 500;
|
|
104
|
-
white-space: nowrap;
|
|
105
|
-
min-width: max-content;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.bubble.visible {
|
|
109
|
-
opacity: 1;
|
|
110
|
-
}
|
|
111
|
-
`;
|
|
65
|
+
static styles = unsafeCSS(styles);
|
|
112
66
|
|
|
113
67
|
connectedCallback(): void {
|
|
114
68
|
super.connectedCallback();
|
|
@@ -147,30 +101,24 @@ export class Tooltip extends LitElement {
|
|
|
147
101
|
}
|
|
148
102
|
|
|
149
103
|
updated(changed: Map<string, unknown>): void {
|
|
150
|
-
if (changed.has("
|
|
104
|
+
if (changed.has("text") || changed.has("defaultValue")) {
|
|
151
105
|
this._loadText();
|
|
152
106
|
}
|
|
153
107
|
}
|
|
154
108
|
|
|
155
|
-
|
|
156
|
-
if (!this.
|
|
109
|
+
_loadText(): void {
|
|
110
|
+
if (!this.text) {
|
|
157
111
|
this._text = this.defaultValue || "";
|
|
158
112
|
this.requestUpdate();
|
|
159
113
|
return;
|
|
160
114
|
}
|
|
161
115
|
|
|
162
116
|
try {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
this._text = notionText;
|
|
166
|
-
this.requestUpdate();
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const t = translate(this.key);
|
|
170
|
-
this._text = t && t !== this.key ? t : this.defaultValue || this.key;
|
|
117
|
+
const t = translate(this.text);
|
|
118
|
+
this._text = t && t !== this.text ? t : this.defaultValue || this.text;
|
|
171
119
|
} catch (err) {
|
|
172
|
-
console.error("ds-tooltip: error loading text for
|
|
173
|
-
this._text = this.defaultValue || this.
|
|
120
|
+
console.error("ds-tooltip: error loading text for text", this.text, err);
|
|
121
|
+
this._text = this.defaultValue || this.text;
|
|
174
122
|
}
|
|
175
123
|
this.requestUpdate();
|
|
176
124
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* ds-banner.css */
|
|
2
|
+
/* Fixed banner component styles for notifications/alerts */
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
display: flex;
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: 0;
|
|
8
|
+
left: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: calc(var(--unit) * var(--sf, 1));
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
padding: 0 calc(var(--unit) * var(--sf, 1));
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
z-index: 9999;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([variant="warning"]) {
|
|
20
|
+
background-color: color-mix(in srgb, var(--yellow) 50%, transparent);
|
|
21
|
+
--banner-text-color: color-mix(in srgb, var(--black) 50%, transparent);
|
|
22
|
+
--banner-action-color: var(--slate);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host([variant="info"]) {
|
|
26
|
+
background-color: rgba(var(--sharp-blue-rgb, 0, 122, 255), 0.7);
|
|
27
|
+
--banner-text-color: var(--white, #fff);
|
|
28
|
+
--banner-action-color: var(--white, #fff);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([variant="success"]) {
|
|
32
|
+
background-color: rgba(var(--apple-green-rgb, 52, 199, 89), 0.7);
|
|
33
|
+
--banner-text-color: var(--white, #fff);
|
|
34
|
+
--banner-action-color: var(--white, #fff);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([variant="error"]) {
|
|
38
|
+
background-color: rgba(var(--tuned-red-rgb, 255, 59, 48), 0.7);
|
|
39
|
+
--banner-text-color: var(--white, #fff);
|
|
40
|
+
--banner-action-color: var(--slate, #1e1e1e);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.text-wrapper {
|
|
44
|
+
flex: 1;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
user-select: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.text-wrapper ds-text,
|
|
50
|
+
.text-wrapper .version {
|
|
51
|
+
color: var(--banner-text-color);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.action-wrapper {
|
|
55
|
+
font-size: calc(12px * var(--sf, 1));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.action-wrapper a {
|
|
59
|
+
color: var(--banner-action-color);
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
font-family: var(--typeface-regular);
|
|
62
|
+
font-size: calc(12px * var(--sf, 1));
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
pointer-events: auto;
|
|
65
|
+
display: inline-block;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.action-wrapper a:hover {
|
|
69
|
+
opacity: 0.8;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.action-wrapper ds-text {
|
|
73
|
+
color: var(--banner-action-color);
|
|
74
|
+
font-family: var(--typeface-regular);
|
|
75
|
+
font-size: calc(12px * var(--sf, 1));
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
}
|