@threadlabs/looma 0.13.0 → 0.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",
@@ -49,6 +49,12 @@
49
49
  flex-shrink: 0;
50
50
  }
51
51
 
52
+ :scope[data-ui-avatar-group-state~="size=sm"] .overflow {
53
+ margin-inline-start: -0.25rem;
54
+ inline-size: 1.75rem;
55
+ block-size: 1.75rem;
56
+ }
57
+
52
58
  .overflow[hidden] {
53
59
  display: none;
54
60
  }
@@ -8,6 +8,7 @@ export interface UiAvatarGroupElement extends HTMLDivElement {
8
8
  export interface UiAvatarGroupProps {
9
9
  label?: string | null;
10
10
  max?: number | null;
11
+ size?: "sm" | "md" | null;
11
12
  attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
12
13
  children?: readonly (string | Node)[];
13
14
  slots?: Readonly<Record<string, readonly (string | Node)[]>>;
@@ -3,7 +3,7 @@ import { manageComponentLifecycle } from "@nextwebwg/html-next/runtime";
3
3
  import * as controller from "../components/ui-avatar-group/ui-avatar-group.js";
4
4
  import "../styles/ui-avatar-group.css";
5
5
 
6
- const definition = {...{"contract":{"tag":"ui-avatar-group","props":{"label":{"type":"string","required":false,"target":{"attribute":"aria-label"},"default":"People"},"max":{"type":"number","required":false,"target":{"attribute":"max"},"default":5}}},"template":{"kind":"element","name":"div","attributes":[{"kind":"literal","name":"role","value":"group"},{"kind":"attribute","name":"aria-label","expression":"label","expressionPlan":{"source":"label","ast":{"kind":"id","name":"label"},"dependencies":["label"]}}],"children":[{"kind":"slot"},{"kind":"element","name":"span","attributes":[{"kind":"literal","name":"class","value":"overflow"},{"kind":"literal","name":"role","value":"img"},{"kind":"attribute","name":"hidden","expression":"not overflowCount","expressionPlan":{"source":"not overflowCount","ast":{"kind":"unary","op":"not","operand":{"kind":"id","name":"overflowCount"}},"dependencies":["overflowCount"]}},{"kind":"attribute","name":"aria-label","expression":"format('%s more', overflowCount)","expressionPlan":{"source":"format('%s more', overflowCount)","ast":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"%s more"},{"kind":"id","name":"overflowCount"}]},"dependencies":["overflowCount"]}}],"children":[{"kind":"element","name":"template","attributes":[{"kind":"directive","name":"value","expression":"format('+%s', overflowCount)","expressionPlan":{"source":"format('+%s', overflowCount)","ast":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"+%s"},{"kind":"id","name":"overflowCount"}]},"dependencies":["overflowCount"]}}],"children":[]}],"ref":"overflow"}]},"declarations":[{"kind":"state","name":"overflowCount","expression":{"source":"0","ast":{"kind":"literal","value":0},"dependencies":[]}}],"root":{"kind":"native","element":"div","choices":["div"]}},source:{file:import.meta.url},css:""};
6
+ const definition = {...{"contract":{"tag":"ui-avatar-group","props":{"label":{"type":"string","required":false,"target":{"attribute":"aria-label"},"default":"People"},"max":{"type":"number","required":false,"target":{"attribute":"max"},"default":5},"size":{"type":{"enum":["sm","md"]},"required":false,"target":{"attribute":"size"},"default":"md"}}},"template":{"kind":"element","name":"div","attributes":[{"kind":"literal","name":"role","value":"group"},{"kind":"attribute","name":"aria-label","expression":"label","expressionPlan":{"source":"label","ast":{"kind":"id","name":"label"},"dependencies":["label"]}}],"children":[{"kind":"slot"},{"kind":"element","name":"span","attributes":[{"kind":"literal","name":"class","value":"overflow"},{"kind":"literal","name":"role","value":"img"},{"kind":"attribute","name":"hidden","expression":"not overflowCount","expressionPlan":{"source":"not overflowCount","ast":{"kind":"unary","op":"not","operand":{"kind":"id","name":"overflowCount"}},"dependencies":["overflowCount"]}},{"kind":"attribute","name":"aria-label","expression":"format('%s more', overflowCount)","expressionPlan":{"source":"format('%s more', overflowCount)","ast":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"%s more"},{"kind":"id","name":"overflowCount"}]},"dependencies":["overflowCount"]}}],"children":[{"kind":"element","name":"template","attributes":[{"kind":"directive","name":"value","expression":"format('+%s', overflowCount)","expressionPlan":{"source":"format('+%s', overflowCount)","ast":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"+%s"},{"kind":"id","name":"overflowCount"}]},"dependencies":["overflowCount"]}}],"children":[]}],"ref":"overflow"}]},"declarations":[{"kind":"state","name":"overflowCount","expression":{"source":"0","ast":{"kind":"literal","value":0},"dependencies":[]}}],"root":{"kind":"native","element":"div","choices":["div"]}},source:{file:import.meta.url},css:""};
7
7
 
