@atomic-ui/ui-vue 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -1,17 +1,44 @@
1
1
  # @atomic-ui/ui-vue
2
2
 
3
- Vue components for the `@atomic-ui/ui` custom elements. Props are bound as DOM properties, and events are typed.
3
+ Vue components for every `@atomic-ui/ui` custom element. Arrays and objects are bound as DOM properties, props and events are typed, and every component and tag is in Vue's `GlobalComponents`.
4
+
5
+ ```sh
6
+ pnpm add @atomic-ui/ui @atomic-ui/ui-vue
7
+ ```
8
+
9
+ Tell Vue's compiler that tags starting with `impkt-` are custom elements, in `vite.config.ts`:
10
+
11
+ ```ts
12
+ vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith('impkt-') } } });
13
+ ```
14
+
15
+ Then import the components where they are used:
4
16
 
5
17
  ```vue
6
18
  <script setup lang="ts">
7
- import '@atomic-ui/ui';
8
- import { ImpktButton, ImpktHeading } from '@atomic-ui/ui-vue';
19
+ import { ref } from 'vue';
20
+ import { ImpktTable, ImpktPagination, ImpktTextInput } from '@atomic-ui/ui-vue';
21
+
22
+ const page = ref(1);
9
23
  </script>
10
24
 
11
25
  <template>
12
- <ImpktHeading :level="1">Your quote</ImpktHeading>
13
- <ImpktButton variant="primary">Continue</ImpktButton>
26
+ <ImpktTextInput label="Search cases" type="search" @change="(e) => (query = e.detail.value)" />
27
+ <ImpktTable caption="Open cases" :columns="columns" :rows="rows" stack selectable @sort="(e) => sortBy(e.detail)" />
28
+ <ImpktPagination :page="page" :pages="9" @page="(e) => (page = e.detail.page)" />
14
29
  </template>
15
30
  ```
16
31
 
17
- Import `@atomic-ui/ui` once, so the custom elements are defined before Vue mounts them.
32
+ Or register them all once with `app.use(AtomicUI)`, and write `<ImpktTable>` anywhere.
33
+
34
+ Importing this package defines the elements, so nothing else needs importing first.
35
+
36
+ ## Names
37
+
38
+ Each component is named after the element's class, so `impkt-table` is `ImpktTable`. Each `impkt-` event is an emit without the prefix: `impkt-change` is `@change`, `impkt-sort` is `@sort` and `impkt-close` is `@close`, and the handler receives the event with its typed `detail`.
39
+
40
+ The components are generated from the component manifest when the package builds, by `scripts/generate.mjs`, so they always match the elements. The components 0.2.0 had keep their names, property bindings and emits.
41
+
42
+ ## Writing the tags
43
+
44
+ A template can also write the tags, such as `<impkt-table :columns="columns" @impkt-sort="sortBy">`. They are typed through `GlobalComponents` as well. Bind arrays and objects with `:` as usual; Vue sets them as properties on a custom element.