@dxos/lit-ui 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe
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/dist/src/dx-anchor/dx-anchor.d.ts +0 -10
- package/dist/src/dx-anchor/dx-anchor.d.ts.map +1 -1
- package/dist/src/dx-anchor/dx-anchor.js +3 -11
- package/dist/src/dx-anchor/dx-anchor.js.map +1 -1
- package/dist/src/dx-avatar/dx-avatar.d.ts.map +1 -1
- package/dist/src/dx-avatar/dx-avatar.js +48 -27
- package/dist/src/dx-avatar/dx-avatar.js.map +1 -1
- package/dist/src/dx-avatar/dx-avatar.lit-stories.d.ts +1 -1
- package/dist/src/dx-avatar/dx-avatar.lit-stories.d.ts.map +1 -1
- package/dist/src/dx-avatar/dx-avatar.lit-stories.js +4 -2
- package/dist/src/dx-avatar/dx-avatar.lit-stories.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/react.d.ts +2 -1
- package/dist/src/react.d.ts.map +1 -1
- package/dist/src/react.js +2 -1
- package/dist/src/react.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/dx-anchor/dx-anchor.ts +4 -16
- package/src/dx-avatar/dx-avatar.lit-stories.ts +5 -3
- package/src/dx-avatar/dx-avatar.ts +50 -27
- package/src/index.ts +1 -1
- package/src/react.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/lit-ui",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.e8ec1fe",
|
|
4
4
|
"description": "Web Components for DXOS using Lit",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -38,13 +38,14 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@lit/react": "^1.0.
|
|
42
|
-
"lit": "^3.
|
|
43
|
-
"@dxos/react-hooks": "0.8.4-main.
|
|
44
|
-
"@dxos/
|
|
41
|
+
"@lit/react": "^1.0.8",
|
|
42
|
+
"lit": "^3.3.1",
|
|
43
|
+
"@dxos/react-hooks": "0.8.4-main.e8ec1fe",
|
|
44
|
+
"@dxos/react-ui-types": "0.8.4-main.e8ec1fe",
|
|
45
|
+
"@dxos/util": "0.8.4-main.e8ec1fe"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
48
|
+
"@dxos/test-utils": "0.8.4-main.e8ec1fe"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
@@ -5,22 +5,10 @@
|
|
|
5
5
|
// TODO(thure): Find a way to instruct ESLint & Prettier to treat any whitespace between tags rendered in the `html` template function as significant.
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { LitElement } from 'lit';
|
|
9
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
export class DxAnchorActivate extends Event {
|
|
14
|
-
public readonly refId: string;
|
|
15
|
-
public readonly label: string;
|
|
16
|
-
public readonly trigger: DxAnchor;
|
|
17
|
-
constructor(props: { refId: string; label: string; trigger: DxAnchor }) {
|
|
18
|
-
super('dx-anchor-activate');
|
|
19
|
-
this.refId = props.refId;
|
|
20
|
-
this.label = props.label;
|
|
21
|
-
this.trigger = props.trigger;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
11
|
+
import { DxAnchorActivate } from '@dxos/react-ui-types';
|
|
24
12
|
|
|
25
13
|
@customElement('dx-anchor')
|
|
26
14
|
export class DxAnchor extends LitElement {
|
|
@@ -30,7 +18,7 @@ export class DxAnchor extends LitElement {
|
|
|
30
18
|
// should be unnecessary, and it isn’t an issue for `DxAvatar` or `DxGrid`. What’s going on?
|
|
31
19
|
|
|
32
20
|
@property({ type: String })
|
|
33
|
-
refid: string =
|
|
21
|
+
refid: string = '';
|
|
34
22
|
|
|
35
23
|
@property({ type: String })
|
|
36
24
|
rootclassname: string | undefined = undefined;
|
|
@@ -38,7 +26,7 @@ export class DxAnchor extends LitElement {
|
|
|
38
26
|
override connectedCallback (): void {
|
|
39
27
|
super.connectedCallback();
|
|
40
28
|
this.tabIndex = 0;
|
|
41
|
-
this.classList.add('dx-focus-ring');
|
|
29
|
+
this.classList.add(this.getAttribute('data-visible-focus')==='false' ? 'outline-none' : 'dx-focus-ring');
|
|
42
30
|
if(this.rootclassname){
|
|
43
31
|
this.classList.add(this.rootclassname);
|
|
44
32
|
}
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
|
-
|
|
7
6
|
import './dx-avatar.pcss';
|
|
7
|
+
|
|
8
8
|
import { html } from 'lit';
|
|
9
9
|
|
|
10
10
|
import { type DxAvatarProps } from './dx-avatar';
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
13
|
title: 'dx-avatar',
|
|
14
|
-
parameters: {
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: 'centered',
|
|
16
|
+
},
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
export const Basic = (
|
|
19
|
+
export const Basic = (_props: DxAvatarProps) => {
|
|
18
20
|
return html`<dx-avatar hue="teal" fallback="Composer user" icon="/icons.svg#ph--basketball--regular"></dx-avatar>`;
|
|
19
21
|
};
|
|
@@ -7,7 +7,6 @@ import { customElement, property, state } from 'lit/decorators.js';
|
|
|
7
7
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
8
8
|
|
|
9
9
|
import { makeId } from '@dxos/react-hooks';
|
|
10
|
-
import { getFirstTwoRenderableChars } from '@dxos/util';
|
|
11
10
|
|
|
12
11
|
import { type Size } from '../defs';
|
|
13
12
|
|
|
@@ -37,6 +36,7 @@ export type DxAvatarProps = Partial<
|
|
|
37
36
|
>
|
|
38
37
|
>;
|
|
39
38
|
|
|
39
|
+
// TODO(burdon): Needs popover.
|
|
40
40
|
@customElement('dx-avatar')
|
|
41
41
|
export class DxAvatar extends LitElement {
|
|
42
42
|
private maskId: string;
|
|
@@ -120,6 +120,7 @@ export class DxAvatar extends LitElement {
|
|
|
120
120
|
: 'var(--surface-bg)';
|
|
121
121
|
const fg =
|
|
122
122
|
this.hue && this.hueVariant === 'surface' ? `var(--dx-${this.hue}SurfaceText)` : 'var(--dx-accentSurfaceText)';
|
|
123
|
+
|
|
123
124
|
return html`<span
|
|
124
125
|
role="none"
|
|
125
126
|
class=${`dx-avatar${this.rootClassName ? ` ${this.rootClassName}` : ''}`}
|
|
@@ -139,59 +140,67 @@ export class DxAvatar extends LitElement {
|
|
|
139
140
|
${
|
|
140
141
|
this.variant === 'circle'
|
|
141
142
|
? svg`<circle fill="white" cx="50%" cy="50%" r=${r} />`
|
|
142
|
-
: svg
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
: svg`
|
|
144
|
+
<rect
|
|
145
|
+
fill="white"
|
|
146
|
+
width=${2 * r}
|
|
147
|
+
height=${2 * r}
|
|
148
|
+
x=${ringGap + ringWidth}
|
|
149
|
+
y=${ringGap + ringWidth}
|
|
150
|
+
rx=${rx}
|
|
151
|
+
/>`
|
|
150
152
|
}
|
|
151
153
|
</mask>
|
|
152
154
|
</defs>
|
|
153
155
|
${
|
|
154
156
|
this.variant === 'circle'
|
|
155
|
-
? svg`
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
? svg`
|
|
158
|
+
<circle
|
|
159
|
+
cx="50%"
|
|
160
|
+
cy="50%"
|
|
161
|
+
r=${r}
|
|
162
|
+
fill=${bg}
|
|
163
|
+
/>`
|
|
164
|
+
: svg`
|
|
165
|
+
<rect
|
|
166
|
+
fill=${bg}
|
|
167
|
+
x=${ringGap + ringWidth}
|
|
168
|
+
y=${ringGap + ringWidth}
|
|
169
|
+
width=${2 * r}
|
|
170
|
+
height=${2 * r}
|
|
171
|
+
rx=${rx}
|
|
172
|
+
/>`
|
|
169
173
|
}
|
|
170
174
|
${
|
|
171
175
|
this.icon
|
|
172
|
-
? svg
|
|
176
|
+
? svg`
|
|
177
|
+
<use
|
|
173
178
|
class="dx-avatar__icon"
|
|
174
179
|
href=${this.icon}
|
|
175
180
|
x=${sizePx / 5}
|
|
176
181
|
y=${sizePx / 5}
|
|
177
182
|
width=${(3 * sizePx) / 5}
|
|
178
183
|
height=${(3 * sizePx) / 5} />`
|
|
179
|
-
:
|
|
184
|
+
: // NOTE: Firefox currently doesn't fully support alignment-baseline.
|
|
185
|
+
svg`
|
|
186
|
+
<text
|
|
180
187
|
x="50%"
|
|
181
188
|
y="50%"
|
|
182
189
|
class="dx-avatar__fallback-text"
|
|
183
190
|
fill=${fg}
|
|
184
191
|
text-anchor="middle"
|
|
185
192
|
alignment-baseline="central"
|
|
193
|
+
dominant-baseline="middle"
|
|
186
194
|
font-size=${this.size === 'px' ? '200%' : this.size * fontScale}
|
|
187
195
|
mask=${`url(#${this.maskId})`}
|
|
188
196
|
>
|
|
189
|
-
${
|
|
197
|
+
${/\p{Emoji_Presentation}/u.test(this.fallback) ? this.fallback : getInitials(this.fallback)}
|
|
190
198
|
</text>`
|
|
191
199
|
}
|
|
192
200
|
${
|
|
193
201
|
this.imgSrc &&
|
|
194
|
-
svg
|
|
202
|
+
svg`
|
|
203
|
+
<image
|
|
195
204
|
width="100%"
|
|
196
205
|
height="100%"
|
|
197
206
|
preserveAspectRatio="xMidYMid slice"
|
|
@@ -211,3 +220,17 @@ export class DxAvatar extends LitElement {
|
|
|
211
220
|
return this;
|
|
212
221
|
}
|
|
213
222
|
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Returns the first two renderable characters from a string that are separated by non-word characters.
|
|
226
|
+
* Handles Unicode characters correctly.
|
|
227
|
+
*/
|
|
228
|
+
const getInitials = (label = ''): string[] => {
|
|
229
|
+
return label
|
|
230
|
+
.trim()
|
|
231
|
+
.split(/\s+/)
|
|
232
|
+
.map((str) => str.replace(/[^\p{L}\p{N}\s]/gu, ''))
|
|
233
|
+
.filter(Boolean)
|
|
234
|
+
.slice(0, 2)
|
|
235
|
+
.map((word) => word[0].toUpperCase());
|
|
236
|
+
};
|
package/src/index.ts
CHANGED
package/src/react.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import { type EventName, createComponent } from '@lit/react';
|
|
6
6
|
import React, { type ComponentPropsWithRef } from 'react';
|
|
7
7
|
|
|
8
|
+
import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui-types';
|
|
9
|
+
|
|
8
10
|
import {
|
|
9
|
-
type DxAnchorActivate,
|
|
10
11
|
type DxTagPickerItemClick,
|
|
11
12
|
DxAnchor as NaturalDxAnchor,
|
|
12
13
|
DxAvatar as NaturalDxAvatar,
|
|
@@ -19,7 +20,7 @@ export const DxAnchor = createComponent({
|
|
|
19
20
|
elementClass: NaturalDxAnchor,
|
|
20
21
|
react: React,
|
|
21
22
|
events: {
|
|
22
|
-
onActivate:
|
|
23
|
+
onActivate: DX_ANCHOR_ACTIVATE as EventName<DxAnchorActivate>,
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
|