@dxos/lit-ui 0.8.4-main.e098934 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/lit-ui",
3
- "version": "0.8.4-main.e098934",
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,14 +38,14 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@lit/react": "^1.0.5",
42
- "lit": "^3.2.0",
43
- "@dxos/react-hooks": "0.8.4-main.e098934",
44
- "@dxos/react-ui-types": "0.8.4-main.e098934",
45
- "@dxos/util": "0.8.4-main.e098934"
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"
46
46
  },
47
47
  "devDependencies": {
48
- "@dxos/test-utils": "0.8.4-main.e098934"
48
+ "@dxos/test-utils": "0.8.4-main.e8ec1fe"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
@@ -26,7 +26,7 @@ export class DxAnchor extends LitElement {
26
26
  override connectedCallback (): void {
27
27
  super.connectedCallback();
28
28
  this.tabIndex = 0;
29
- this.classList.add('dx-focus-ring');
29
+ this.classList.add(this.getAttribute('data-visible-focus')==='false' ? 'outline-none' : 'dx-focus-ring');
30
30
  if(this.rootclassname){
31
31
  this.classList.add(this.rootclassname);
32
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: { layout: 'fullscreen' },
14
+ parameters: {
15
+ layout: 'centered',
16
+ },
15
17
  };
16
18
 
17
- export const Basic = (props: DxAvatarProps) => {
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`<rect
143
- fill="white"
144
- width=${2 * r}
145
- height=${2 * r}
146
- x=${ringGap + ringWidth}
147
- y=${ringGap + ringWidth}
148
- rx=${rx}
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` <circle
156
- cx="50%"
157
- cy="50%"
158
- r=${r}
159
- fill=${bg}
160
- />`
161
- : svg` <rect
162
- fill=${bg}
163
- x=${ringGap + ringWidth}
164
- y=${ringGap + ringWidth}
165
- width=${2 * r}
166
- height=${2 * r}
167
- rx=${rx}
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`<use
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
- : svg`<text
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
- ${getFirstTwoRenderableChars(this.fallback)}
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`<image
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
@@ -4,5 +4,5 @@
4
4
 
5
5
  export * from './dx-anchor';
6
6
  export * from './dx-avatar';
7
- export * from './dx-tag-picker';
8
7
  export * from './dx-icon';
8
+ export * from './dx-tag-picker';
package/src/react.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  import { type EventName, createComponent } from '@lit/react';
6
6
  import React, { type ComponentPropsWithRef } from 'react';
7
7
 
8
- import { type DxAnchorActivate } from '@dxos/react-ui-types';
8
+ import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui-types';
9
9
 
10
10
  import {
11
11
  type DxTagPickerItemClick,
@@ -20,7 +20,7 @@ export const DxAnchor = createComponent({
20
20
  elementClass: NaturalDxAnchor,
21
21
  react: React,
22
22
  events: {
23
- onActivate: 'dx-anchor-activate' as EventName<DxAnchorActivate>,
23
+ onActivate: DX_ANCHOR_ACTIVATE as EventName<DxAnchorActivate>,
24
24
  },
25
25
  });
26
26