@dxos/lit-ui 0.8.4-main.dedc0f3 → 0.8.4-main.ead640a

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.dedc0f3",
3
+ "version": "0.8.4-main.ead640a",
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.5",
42
- "lit": "^3.2.0",
43
- "@dxos/react-hooks": "0.8.4-main.dedc0f3",
44
- "@dxos/util": "0.8.4-main.dedc0f3"
41
+ "@lit/react": "^1.0.8",
42
+ "lit": "^3.3.1",
43
+ "@dxos/react-ui-types": "0.8.4-main.ead640a",
44
+ "@dxos/react-hooks": "0.8.4-main.ead640a",
45
+ "@dxos/util": "0.8.4-main.ead640a"
45
46
  },
46
47
  "devDependencies": {
47
- "@dxos/test-utils": "0.8.4-main.dedc0f3"
48
+ "@dxos/test-utils": "0.8.4-main.ead640a"
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 { html, LitElement } from 'lit';
8
+ import { LitElement } from 'lit';
9
9
  import { customElement, property } from 'lit/decorators.js';
10
10
 
11
- import { makeId } from '@dxos/react-hooks';
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 = makeId('dx-anchor');
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,8 +3,8 @@
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';
@@ -14,6 +14,6 @@ export default {
14
14
  parameters: { layout: 'fullscreen' },
15
15
  };
16
16
 
17
- export const Basic = (props: DxAvatarProps) => {
17
+ export const Basic = (_props: DxAvatarProps) => {
18
18
  return html`<dx-avatar hue="teal" fallback="Composer user" icon="/icons.svg#ph--basketball--regular"></dx-avatar>`;
19
19
  };
@@ -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,44 +140,49 @@ 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
+ : svg`
185
+ <text
180
186
  x="50%"
181
187
  y="50%"
182
188
  class="dx-avatar__fallback-text"
@@ -186,12 +192,13 @@ export class DxAvatar extends LitElement {
186
192
  font-size=${this.size === 'px' ? '200%' : this.size * fontScale}
187
193
  mask=${`url(#${this.maskId})`}
188
194
  >
189
- ${getFirstTwoRenderableChars(this.fallback)}
195
+ ${/\p{Emoji}/u.test(this.fallback) ? this.fallback : getInitials(this.fallback)}
190
196
  </text>`
191
197
  }
192
198
  ${
193
199
  this.imgSrc &&
194
- svg`<image
200
+ svg`
201
+ <image
195
202
  width="100%"
196
203
  height="100%"
197
204
  preserveAspectRatio="xMidYMid slice"
@@ -211,3 +218,17 @@ export class DxAvatar extends LitElement {
211
218
  return this;
212
219
  }
213
220
  }
221
+
222
+ /**
223
+ * Returns the first two renderable characters from a string that are separated by non-word characters.
224
+ * Handles Unicode characters correctly.
225
+ */
226
+ const getInitials = (label = ''): string[] => {
227
+ return label
228
+ .trim()
229
+ .split(/\s+/)
230
+ .map((str) => str.replace(/[^\p{L}\p{N}\s]/gu, ''))
231
+ .filter(Boolean)
232
+ .slice(0, 2)
233
+ .map((word) => word[0].toUpperCase());
234
+ };
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,8 +5,9 @@
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';
9
+
8
10
  import {
9
- type DxAnchorActivate,
10
11
  type DxTagPickerItemClick,
11
12
  DxAnchor as NaturalDxAnchor,
12
13
  DxAvatar as NaturalDxAvatar,