8
8
  export function createUiAvatarGroup(options = {}) {
9
9
  const { attributes = {}, children = [], slots = {}, as, ...componentProps } = options;
@@ -1,6 +1,7 @@
1
1
  type __VLS_Props = {
2
2
  label?: string;
3
3
  max?: number;
4
+ size?: 'sm' | 'md';
4
5
  };
5
6
  declare var __VLS_1: {};
6
7
  type __VLS_Slots = {} & {
@@ -8,6 +9,7 @@ type __VLS_Slots = {} & {
8
9
  };
9
10
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
11
  label: string;
12
+ size: "sm" | "md";
11
13
  max: number;
12
14
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
15
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,6 +1,6 @@
1
1
  <!-- Generated by HTML Next 1.0.0-alpha.5 for Vue 3.5. Do not edit. -->
2
2
  <script setup lang="ts">
3
- import { ref, useTemplateRef } from 'vue'
3
+ import { computed, ref, useTemplateRef } from 'vue'
4
4
  import * as controllerModule from '../components/ui-avatar-group/ui-avatar-group.js'
5
5
  import { createDispatch, useComponentHost } from './host'
6
6
 
@@ -10,10 +10,12 @@ const props = withDefaults(
10
10
  defineProps<{
11
11
  label?: string
12
12
  max?: number
13
+ size?: 'sm' | 'md'
13
14
  }>(),
14
15
  {
15
16
  label: 'People',
16
17
  max: 5,
18
+ size: 'md',
17
19
  },
18
20
  )
19
21
 
@@ -21,6 +23,13 @@ const root = ref<HTMLElement | null>(null)
21
23
  const overflowElement = useTemplateRef<HTMLElement>('overflow')
22
24
  const overflowCount = ref(0)
23
25
 
26
+ /** The values the styles' :host-state() rules test. */
27
+ const hostState = computed(() =>
28
+ [
29
+ props.size && `size size=${props.size}`,
30
+ ].filter(Boolean).join(' ')
31
+ )
32
+
24
33
  const dispatch = createDispatch(root)
25
34
 
26
35
  useComponentHost(controllerModule.default, {
@@ -33,7 +42,14 @@ useComponentHost(controllerModule.default, {
33
42
  </script>
34
43
 
35
44
  <template>
36
- <div data-component="ui-avatar-group" role="group" v-bind="$attrs" :aria-label="label" ref="root">
45
+ <div
46
+ data-component="ui-avatar-group"
47
+ role="group"
48
+ v-bind="$attrs"
49
+ :aria-label="label"
50
+ :data-ui-avatar-group-state="hostState || undefined"
51
+ ref="root"
52
+ >
37
53
  <slot />
38
54
  <span
39
55
  class="overflow"
@@ -104,6 +120,12 @@ useComponentHost(controllerModule.default, {
104
120
  flex-shrink: 0;
105
121
  }
106
122
 
123
+ [data-component~="ui-avatar-group"][data-ui-avatar-group-state~="size=sm"] .overflow {
124
+ margin-inline-start: -0.25rem;
125
+ inline-size: 1.75rem;
126
+ block-size: 1.75rem;
127
+ }
128
+
107
129
  .overflow[hidden] {
108
130
  display: none;
109
131
  }
@@ -1,9 +1,9 @@
1
1
  import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
2
2
  import { n as useComponentHost, t as createDispatch } from "./host.js";
3
- import { createElementBlock, createElementVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, toDisplayString, useTemplateRef } from "vue";
3
+ import { computed, createElementBlock, createElementVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, toDisplayString, useTemplateRef } from "vue";
4
4
  import * as controllerModule from "@threadlabs/looma/components/ui-avatar-group/ui-avatar-group.js";
5
5
  //#region .build/vue/UiAvatarGroup.vue?vue&type=script&setup=true&lang.ts
6
- var _hoisted_1 = ["aria-label"];
6
+ var _hoisted_1 = ["aria-label", "data-ui-avatar-group-state"];
7
7
  var _hoisted_2 = ["hidden", "aria-label"];
8
8
  //#endregion
9
9
  //#region .build/vue/UiAvatarGroup.vue
@@ -12,13 +12,16 @@ var UiAvatarGroup_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
12
12
  __name: "UiAvatarGroup",
13
13
  props: {
14
14
  label: { default: "People" },
15
- max: { default: 5 }
15
+ max: { default: 5 },
16
+ size: { default: "md" }
16
17
  },
17
18
  setup(__props) {
18
19
  const props = __props;
19
20
  const root = ref(null);
20
21
  const overflowElement = useTemplateRef("overflow");
21
22
  const overflowCount = ref(0);
23
+ /** The values the styles' :host-state() rules test. */
24
+ const hostState = computed(() => [props.size && `size size=${props.size}`].filter(Boolean).join(" "));
22
25
  const dispatch = createDispatch(root);
23
26
  useComponentHost(controllerModule.default, {
24
27
  root,
@@ -33,6 +36,7 @@ var UiAvatarGroup_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
33
36
  role: "group"
34
37
  }, _ctx.$attrs, {
35
38
  "aria-label": __props.label,
39
+ "data-ui-avatar-group-state": hostState.value || void 0,
36
40
  ref_key: "root",
37
41
  ref: root
38
42
  }), [renderSlot(_ctx.$slots, "default"), createElementVNode("span", {
@@ -44,6 +48,6 @@ var UiAvatarGroup_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
44
48
  }, toDisplayString(`+${overflowCount.value}`), 9, _hoisted_2)], 16, _hoisted_1);
45
49
  };
46
50
  }
47
- }), [["__scopeId", "data-v-5e4b76ea"]]);
51
+ }), [["__scopeId", "data-v-c2d41fb1"]]);
48
52
  //#endregion
49
53
  export { UiAvatarGroup_default as t };
@@ -166,7 +166,7 @@
166
166
  syntax: "*";
167
167
  inherits: false;
168
168
  }
169
- [data-component~="ui-avatar-group"][data-v-5e4b76ea] {
169
+ [data-component~="ui-avatar-group"][data-v-c2d41fb1] {
170
170
  /* Hooks do not inherit, so the parts below read them from the root. */
171
171
  --_ui-avatar-group-overlap-shadow: var(--ui-avatar-group-overlap-shadow);
172
172
  --_ui-avatar-group-edge-ring: var(--ui-avatar-group-edge-ring);
@@ -184,15 +184,15 @@
184
184
 
185
185
  /* Overlap and the separating shadow are applied by the controller: slotted avatars are nested
186
186
  * component roots outside this style scope. */
187
- [data-v-5e4b76ea-s] {
187
+ [data-v-c2d41fb1-s] {
188
188
  margin-inline-start: -0.5rem;
189
189
  flex-shrink: 0;
190
190
  border-radius: 999px;
191
191
  }
192
- [data-v-5e4b76ea-s]:first-child {
192
+ [data-v-c2d41fb1-s]:first-child {
193
193
  margin-inline-start: 0;
194
194
  }
195
- .overflow[data-v-5e4b76ea] {
195
+ .overflow[data-v-c2d41fb1] {
196
196
  margin-inline-start: -0.5rem;
197
197
  display: inline-flex;
198
198
  align-items: center;
@@ -211,12 +211,17 @@
211
211
  font-weight: 600;
212
212
  flex-shrink: 0;
213
213
  }
214
- .overflow[hidden][data-v-5e4b76ea] {
214
+ [data-component~="ui-avatar-group"][data-ui-avatar-group-state~="size=sm"] .overflow[data-v-c2d41fb1] {
215
+ margin-inline-start: -0.25rem;
216
+ inline-size: 1.75rem;
217
+ block-size: 1.75rem;
218
+ }
219
+ .overflow[hidden][data-v-c2d41fb1] {
215
220
  display: none;
216
221
  }
217
222
 
218
223
  /* A component that sets its display still honours the hidden attribute on its root. */
219
- [data-component~="ui-avatar-group"][hidden][data-v-5e4b76ea] {
224
+ [data-component~="ui-avatar-group"][hidden][data-v-c2d41fb1] {
220
225
  display: none;
221
226
  }
222
227