@empathyco/x-components 3.0.0-alpha.340 → 3.0.0-alpha.342
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/CHANGELOG.md +18 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +2 -0
- package/core/index.js.map +1 -1
- package/design-system/full-theme.css +44 -43
- package/docs/API-reference/api/x-components.capitalize.md +3 -3
- package/docs/API-reference/api/x-components.createusedevice.md +34 -0
- package/docs/API-reference/api/x-components.md +4 -0
- package/docs/API-reference/api/x-components.use_x.md +19 -0
- package/docs/API-reference/api/x-components.usedeviceflags.md +13 -0
- package/docs/API-reference/api/x-components.usedevicereturn.md +19 -0
- package/js/composables/create-use-device.composable.js +160 -0
- package/js/composables/create-use-device.composable.js.map +1 -0
- package/js/composables/use-_x.js +15 -0
- package/js/composables/use-_x.js.map +1 -0
- package/js/index.js +2 -0
- package/js/index.js.map +1 -1
- package/js/utils/string.js +1 -1
- package/js/utils/string.js.map +1 -1
- package/package.json +4 -3
- package/report/x-components.api.json +355 -5
- package/report/x-components.api.md +18 -1
- package/types/composables/create-use-device.composable.d.ts +51 -0
- package/types/composables/create-use-device.composable.d.ts.map +1 -0
- package/types/composables/index.d.ts +3 -0
- package/types/composables/index.d.ts.map +1 -0
- package/types/composables/use-$x.d.ts +10 -0
- package/types/composables/use-$x.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/utils/string.d.ts +1 -1
- package/types/utils/string.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.0-alpha.342](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.341...@empathyco/x-components@3.0.0-alpha.342) (2023-03-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @empathyco/x-components
|
|
9
|
+
|
|
10
|
+
# Change Log
|
|
11
|
+
|
|
12
|
+
All notable changes to this project will be documented in this file. See
|
|
13
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
14
|
+
|
|
15
|
+
## [3.0.0-alpha.341](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.340...@empathyco/x-components@3.0.0-alpha.341) (2023-03-30)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @empathyco/x-components
|
|
18
|
+
|
|
19
|
+
# Change Log
|
|
20
|
+
|
|
21
|
+
All notable changes to this project will be documented in this file. See
|
|
22
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
23
|
+
|
|
6
24
|
## [3.0.0-alpha.340](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.339...@empathyco/x-components@3.0.0-alpha.340) (2023-03-29)
|
|
7
25
|
|
|
8
26
|
### Features
|
package/core/index.d.ts
CHANGED
package/core/index.js
CHANGED
|
@@ -146,6 +146,8 @@ export { Getter, State } from '../js/components/decorators/store.decorators.js';
|
|
|
146
146
|
export { ItemsListInjectionMixin } from '../js/components/items-list-injection.mixin.js';
|
|
147
147
|
export { xComponentMixin } from '../js/components/x-component.mixin.js';
|
|
148
148
|
export { getXComponentXModuleName, isXComponent } from '../js/components/x-component.utils.js';
|
|
149
|
+
export { createUseDevice } from '../js/composables/create-use-device.composable.js';
|
|
150
|
+
export { use$x } from '../js/composables/use-_x.js';
|
|
149
151
|
export { infiniteScroll } from '../js/directives/infinite-scroll/infinite-scroll.js';
|
|
150
152
|
export { setupDevtools } from '../js/plugins/devtools/devtools.plugin.js';
|
|
151
153
|
export { bus } from '../js/plugins/x-bus.js';
|
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -4669,49 +4669,6 @@
|
|
|
4669
4669
|
.x-fill--transparent {
|
|
4670
4670
|
fill: var(--x-color-base-transparent) !important;
|
|
4671
4671
|
}
|
|
4672
|
-
.x-flex-1 {
|
|
4673
|
-
flex: 1 1 0% !important;
|
|
4674
|
-
}
|
|
4675
|
-
|
|
4676
|
-
.x-flex-auto {
|
|
4677
|
-
flex: 1 1 auto !important;
|
|
4678
|
-
}
|
|
4679
|
-
|
|
4680
|
-
.x-flex-initial {
|
|
4681
|
-
flex: 0 1 auto !important;
|
|
4682
|
-
}
|
|
4683
|
-
|
|
4684
|
-
.x-flex-no-shrink {
|
|
4685
|
-
flex: 1 0 auto !important;
|
|
4686
|
-
}
|
|
4687
|
-
|
|
4688
|
-
.x-flex-none {
|
|
4689
|
-
flex: none !important;
|
|
4690
|
-
}
|
|
4691
|
-
|
|
4692
|
-
.x-self-auto {
|
|
4693
|
-
align-self: auto !important;
|
|
4694
|
-
}
|
|
4695
|
-
|
|
4696
|
-
.x-self-start {
|
|
4697
|
-
align-self: flex-start !important;
|
|
4698
|
-
}
|
|
4699
|
-
|
|
4700
|
-
.x-self-end {
|
|
4701
|
-
align-self: flex-end !important;
|
|
4702
|
-
}
|
|
4703
|
-
|
|
4704
|
-
.x-self-center {
|
|
4705
|
-
align-self: center !important;
|
|
4706
|
-
}
|
|
4707
|
-
|
|
4708
|
-
.x-self-stretch {
|
|
4709
|
-
align-self: stretch !important;
|
|
4710
|
-
}
|
|
4711
|
-
|
|
4712
|
-
.x-self-baseline {
|
|
4713
|
-
align-self: baseline !important;
|
|
4714
|
-
}
|
|
4715
4672
|
.x-line-clamp--2 {
|
|
4716
4673
|
overflow: hidden !important;
|
|
4717
4674
|
display: -webkit-box !important;
|
|
@@ -5668,3 +5625,47 @@
|
|
|
5668
5625
|
.x-sticky {
|
|
5669
5626
|
position: sticky !important;
|
|
5670
5627
|
}
|
|
5628
|
+
|
|
5629
|
+
.x-flex-1 {
|
|
5630
|
+
flex: 1 1 0% !important;
|
|
5631
|
+
}
|
|
5632
|
+
|
|
5633
|
+
.x-flex-auto {
|
|
5634
|
+
flex: 1 1 auto !important;
|
|
5635
|
+
}
|
|
5636
|
+
|
|
5637
|
+
.x-flex-initial {
|
|
5638
|
+
flex: 0 1 auto !important;
|
|
5639
|
+
}
|
|
5640
|
+
|
|
5641
|
+
.x-flex-no-shrink {
|
|
5642
|
+
flex: 1 0 auto !important;
|
|
5643
|
+
}
|
|
5644
|
+
|
|
5645
|
+
.x-flex-none {
|
|
5646
|
+
flex: none !important;
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5649
|
+
.x-self-auto {
|
|
5650
|
+
align-self: auto !important;
|
|
5651
|
+
}
|
|
5652
|
+
|
|
5653
|
+
.x-self-start {
|
|
5654
|
+
align-self: flex-start !important;
|
|
5655
|
+
}
|
|
5656
|
+
|
|
5657
|
+
.x-self-end {
|
|
5658
|
+
align-self: flex-end !important;
|
|
5659
|
+
}
|
|
5660
|
+
|
|
5661
|
+
.x-self-center {
|
|
5662
|
+
align-self: center !important;
|
|
5663
|
+
}
|
|
5664
|
+
|
|
5665
|
+
.x-self-stretch {
|
|
5666
|
+
align-self: stretch !important;
|
|
5667
|
+
}
|
|
5668
|
+
|
|
5669
|
+
.x-self-baseline {
|
|
5670
|
+
align-self: baseline !important;
|
|
5671
|
+
}
|
|
@@ -9,18 +9,18 @@ Util to capitalize a string .
|
|
|
9
9
|
**Signature:**
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare function capitalize(str:
|
|
12
|
+
export declare function capitalize<StrType extends string>(str: StrType): Capitalize<StrType>;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
16
16
|
|
|
17
17
|
| Parameter | Type | Description |
|
|
18
18
|
| --- | --- | --- |
|
|
19
|
-
| str |
|
|
19
|
+
| str | StrType | String value. |
|
|
20
20
|
|
|
21
21
|
**Returns:**
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Capitalize<StrType>
|
|
24
24
|
|
|
25
25
|
Returns the string capitalized.
|
|
26
26
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [createUseDevice](./x-components.createusedevice.md)
|
|
4
|
+
|
|
5
|
+
## createUseDevice() function
|
|
6
|
+
|
|
7
|
+
Factory function that creates a composable for device detection using the devices parameter to configure breakpoints.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function createUseDevice<Device extends string>(devices: Record<Device, number>): () => UseDeviceReturn<Device>;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| devices | Record<Device, number> | An object containing the breakpoints, where the key is the name of the device and the value is the screen width. |
|
|
20
|
+
|
|
21
|
+
**Returns:**
|
|
22
|
+
|
|
23
|
+
() => [UseDeviceReturn](./x-components.usedevicereturn.md)<!-- --><Device>
|
|
24
|
+
|
|
25
|
+
A composable which provides multiple reactive flags and values for detecting the current device. The flags names depends on the names passed in the `devices` parameter.
|
|
26
|
+
|
|
27
|
+
## Remarks
|
|
28
|
+
|
|
29
|
+
The `orientation` only works for orientation-sensor devices (mobile, tablet, etc). If in a desktop, the height of the window is larger than the width, the orientation will be `landscape`<!-- -->.
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
´´´typescript const useDevice = createUseDevice(<!-- -->{ mobile: 0, tablet: 744, desktop: 1024 }<!-- -->); const { isMobile, isMobileOrLess, isMobileOrGreater, isTablet, isTabletOrLess, isTabletOrGreater, isDesktop, isDesktopOrLess, isDesktopOrGreater, deviceName, orientation, istTouchable } = useDevice();
|
|
34
|
+
|
|
@@ -163,6 +163,7 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
163
163
|
| [createRawFilters(filterIds)](./x-components.createrawfilters.md) | Helper method which creates the filter entity from the filter ir of the url. |
|
|
164
164
|
| [createStoreEmitters(storeModule, emitters)](./x-components.createstoreemitters.md) | Helper function for creating type-safe [StoreEmitters](./x-components.storeemitters.md)<!-- -->. |
|
|
165
165
|
| [createTrackWire(property)](./x-components.createtrackwire.md) | Factory helper to create a wire for the track of a taggable element. |
|
|
166
|
+
| [createUseDevice(devices)](./x-components.createusedevice.md) | Factory function that creates a composable for device detection using the devices parameter to configure breakpoints. |
|
|
166
167
|
| [createWireFromFunction(fn)](./x-components.createwirefromfunction.md) | Creates a wire that executes the function passed. This function will receive a [WireParams](./x-components.wireparams.md) object. |
|
|
167
168
|
| [createWiring(wiring)](./x-components.createwiring.md) | Util function to generate type-safe wiring. If TypeScript ever accepts the PR about generic type inference this function can be removed. |
|
|
168
169
|
| [currencyFormatter(value, format)](./x-components.currencyformatter.md) | Format a value with a given format. |
|
|
@@ -201,6 +202,7 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
201
202
|
| [State(module, path)](./x-components.state.md) | <p>Generates a computed property which returns the selected state.</p><p>The decorated property needs to be public for type inference to work.</p> |
|
|
202
203
|
| [throttle(wire, timeInMs, options)](./x-components.throttle.md) | Creates a throttled [Wire](./x-components.wire.md)<!-- -->. Being throttled means that it will only be executed once every couple of milliseconds given by the <code>timeInMs</code> parameter. |
|
|
203
204
|
| [toKebabCase(str)](./x-components.tokebabcase.md) | Util to transform string a into kebab case. |
|
|
205
|
+
| [use$x()](./x-components.use_x.md) | Function which returns the <code>$x</code> object from the current component instance. |
|
|
204
206
|
| [wireCommit(mutation, payloadFactory)](./x-components.wirecommit.md) | Creates a wire that commits a mutation to the store. This wire receives a function. This function is used to get the actual payload value passed to mutation. This wire can be used in every event, as it does not have a payload type associated. |
|
|
205
207
|
| [wireCommit(mutation, staticPayload)](./x-components.wirecommit_1.md) | Creates a wire that commits a mutation to the store. This wire can receive any value as payload. This wire can be used in every event, as it does not have a payload type associated. |
|
|
206
208
|
| [wireCommit(mutation)](./x-components.wirecommit_2.md) | Creates a wire that commits a mutation to the store. This wire will commit to the store the payload that it receives in the observable. |
|
|
@@ -741,6 +743,8 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
741
743
|
| [UrlParamValue](./x-components.urlparamvalue.md) | The allowed values of the parameters to store in the URL. |
|
|
742
744
|
| [UrlXModule](./x-components.urlxmodule.md) | URL [XModule](./x-components.xmodule.md) alias. |
|
|
743
745
|
| [UrlXStoreModule](./x-components.urlxstoremodule.md) | URL type safe store module. |
|
|
746
|
+
| [UseDeviceFlags](./x-components.usedeviceflags.md) | The device flags type of the Return type of the composable returned by <code>createUseDevice</code>. |
|
|
747
|
+
| [UseDeviceReturn](./x-components.usedevicereturn.md) | The Return type of the composable returned by <code>createUseDevice</code>. |
|
|
744
748
|
| [VueConstructorPartialArgument](./x-components.vueconstructorpartialargument.md) | First parameter of the Vue constructor. |
|
|
745
749
|
| [VueCSSClasses](./x-components.vuecssclasses.md) | Union type containing supported Vue dynamic classes. |
|
|
746
750
|
| [Wire](./x-components.wire.md) | A Wire is a function that receives an observable, the store and the on function of the bus it will run in and returns a subscription. |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [use$x](./x-components.use_x.md)
|
|
4
|
+
|
|
5
|
+
## use$x() function
|
|
6
|
+
|
|
7
|
+
Function which returns the `$x` object from the current component instance.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function use$x(): XComponentAPI;
|
|
13
|
+
```
|
|
14
|
+
**Returns:**
|
|
15
|
+
|
|
16
|
+
[XComponentAPI](./x-components.xcomponentapi.md)
|
|
17
|
+
|
|
18
|
+
The `$x` object from the current component instance.
|
|
19
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [UseDeviceFlags](./x-components.usedeviceflags.md)
|
|
4
|
+
|
|
5
|
+
## UseDeviceFlags type
|
|
6
|
+
|
|
7
|
+
The device flags type of the Return type of the composable returned by `createUseDevice`<!-- -->.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export type UseDeviceFlags<Device extends string> = Record<`is${Capitalize<Device>}`, Ref<boolean>> & Record<`is${Capitalize<Device>}OrGreater`, Ref<boolean>> & Record<`is${Capitalize<Device>}OrLess`, Ref<boolean>>;
|
|
13
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [UseDeviceReturn](./x-components.usedevicereturn.md)
|
|
4
|
+
|
|
5
|
+
## UseDeviceReturn type
|
|
6
|
+
|
|
7
|
+
The Return type of the composable returned by `createUseDevice`<!-- -->.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export type UseDeviceReturn<Device extends string = string> = {
|
|
13
|
+
orientation: Ref<'landscape' | 'portrait' | undefined>;
|
|
14
|
+
isTouchable: Ref<boolean>;
|
|
15
|
+
deviceName: Ref<string>;
|
|
16
|
+
} & UseDeviceFlags<Device>;
|
|
17
|
+
```
|
|
18
|
+
**References:** [UseDeviceFlags](./x-components.usedeviceflags.md)
|
|
19
|
+
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { reduce } from '@empathyco/x-utils';
|
|
2
|
+
import { useMemoize, useWindowSize, useScreenOrientation, useEventListener } from '@vueuse/core';
|
|
3
|
+
import { effectScope, computed, ref } from 'vue';
|
|
4
|
+
import { capitalize } from '../utils/string.js';
|
|
5
|
+
import '../utils/storage.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Factory function that creates a composable for device detection using the devices parameter
|
|
9
|
+
* to configure breakpoints.
|
|
10
|
+
*
|
|
11
|
+
* @param devices - An object containing the breakpoints, where the key is the name of the device
|
|
12
|
+
* and the value is the screen width.
|
|
13
|
+
* @returns A composable which provides multiple reactive flags and values for detecting the
|
|
14
|
+
* current device. The flags names depends on the names passed in the `devices` parameter.
|
|
15
|
+
* @remarks The `orientation` only works for orientation-sensor devices (mobile, tablet, etc). If
|
|
16
|
+
* in a desktop, the height of the window is larger than the width, the orientation will be
|
|
17
|
+
* `landscape`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ´´´typescript
|
|
21
|
+
* const useDevice = createUseDevice(\{ mobile: 0, tablet: 744, desktop: 1024 \});
|
|
22
|
+
* const \{
|
|
23
|
+
* isMobile,
|
|
24
|
+
* isMobileOrLess,
|
|
25
|
+
* isMobileOrGreater,
|
|
26
|
+
* isTablet,
|
|
27
|
+
* isTabletOrLess,
|
|
28
|
+
* isTabletOrGreater,
|
|
29
|
+
* isDesktop,
|
|
30
|
+
* isDesktopOrLess,
|
|
31
|
+
* isDesktopOrGreater,
|
|
32
|
+
* deviceName,
|
|
33
|
+
* orientation,
|
|
34
|
+
* istTouchable
|
|
35
|
+
* \} = useDevice();
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
function createUseDevice(devices) {
|
|
40
|
+
let devicesFlags;
|
|
41
|
+
let orientation;
|
|
42
|
+
let isTouchable;
|
|
43
|
+
let deviceName;
|
|
44
|
+
// The `effectScope` group all the changes in one to avoid multiple re-renderings.
|
|
45
|
+
const scope = effectScope();
|
|
46
|
+
scope.run(() => {
|
|
47
|
+
devicesFlags = getDeviceFlags(devices);
|
|
48
|
+
orientation = getOrientation();
|
|
49
|
+
isTouchable = getIsTouchable();
|
|
50
|
+
deviceName = getDeviceName(devices, devicesFlags);
|
|
51
|
+
});
|
|
52
|
+
return () => ({
|
|
53
|
+
...devicesFlags,
|
|
54
|
+
orientation,
|
|
55
|
+
isTouchable,
|
|
56
|
+
deviceName
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A function that returns reactive flags to detect the current device based on provided
|
|
61
|
+
* breakpoints.
|
|
62
|
+
*
|
|
63
|
+
* @param devices - An object containing the breakpoints, where the key is the name of the device
|
|
64
|
+
* and the value is the screen width.
|
|
65
|
+
* @returns A object containing the multiple reactive flags.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
function getDeviceFlags(devices) {
|
|
70
|
+
const { width: windowSize } = useWindowSize();
|
|
71
|
+
return reduce(devices, (accumulator, device, deviceWidth) => {
|
|
72
|
+
const isDevice = computed(() => isCurrentDevice(device, devices, windowSize.value));
|
|
73
|
+
accumulator[`is${capitalize(device)}`] = isDevice;
|
|
74
|
+
accumulator[`is${capitalize(device)}OrLess`] = computed(() => deviceWidth >= windowSize.value || isDevice.value);
|
|
75
|
+
accumulator[`is${capitalize(device)}OrGreater`] = computed(() => deviceWidth <= windowSize.value);
|
|
76
|
+
return accumulator;
|
|
77
|
+
}, {});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* To get the devices sorted by size and not run this calculation on every check.
|
|
81
|
+
*/
|
|
82
|
+
const getSortedByWidthDevices = useMemoize((devices) => Object.entries(devices).sort(([, aWidth], [, bWidth]) => bWidth - aWidth));
|
|
83
|
+
/**
|
|
84
|
+
* Checks if the current device satisfies the criteria of being a valid device.
|
|
85
|
+
*
|
|
86
|
+
* @param device - The name of the current device.
|
|
87
|
+
* @param devices - An object containing device names and their
|
|
88
|
+
* respective widths.
|
|
89
|
+
* @param windowSize - The width of the window.
|
|
90
|
+
* @returns A boolean value indicating whether the current device satisfies the
|
|
91
|
+
* criteria of being a valid device.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
function isCurrentDevice(device, devices, windowSize) {
|
|
96
|
+
const deviceWidth = devices[device];
|
|
97
|
+
return (deviceWidth <= windowSize &&
|
|
98
|
+
!getSortedByWidthDevices(devices).some(([, otherDeviceWidth]) => otherDeviceWidth <= windowSize && otherDeviceWidth > deviceWidth));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A function that returns the current device orientation as a reactive value.
|
|
102
|
+
*
|
|
103
|
+
* @returns A reactive value indicating the current device
|
|
104
|
+
* orientation.
|
|
105
|
+
*
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
function getOrientation() {
|
|
109
|
+
const { orientation } = useScreenOrientation();
|
|
110
|
+
return computed(() => orientation.value?.includes('landscape')
|
|
111
|
+
? 'landscape'
|
|
112
|
+
: orientation.value?.includes('portrait')
|
|
113
|
+
? 'portrait'
|
|
114
|
+
: undefined);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A function that returns a reactive boolean indicating whether the current device is
|
|
118
|
+
* touch-enabled.
|
|
119
|
+
*
|
|
120
|
+
* @returns A reactive boolean indicating whether the current device is touch-enabled.
|
|
121
|
+
*
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
function getIsTouchable() {
|
|
125
|
+
const isTouchableRef = ref(detectTouchable());
|
|
126
|
+
if (window) {
|
|
127
|
+
useEventListener(window, 'resize', () => (isTouchableRef.value = detectTouchable()), {
|
|
128
|
+
passive: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return isTouchableRef;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A function that returns a reactive string indicating the name of the currently detected device
|
|
135
|
+
* based on the provided devices and device flags.
|
|
136
|
+
*
|
|
137
|
+
* @param devices - An object containing the breakpoints, where the key is the name of the device
|
|
138
|
+
* and the value is the screen width.
|
|
139
|
+
* @param devicesFlags - An object containing multiple reactive flags and values for detecting
|
|
140
|
+
* the current device.
|
|
141
|
+
* @returns A reactive string indicating the name of the currently detected device.
|
|
142
|
+
*
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
function getDeviceName(devices, devicesFlags) {
|
|
146
|
+
return computed(() => Object.keys(devices).find(device => devicesFlags[`is${capitalize(device)}`]?.value) ?? '');
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A utility function that detects whether the current device is touch-enabled.
|
|
150
|
+
*
|
|
151
|
+
* @returns A boolean indicating whether the current device is touch-enabled.
|
|
152
|
+
*
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
function detectTouchable() {
|
|
156
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { createUseDevice };
|
|
160
|
+
//# sourceMappingURL=create-use-device.composable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-use-device.composable.js","sources":["../../../src/composables/create-use-device.composable.ts"],"sourcesContent":["import { reduce } from '@empathyco/x-utils';\nimport { useWindowSize, useScreenOrientation, useEventListener, useMemoize } from '@vueuse/core';\nimport { computed, effectScope, ref, Ref } from 'vue';\nimport { capitalize } from '../utils';\n\n/**\n * The Return type of the composable returned by `createUseDevice`.\n *\n * @public\n */\nexport type UseDeviceReturn<Device extends string = string> = {\n orientation: Ref<'landscape' | 'portrait' | undefined>;\n isTouchable: Ref<boolean>;\n deviceName: Ref<string>;\n} & UseDeviceFlags<Device>;\n\n/**\n * The device flags type of the Return type of the composable returned by `createUseDevice`.\n *\n * @public\n */\nexport type UseDeviceFlags<Device extends string> = Record<\n `is${Capitalize<Device>}`,\n Ref<boolean>\n> &\n Record<`is${Capitalize<Device>}OrGreater`, Ref<boolean>> &\n Record<`is${Capitalize<Device>}OrLess`, Ref<boolean>>;\n\n/**\n * Factory function that creates a composable for device detection using the devices parameter\n * to configure breakpoints.\n *\n * @param devices - An object containing the breakpoints, where the key is the name of the device\n * and the value is the screen width.\n * @returns A composable which provides multiple reactive flags and values for detecting the\n * current device. The flags names depends on the names passed in the `devices` parameter.\n * @remarks The `orientation` only works for orientation-sensor devices (mobile, tablet, etc). If\n * in a desktop, the height of the window is larger than the width, the orientation will be\n * `landscape`.\n *\n * @example\n * ´´´typescript\n * const useDevice = createUseDevice(\\{ mobile: 0, tablet: 744, desktop: 1024 \\});\n * const \\{\n * isMobile,\n * isMobileOrLess,\n * isMobileOrGreater,\n * isTablet,\n * isTabletOrLess,\n * isTabletOrGreater,\n * isDesktop,\n * isDesktopOrLess,\n * isDesktopOrGreater,\n * deviceName,\n * orientation,\n * istTouchable\n * \\} = useDevice();\n *\n * @public\n */\nexport function createUseDevice<Device extends string>(\n devices: Record<Device, number>\n): () => UseDeviceReturn<Device> {\n let devicesFlags: UseDeviceFlags<Device>;\n let orientation: UseDeviceReturn['orientation'];\n let isTouchable: UseDeviceReturn['isTouchable'];\n let deviceName: UseDeviceReturn['deviceName'];\n // The `effectScope` group all the changes in one to avoid multiple re-renderings.\n const scope = effectScope();\n scope.run(() => {\n devicesFlags = getDeviceFlags(devices);\n orientation = getOrientation();\n isTouchable = getIsTouchable();\n deviceName = getDeviceName(devices, devicesFlags);\n });\n return () => ({\n ...devicesFlags,\n orientation,\n isTouchable,\n deviceName\n });\n}\n\n/**\n * A function that returns reactive flags to detect the current device based on provided\n * breakpoints.\n *\n * @param devices - An object containing the breakpoints, where the key is the name of the device\n * and the value is the screen width.\n * @returns A object containing the multiple reactive flags.\n *\n * @internal\n */\nfunction getDeviceFlags<Device extends string>(\n devices: Record<Device, number>\n): UseDeviceFlags<Device> {\n const { width: windowSize } = useWindowSize();\n return reduce(\n devices,\n (accumulator, device, deviceWidth) => {\n const isDevice = computed(() => isCurrentDevice(device, devices, windowSize.value));\n accumulator[`is${capitalize(device)}`] = isDevice;\n accumulator[`is${capitalize(device)}OrLess`] = computed(\n () => deviceWidth >= windowSize.value || isDevice.value\n );\n accumulator[`is${capitalize(device)}OrGreater`] = computed(\n () => deviceWidth <= windowSize.value\n );\n return accumulator;\n },\n {} as Record<string, Ref<boolean>>\n );\n}\n\n/**\n * To get the devices sorted by size and not run this calculation on every check.\n */\nconst getSortedByWidthDevices = useMemoize((devices: Record<string, number>) =>\n Object.entries(devices).sort(([, aWidth], [, bWidth]) => bWidth - aWidth)\n);\n\n/**\n * Checks if the current device satisfies the criteria of being a valid device.\n *\n * @param device - The name of the current device.\n * @param devices - An object containing device names and their\n * respective widths.\n * @param windowSize - The width of the window.\n * @returns A boolean value indicating whether the current device satisfies the\n * criteria of being a valid device.\n *\n * @internal\n */\nfunction isCurrentDevice(\n device: string,\n devices: Record<string, number>,\n windowSize: number\n): boolean {\n const deviceWidth = devices[device];\n return (\n deviceWidth <= windowSize &&\n !getSortedByWidthDevices(devices).some(\n ([, otherDeviceWidth]) => otherDeviceWidth <= windowSize && otherDeviceWidth > deviceWidth\n )\n );\n}\n\n/**\n * A function that returns the current device orientation as a reactive value.\n *\n * @returns A reactive value indicating the current device\n * orientation.\n *\n * @internal\n */\nfunction getOrientation(): UseDeviceReturn['orientation'] {\n const { orientation } = useScreenOrientation();\n return computed(() =>\n orientation.value?.includes('landscape')\n ? 'landscape'\n : orientation.value?.includes('portrait')\n ? 'portrait'\n : undefined\n );\n}\n\n/**\n * A function that returns a reactive boolean indicating whether the current device is\n * touch-enabled.\n *\n * @returns A reactive boolean indicating whether the current device is touch-enabled.\n *\n * @internal\n */\nfunction getIsTouchable(): Ref<boolean> {\n const isTouchableRef = ref(detectTouchable());\n if (window) {\n useEventListener(window, 'resize', () => (isTouchableRef.value = detectTouchable()), {\n passive: true\n });\n }\n return isTouchableRef;\n}\n\n/**\n * A function that returns a reactive string indicating the name of the currently detected device\n * based on the provided devices and device flags.\n *\n * @param devices - An object containing the breakpoints, where the key is the name of the device\n * and the value is the screen width.\n * @param devicesFlags - An object containing multiple reactive flags and values for detecting\n * the current device.\n * @returns A reactive string indicating the name of the currently detected device.\n *\n * @internal\n */\nfunction getDeviceName(\n devices: Record<string, number>,\n devicesFlags: UseDeviceFlags<string>\n): Ref<string> {\n return computed(\n () => Object.keys(devices).find(device => devicesFlags[`is${capitalize(device)}`]?.value) ?? ''\n );\n}\n\n/**\n * A utility function that detects whether the current device is touch-enabled.\n *\n * @returns A boolean indicating whether the current device is touch-enabled.\n *\n * @internal\n */\nfunction detectTouchable(): boolean {\n return 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getCurrentInstance } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Function which returns the `$x` object from the current component instance.
|
|
5
|
+
*
|
|
6
|
+
* @returns The `$x` object from the current component instance.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
function use$x() {
|
|
11
|
+
return (getCurrentInstance()?.proxy).$x;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { use$x };
|
|
15
|
+
//# sourceMappingURL=use-_x.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-_x.js","sources":["../../../src/composables/use-$x.ts"],"sourcesContent":["import { getCurrentInstance } from 'vue';\nimport { XComponentAPI } from '../plugins';\n\n/**\n * Function which returns the `$x` object from the current component instance.\n *\n * @returns The `$x` object from the current component instance.\n *\n * @public\n */\nexport function use$x(): XComponentAPI {\n return (getCurrentInstance()?.proxy as unknown as { $x: XComponentAPI }).$x;\n}\n"],"names":[],"mappings":";;AAGA;;;;;;AAMG;SACa,KAAK,GAAA;IACnB,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAA0C,EAAC,EAAE,CAAC;AAC9E;;;;"}
|
package/js/index.js
CHANGED
|
@@ -146,6 +146,8 @@ export { Getter, State } from './components/decorators/store.decorators.js';
|
|
|
146
146
|
export { ItemsListInjectionMixin } from './components/items-list-injection.mixin.js';
|
|
147
147
|
export { xComponentMixin } from './components/x-component.mixin.js';
|
|
148
148
|
export { getXComponentXModuleName, isXComponent } from './components/x-component.utils.js';
|
|
149
|
+
export { createUseDevice } from './composables/create-use-device.composable.js';
|
|
150
|
+
export { use$x } from './composables/use-_x.js';
|
|
149
151
|
export { infiniteScroll } from './directives/infinite-scroll/infinite-scroll.js';
|
|
150
152
|
export { setupDevtools } from './plugins/devtools/devtools.plugin.js';
|
|
151
153
|
export { bus } from './plugins/x-bus.js';
|
package/js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/js/utils/string.js
CHANGED
package/js/utils/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sources":["../../../src/utils/string.ts"],"sourcesContent":["/**\n * Util used to return true if the string is empty, undefined or null.\n *\n * @param str - String value.\n * @returns Returns true if str is an empty string, undefined or null.\n * @public\n */\nexport function isStringEmpty(str?: string | null): boolean {\n return !str || str.length === 0;\n}\n\n/**\n * Util to transform string a into kebab case.\n *\n * @example\n * Transforms `camelCase` into `camel-case`\n * Transforms `PascalCase` into `pascal-case`\n * Transforms `snake_case` into `snake-case`\n * Transforms `space space multispaces` into `space-space-multiplespaces`\n * Transforms `kebab-case` into `kebab-case`\n *\n * @param str - String value.\n * @returns Returns the string in kebab case.\n * @public\n */\nexport function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/\\s+|_/g, '-')\n .toLowerCase();\n}\n\n/**\n * Util to capitalize a string .\n *\n * @example\n * Transforms `query` into `Query`\n *\n * @param str - String value.\n *\n * @returns Returns the string capitalized.\n *\n * @public\n */\nexport function capitalize(str:
|
|
1
|
+
{"version":3,"file":"string.js","sources":["../../../src/utils/string.ts"],"sourcesContent":["/**\n * Util used to return true if the string is empty, undefined or null.\n *\n * @param str - String value.\n * @returns Returns true if str is an empty string, undefined or null.\n * @public\n */\nexport function isStringEmpty(str?: string | null): boolean {\n return !str || str.length === 0;\n}\n\n/**\n * Util to transform string a into kebab case.\n *\n * @example\n * Transforms `camelCase` into `camel-case`\n * Transforms `PascalCase` into `pascal-case`\n * Transforms `snake_case` into `snake-case`\n * Transforms `space space multispaces` into `space-space-multiplespaces`\n * Transforms `kebab-case` into `kebab-case`\n *\n * @param str - String value.\n * @returns Returns the string in kebab case.\n * @public\n */\nexport function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/\\s+|_/g, '-')\n .toLowerCase();\n}\n\n/**\n * Util to capitalize a string .\n *\n * @example\n * Transforms `query` into `Query`\n *\n * @param str - String value.\n *\n * @returns Returns the string capitalized.\n *\n * @public\n */\nexport function capitalize<StrType extends string>(str: StrType): Capitalize<StrType> {\n return (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<StrType>;\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACG,SAAU,aAAa,CAAC,GAAmB,EAAA;IAC/C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;AAaG;AACG,SAAU,WAAW,CAAC,GAAW,EAAA;AACrC,IAAA,OAAO,GAAG;AACP,SAAA,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;AACnC,SAAA,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;AACtB,SAAA,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;AAWG;AACG,SAAU,UAAU,CAAyB,GAAY,EAAA;AAC7D,IAAA,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAyB;AAC7E;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-components",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.342",
|
|
4
4
|
"description": "Empathy X Components",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@badeball/cypress-cucumber-preprocessor": "~15.0.0",
|
|
92
92
|
"@bahmutov/cypress-esbuild-preprocessor": "~2.2.0",
|
|
93
93
|
"@cypress/vue2": "~2.0.1",
|
|
94
|
-
"@empathyco/x-tailwindcss": "^1.0.0-alpha.
|
|
94
|
+
"@empathyco/x-tailwindcss": "^1.0.0-alpha.20",
|
|
95
95
|
"@microsoft/api-documenter": "~7.21.3",
|
|
96
96
|
"@microsoft/api-extractor": "~7.33.7",
|
|
97
97
|
"@rollup/plugin-commonjs": "~24.0.0",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"@vue/cli-service": "~5.0.4",
|
|
108
108
|
"@vue/test-utils": "~1.0.3",
|
|
109
109
|
"@vue/vue2-jest": "~27.0.0-alpha.3",
|
|
110
|
+
"@vueuse/core": "~9.13.0",
|
|
110
111
|
"autoprefixer": "~10.4.4",
|
|
111
112
|
"convert-source-map": "~2.0.0",
|
|
112
113
|
"cypress": "~12.8.0",
|
|
@@ -142,5 +143,5 @@
|
|
|
142
143
|
"access": "public",
|
|
143
144
|
"directory": "dist"
|
|
144
145
|
},
|
|
145
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "c11db7863eb13f5bbcd11a79a27aef9db323ef32"
|
|
146
147
|
}
|
|
@@ -8069,19 +8069,32 @@
|
|
|
8069
8069
|
"excerptTokens": [
|
|
8070
8070
|
{
|
|
8071
8071
|
"kind": "Content",
|
|
8072
|
-
"text": "export declare function capitalize
|
|
8072
|
+
"text": "export declare function capitalize<StrType extends "
|
|
8073
8073
|
},
|
|
8074
8074
|
{
|
|
8075
8075
|
"kind": "Content",
|
|
8076
8076
|
"text": "string"
|
|
8077
8077
|
},
|
|
8078
|
+
{
|
|
8079
|
+
"kind": "Content",
|
|
8080
|
+
"text": ">(str: "
|
|
8081
|
+
},
|
|
8082
|
+
{
|
|
8083
|
+
"kind": "Content",
|
|
8084
|
+
"text": "StrType"
|
|
8085
|
+
},
|
|
8078
8086
|
{
|
|
8079
8087
|
"kind": "Content",
|
|
8080
8088
|
"text": "): "
|
|
8081
8089
|
},
|
|
8090
|
+
{
|
|
8091
|
+
"kind": "Reference",
|
|
8092
|
+
"text": "Capitalize",
|
|
8093
|
+
"canonicalReference": "!Capitalize:type"
|
|
8094
|
+
},
|
|
8082
8095
|
{
|
|
8083
8096
|
"kind": "Content",
|
|
8084
|
-
"text": "
|
|
8097
|
+
"text": "<StrType>"
|
|
8085
8098
|
},
|
|
8086
8099
|
{
|
|
8087
8100
|
"kind": "Content",
|
|
@@ -8090,8 +8103,8 @@
|
|
|
8090
8103
|
],
|
|
8091
8104
|
"fileUrlPath": "src/utils/string.ts",
|
|
8092
8105
|
"returnTypeTokenRange": {
|
|
8093
|
-
"startIndex":
|
|
8094
|
-
"endIndex":
|
|
8106
|
+
"startIndex": 5,
|
|
8107
|
+
"endIndex": 7
|
|
8095
8108
|
},
|
|
8096
8109
|
"releaseTag": "Public",
|
|
8097
8110
|
"overloadIndex": 1,
|
|
@@ -8099,10 +8112,23 @@
|
|
|
8099
8112
|
{
|
|
8100
8113
|
"parameterName": "str",
|
|
8101
8114
|
"parameterTypeTokenRange": {
|
|
8115
|
+
"startIndex": 3,
|
|
8116
|
+
"endIndex": 4
|
|
8117
|
+
},
|
|
8118
|
+
"isOptional": false
|
|
8119
|
+
}
|
|
8120
|
+
],
|
|
8121
|
+
"typeParameters": [
|
|
8122
|
+
{
|
|
8123
|
+
"typeParameterName": "StrType",
|
|
8124
|
+
"constraintTokenRange": {
|
|
8102
8125
|
"startIndex": 1,
|
|
8103
8126
|
"endIndex": 2
|
|
8104
8127
|
},
|
|
8105
|
-
"
|
|
8128
|
+
"defaultTypeTokenRange": {
|
|
8129
|
+
"startIndex": 0,
|
|
8130
|
+
"endIndex": 0
|
|
8131
|
+
}
|
|
8106
8132
|
}
|
|
8107
8133
|
],
|
|
8108
8134
|
"name": "capitalize"
|
|
@@ -9669,6 +9695,86 @@
|
|
|
9669
9695
|
],
|
|
9670
9696
|
"name": "createTrackWire"
|
|
9671
9697
|
},
|
|
9698
|
+
{
|
|
9699
|
+
"kind": "Function",
|
|
9700
|
+
"canonicalReference": "@empathyco/x-components!createUseDevice:function(1)",
|
|
9701
|
+
"docComment": "/**\n * Factory function that creates a composable for device detection using the devices parameter to configure breakpoints.\n *\n * @remarks\n *\n * The `orientation` only works for orientation-sensor devices (mobile, tablet, etc). If in a desktop, the height of the window is larger than the width, the orientation will be `landscape`.\n *\n * @param devices - An object containing the breakpoints, where the key is the name of the device and the value is the screen width.\n *\n * @returns A composable which provides multiple reactive flags and values for detecting the current device. The flags names depends on the names passed in the `devices` parameter.\n *\n * @example\n *\n * ´´´typescript const useDevice = createUseDevice(\\{ mobile: 0, tablet: 744, desktop: 1024 \\}); const \\{ isMobile, isMobileOrLess, isMobileOrGreater, isTablet, isTabletOrLess, isTabletOrGreater, isDesktop, isDesktopOrLess, isDesktopOrGreater, deviceName, orientation, istTouchable \\} = useDevice();\n *\n * @public\n */\n",
|
|
9702
|
+
"excerptTokens": [
|
|
9703
|
+
{
|
|
9704
|
+
"kind": "Content",
|
|
9705
|
+
"text": "export declare function createUseDevice<Device extends "
|
|
9706
|
+
},
|
|
9707
|
+
{
|
|
9708
|
+
"kind": "Content",
|
|
9709
|
+
"text": "string"
|
|
9710
|
+
},
|
|
9711
|
+
{
|
|
9712
|
+
"kind": "Content",
|
|
9713
|
+
"text": ">(devices: "
|
|
9714
|
+
},
|
|
9715
|
+
{
|
|
9716
|
+
"kind": "Reference",
|
|
9717
|
+
"text": "Record",
|
|
9718
|
+
"canonicalReference": "!Record:type"
|
|
9719
|
+
},
|
|
9720
|
+
{
|
|
9721
|
+
"kind": "Content",
|
|
9722
|
+
"text": "<Device, number>"
|
|
9723
|
+
},
|
|
9724
|
+
{
|
|
9725
|
+
"kind": "Content",
|
|
9726
|
+
"text": "): "
|
|
9727
|
+
},
|
|
9728
|
+
{
|
|
9729
|
+
"kind": "Content",
|
|
9730
|
+
"text": "() => "
|
|
9731
|
+
},
|
|
9732
|
+
{
|
|
9733
|
+
"kind": "Reference",
|
|
9734
|
+
"text": "UseDeviceReturn",
|
|
9735
|
+
"canonicalReference": "@empathyco/x-components!UseDeviceReturn:type"
|
|
9736
|
+
},
|
|
9737
|
+
{
|
|
9738
|
+
"kind": "Content",
|
|
9739
|
+
"text": "<Device>"
|
|
9740
|
+
},
|
|
9741
|
+
{
|
|
9742
|
+
"kind": "Content",
|
|
9743
|
+
"text": ";"
|
|
9744
|
+
}
|
|
9745
|
+
],
|
|
9746
|
+
"fileUrlPath": "src/composables/create-use-device.composable.ts",
|
|
9747
|
+
"returnTypeTokenRange": {
|
|
9748
|
+
"startIndex": 6,
|
|
9749
|
+
"endIndex": 9
|
|
9750
|
+
},
|
|
9751
|
+
"releaseTag": "Public",
|
|
9752
|
+
"overloadIndex": 1,
|
|
9753
|
+
"parameters": [
|
|
9754
|
+
{
|
|
9755
|
+
"parameterName": "devices",
|
|
9756
|
+
"parameterTypeTokenRange": {
|
|
9757
|
+
"startIndex": 3,
|
|
9758
|
+
"endIndex": 5
|
|
9759
|
+
},
|
|
9760
|
+
"isOptional": false
|
|
9761
|
+
}
|
|
9762
|
+
],
|
|
9763
|
+
"typeParameters": [
|
|
9764
|
+
{
|
|
9765
|
+
"typeParameterName": "Device",
|
|
9766
|
+
"constraintTokenRange": {
|
|
9767
|
+
"startIndex": 1,
|
|
9768
|
+
"endIndex": 2
|
|
9769
|
+
},
|
|
9770
|
+
"defaultTypeTokenRange": {
|
|
9771
|
+
"startIndex": 0,
|
|
9772
|
+
"endIndex": 0
|
|
9773
|
+
}
|
|
9774
|
+
}
|
|
9775
|
+
],
|
|
9776
|
+
"name": "createUseDevice"
|
|
9777
|
+
},
|
|
9672
9778
|
{
|
|
9673
9779
|
"kind": "Function",
|
|
9674
9780
|
"canonicalReference": "@empathyco/x-components!createWireFromFunction:function(1)",
|
|
@@ -55622,6 +55728,250 @@
|
|
|
55622
55728
|
"endIndex": 11
|
|
55623
55729
|
}
|
|
55624
55730
|
},
|
|
55731
|
+
{
|
|
55732
|
+
"kind": "Function",
|
|
55733
|
+
"canonicalReference": "@empathyco/x-components!use$x:function(1)",
|
|
55734
|
+
"docComment": "/**\n * Function which returns the `$x` object from the current component instance.\n *\n * @returns The `$x` object from the current component instance.\n *\n * @public\n */\n",
|
|
55735
|
+
"excerptTokens": [
|
|
55736
|
+
{
|
|
55737
|
+
"kind": "Content",
|
|
55738
|
+
"text": "export declare function use$x(): "
|
|
55739
|
+
},
|
|
55740
|
+
{
|
|
55741
|
+
"kind": "Reference",
|
|
55742
|
+
"text": "XComponentAPI",
|
|
55743
|
+
"canonicalReference": "@empathyco/x-components!XComponentAPI:interface"
|
|
55744
|
+
},
|
|
55745
|
+
{
|
|
55746
|
+
"kind": "Content",
|
|
55747
|
+
"text": ";"
|
|
55748
|
+
}
|
|
55749
|
+
],
|
|
55750
|
+
"fileUrlPath": "src/composables/use-$x.ts",
|
|
55751
|
+
"returnTypeTokenRange": {
|
|
55752
|
+
"startIndex": 1,
|
|
55753
|
+
"endIndex": 2
|
|
55754
|
+
},
|
|
55755
|
+
"releaseTag": "Public",
|
|
55756
|
+
"overloadIndex": 1,
|
|
55757
|
+
"parameters": [],
|
|
55758
|
+
"name": "use$x"
|
|
55759
|
+
},
|
|
55760
|
+
{
|
|
55761
|
+
"kind": "TypeAlias",
|
|
55762
|
+
"canonicalReference": "@empathyco/x-components!UseDeviceFlags:type",
|
|
55763
|
+
"docComment": "/**\n * The device flags type of the Return type of the composable returned by `createUseDevice`.\n *\n * @public\n */\n",
|
|
55764
|
+
"excerptTokens": [
|
|
55765
|
+
{
|
|
55766
|
+
"kind": "Content",
|
|
55767
|
+
"text": "export type UseDeviceFlags<Device extends "
|
|
55768
|
+
},
|
|
55769
|
+
{
|
|
55770
|
+
"kind": "Content",
|
|
55771
|
+
"text": "string"
|
|
55772
|
+
},
|
|
55773
|
+
{
|
|
55774
|
+
"kind": "Content",
|
|
55775
|
+
"text": "> = "
|
|
55776
|
+
},
|
|
55777
|
+
{
|
|
55778
|
+
"kind": "Reference",
|
|
55779
|
+
"text": "Record",
|
|
55780
|
+
"canonicalReference": "!Record:type"
|
|
55781
|
+
},
|
|
55782
|
+
{
|
|
55783
|
+
"kind": "Content",
|
|
55784
|
+
"text": "<`is${"
|
|
55785
|
+
},
|
|
55786
|
+
{
|
|
55787
|
+
"kind": "Reference",
|
|
55788
|
+
"text": "Capitalize",
|
|
55789
|
+
"canonicalReference": "!Capitalize:type"
|
|
55790
|
+
},
|
|
55791
|
+
{
|
|
55792
|
+
"kind": "Content",
|
|
55793
|
+
"text": "<Device>}`, "
|
|
55794
|
+
},
|
|
55795
|
+
{
|
|
55796
|
+
"kind": "Reference",
|
|
55797
|
+
"text": "Ref",
|
|
55798
|
+
"canonicalReference": "vue!Ref:interface"
|
|
55799
|
+
},
|
|
55800
|
+
{
|
|
55801
|
+
"kind": "Content",
|
|
55802
|
+
"text": "<boolean>> & "
|
|
55803
|
+
},
|
|
55804
|
+
{
|
|
55805
|
+
"kind": "Reference",
|
|
55806
|
+
"text": "Record",
|
|
55807
|
+
"canonicalReference": "!Record:type"
|
|
55808
|
+
},
|
|
55809
|
+
{
|
|
55810
|
+
"kind": "Content",
|
|
55811
|
+
"text": "<`is${"
|
|
55812
|
+
},
|
|
55813
|
+
{
|
|
55814
|
+
"kind": "Reference",
|
|
55815
|
+
"text": "Capitalize",
|
|
55816
|
+
"canonicalReference": "!Capitalize:type"
|
|
55817
|
+
},
|
|
55818
|
+
{
|
|
55819
|
+
"kind": "Content",
|
|
55820
|
+
"text": "<Device>}OrGreater`, "
|
|
55821
|
+
},
|
|
55822
|
+
{
|
|
55823
|
+
"kind": "Reference",
|
|
55824
|
+
"text": "Ref",
|
|
55825
|
+
"canonicalReference": "vue!Ref:interface"
|
|
55826
|
+
},
|
|
55827
|
+
{
|
|
55828
|
+
"kind": "Content",
|
|
55829
|
+
"text": "<boolean>> & "
|
|
55830
|
+
},
|
|
55831
|
+
{
|
|
55832
|
+
"kind": "Reference",
|
|
55833
|
+
"text": "Record",
|
|
55834
|
+
"canonicalReference": "!Record:type"
|
|
55835
|
+
},
|
|
55836
|
+
{
|
|
55837
|
+
"kind": "Content",
|
|
55838
|
+
"text": "<`is${"
|
|
55839
|
+
},
|
|
55840
|
+
{
|
|
55841
|
+
"kind": "Reference",
|
|
55842
|
+
"text": "Capitalize",
|
|
55843
|
+
"canonicalReference": "!Capitalize:type"
|
|
55844
|
+
},
|
|
55845
|
+
{
|
|
55846
|
+
"kind": "Content",
|
|
55847
|
+
"text": "<Device>}OrLess`, "
|
|
55848
|
+
},
|
|
55849
|
+
{
|
|
55850
|
+
"kind": "Reference",
|
|
55851
|
+
"text": "Ref",
|
|
55852
|
+
"canonicalReference": "vue!Ref:interface"
|
|
55853
|
+
},
|
|
55854
|
+
{
|
|
55855
|
+
"kind": "Content",
|
|
55856
|
+
"text": "<boolean>>"
|
|
55857
|
+
},
|
|
55858
|
+
{
|
|
55859
|
+
"kind": "Content",
|
|
55860
|
+
"text": ";"
|
|
55861
|
+
}
|
|
55862
|
+
],
|
|
55863
|
+
"fileUrlPath": "src/composables/create-use-device.composable.ts",
|
|
55864
|
+
"releaseTag": "Public",
|
|
55865
|
+
"name": "UseDeviceFlags",
|
|
55866
|
+
"typeParameters": [
|
|
55867
|
+
{
|
|
55868
|
+
"typeParameterName": "Device",
|
|
55869
|
+
"constraintTokenRange": {
|
|
55870
|
+
"startIndex": 1,
|
|
55871
|
+
"endIndex": 2
|
|
55872
|
+
},
|
|
55873
|
+
"defaultTypeTokenRange": {
|
|
55874
|
+
"startIndex": 0,
|
|
55875
|
+
"endIndex": 0
|
|
55876
|
+
}
|
|
55877
|
+
}
|
|
55878
|
+
],
|
|
55879
|
+
"typeTokenRange": {
|
|
55880
|
+
"startIndex": 3,
|
|
55881
|
+
"endIndex": 21
|
|
55882
|
+
}
|
|
55883
|
+
},
|
|
55884
|
+
{
|
|
55885
|
+
"kind": "TypeAlias",
|
|
55886
|
+
"canonicalReference": "@empathyco/x-components!UseDeviceReturn:type",
|
|
55887
|
+
"docComment": "/**\n * The Return type of the composable returned by `createUseDevice`.\n *\n * @public\n */\n",
|
|
55888
|
+
"excerptTokens": [
|
|
55889
|
+
{
|
|
55890
|
+
"kind": "Content",
|
|
55891
|
+
"text": "export type UseDeviceReturn<Device extends "
|
|
55892
|
+
},
|
|
55893
|
+
{
|
|
55894
|
+
"kind": "Content",
|
|
55895
|
+
"text": "string"
|
|
55896
|
+
},
|
|
55897
|
+
{
|
|
55898
|
+
"kind": "Content",
|
|
55899
|
+
"text": " = "
|
|
55900
|
+
},
|
|
55901
|
+
{
|
|
55902
|
+
"kind": "Content",
|
|
55903
|
+
"text": "string"
|
|
55904
|
+
},
|
|
55905
|
+
{
|
|
55906
|
+
"kind": "Content",
|
|
55907
|
+
"text": "> = "
|
|
55908
|
+
},
|
|
55909
|
+
{
|
|
55910
|
+
"kind": "Content",
|
|
55911
|
+
"text": "{\n orientation: "
|
|
55912
|
+
},
|
|
55913
|
+
{
|
|
55914
|
+
"kind": "Reference",
|
|
55915
|
+
"text": "Ref",
|
|
55916
|
+
"canonicalReference": "vue!Ref:interface"
|
|
55917
|
+
},
|
|
55918
|
+
{
|
|
55919
|
+
"kind": "Content",
|
|
55920
|
+
"text": "<'landscape' | 'portrait' | undefined>;\n isTouchable: "
|
|
55921
|
+
},
|
|
55922
|
+
{
|
|
55923
|
+
"kind": "Reference",
|
|
55924
|
+
"text": "Ref",
|
|
55925
|
+
"canonicalReference": "vue!Ref:interface"
|
|
55926
|
+
},
|
|
55927
|
+
{
|
|
55928
|
+
"kind": "Content",
|
|
55929
|
+
"text": "<boolean>;\n deviceName: "
|
|
55930
|
+
},
|
|
55931
|
+
{
|
|
55932
|
+
"kind": "Reference",
|
|
55933
|
+
"text": "Ref",
|
|
55934
|
+
"canonicalReference": "vue!Ref:interface"
|
|
55935
|
+
},
|
|
55936
|
+
{
|
|
55937
|
+
"kind": "Content",
|
|
55938
|
+
"text": "<string>;\n} & "
|
|
55939
|
+
},
|
|
55940
|
+
{
|
|
55941
|
+
"kind": "Reference",
|
|
55942
|
+
"text": "UseDeviceFlags",
|
|
55943
|
+
"canonicalReference": "@empathyco/x-components!UseDeviceFlags:type"
|
|
55944
|
+
},
|
|
55945
|
+
{
|
|
55946
|
+
"kind": "Content",
|
|
55947
|
+
"text": "<Device>"
|
|
55948
|
+
},
|
|
55949
|
+
{
|
|
55950
|
+
"kind": "Content",
|
|
55951
|
+
"text": ";"
|
|
55952
|
+
}
|
|
55953
|
+
],
|
|
55954
|
+
"fileUrlPath": "src/composables/create-use-device.composable.ts",
|
|
55955
|
+
"releaseTag": "Public",
|
|
55956
|
+
"name": "UseDeviceReturn",
|
|
55957
|
+
"typeParameters": [
|
|
55958
|
+
{
|
|
55959
|
+
"typeParameterName": "Device",
|
|
55960
|
+
"constraintTokenRange": {
|
|
55961
|
+
"startIndex": 1,
|
|
55962
|
+
"endIndex": 2
|
|
55963
|
+
},
|
|
55964
|
+
"defaultTypeTokenRange": {
|
|
55965
|
+
"startIndex": 3,
|
|
55966
|
+
"endIndex": 4
|
|
55967
|
+
}
|
|
55968
|
+
}
|
|
55969
|
+
],
|
|
55970
|
+
"typeTokenRange": {
|
|
55971
|
+
"startIndex": 5,
|
|
55972
|
+
"endIndex": 14
|
|
55973
|
+
}
|
|
55974
|
+
},
|
|
55625
55975
|
{
|
|
55626
55976
|
"kind": "Variable",
|
|
55627
55977
|
"canonicalReference": "@empathyco/x-components!UserFilledIcon:var",
|
|
@@ -23,6 +23,7 @@ import { Module } from 'vuex';
|
|
|
23
23
|
import { Observable } from 'rxjs';
|
|
24
24
|
import { PluginObject } from 'vue';
|
|
25
25
|
import { Priority } from '@empathyco/x-bus';
|
|
26
|
+
import { Ref } from 'vue';
|
|
26
27
|
import { RequiredProperties } from '@empathyco/x-utils';
|
|
27
28
|
import { ShallowUnwrapRef } from 'vue';
|
|
28
29
|
import { StorageService } from '@empathyco/x-storage-service';
|
|
@@ -783,7 +784,7 @@ export interface CancellablePromiseFunction<T, K = unknown> {
|
|
|
783
784
|
export const CancelSymbol: unique symbol;
|
|
784
785
|
|
|
785
786
|
// @public
|
|
786
|
-
export function capitalize(str:
|
|
787
|
+
export function capitalize<StrType extends string>(str: StrType): Capitalize<StrType>;
|
|
787
788
|
|
|
788
789
|
// @public (undocumented)
|
|
789
790
|
export const CartFilledIcon: {};
|
|
@@ -964,6 +965,9 @@ export function createStoreEmitters<Module extends AnyXStoreModule, Emitters ext
|
|
|
964
965
|
// @public
|
|
965
966
|
export function createTrackWire(property: keyof Tagging_2): Wire<Taggable>;
|
|
966
967
|
|
|
968
|
+
// @public
|
|
969
|
+
export function createUseDevice<Device extends string>(devices: Record<Device, number>): () => UseDeviceReturn<Device>;
|
|
970
|
+
|
|
967
971
|
// @public
|
|
968
972
|
export function createWireFromFunction<Payload>(fn: (parameters: WireParams<Payload>) => void): Wire<Payload>;
|
|
969
973
|
|
|
@@ -5319,6 +5323,19 @@ export type UrlXStoreModule = XStoreModule<UrlState, UrlGetters, UrlMutations, U
|
|
|
5319
5323
|
// @internal
|
|
5320
5324
|
export const urlXStoreModule: UrlXStoreModule;
|
|
5321
5325
|
|
|
5326
|
+
// @public
|
|
5327
|
+
export function use$x(): XComponentAPI;
|
|
5328
|
+
|
|
5329
|
+
// @public
|
|
5330
|
+
export type UseDeviceFlags<Device extends string> = Record<`is${Capitalize<Device>}`, Ref<boolean>> & Record<`is${Capitalize<Device>}OrGreater`, Ref<boolean>> & Record<`is${Capitalize<Device>}OrLess`, Ref<boolean>>;
|
|
5331
|
+
|
|
5332
|
+
// @public
|
|
5333
|
+
export type UseDeviceReturn<Device extends string = string> = {
|
|
5334
|
+
orientation: Ref<'landscape' | 'portrait' | undefined>;
|
|
5335
|
+
isTouchable: Ref<boolean>;
|
|
5336
|
+
deviceName: Ref<string>;
|
|
5337
|
+
} & UseDeviceFlags<Device>;
|
|
5338
|
+
|
|
5322
5339
|
// @public (undocumented)
|
|
5323
5340
|
export const UserFilledIcon: {};
|
|
5324
5341
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* The Return type of the composable returned by `createUseDevice`.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export type UseDeviceReturn<Device extends string = string> = {
|
|
8
|
+
orientation: Ref<'landscape' | 'portrait' | undefined>;
|
|
9
|
+
isTouchable: Ref<boolean>;
|
|
10
|
+
deviceName: Ref<string>;
|
|
11
|
+
} & UseDeviceFlags<Device>;
|
|
12
|
+
/**
|
|
13
|
+
* The device flags type of the Return type of the composable returned by `createUseDevice`.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type UseDeviceFlags<Device extends string> = Record<`is${Capitalize<Device>}`, Ref<boolean>> & Record<`is${Capitalize<Device>}OrGreater`, Ref<boolean>> & Record<`is${Capitalize<Device>}OrLess`, Ref<boolean>>;
|
|
18
|
+
/**
|
|
19
|
+
* Factory function that creates a composable for device detection using the devices parameter
|
|
20
|
+
* to configure breakpoints.
|
|
21
|
+
*
|
|
22
|
+
* @param devices - An object containing the breakpoints, where the key is the name of the device
|
|
23
|
+
* and the value is the screen width.
|
|
24
|
+
* @returns A composable which provides multiple reactive flags and values for detecting the
|
|
25
|
+
* current device. The flags names depends on the names passed in the `devices` parameter.
|
|
26
|
+
* @remarks The `orientation` only works for orientation-sensor devices (mobile, tablet, etc). If
|
|
27
|
+
* in a desktop, the height of the window is larger than the width, the orientation will be
|
|
28
|
+
* `landscape`.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ´´´typescript
|
|
32
|
+
* const useDevice = createUseDevice(\{ mobile: 0, tablet: 744, desktop: 1024 \});
|
|
33
|
+
* const \{
|
|
34
|
+
* isMobile,
|
|
35
|
+
* isMobileOrLess,
|
|
36
|
+
* isMobileOrGreater,
|
|
37
|
+
* isTablet,
|
|
38
|
+
* isTabletOrLess,
|
|
39
|
+
* isTabletOrGreater,
|
|
40
|
+
* isDesktop,
|
|
41
|
+
* isDesktopOrLess,
|
|
42
|
+
* isDesktopOrGreater,
|
|
43
|
+
* deviceName,
|
|
44
|
+
* orientation,
|
|
45
|
+
* istTouchable
|
|
46
|
+
* \} = useDevice();
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare function createUseDevice<Device extends string>(devices: Record<Device, number>): () => UseDeviceReturn<Device>;
|
|
51
|
+
//# sourceMappingURL=create-use-device.composable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-use-device.composable.d.ts","sourceRoot":"","sources":["../../../src/composables/create-use-device.composable.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,GAAG,EAAE,MAAM,KAAK,CAAC;AAGtD;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,WAAW,EAAE,GAAG,CAAC,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC;IACvD,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACzB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,MAAM,IAAI,MAAM,CACxD,KAAK,UAAU,CAAC,MAAM,CAAC,EAAE,EACzB,GAAG,CAAC,OAAO,CAAC,CACb,GACC,MAAM,CAAC,KAAK,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,GACxD,MAAM,CAAC,KAAK,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,MAAM,EACnD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,eAAe,CAAC,MAAM,CAAC,CAmB/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { XComponentAPI } from '../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* Function which returns the `$x` object from the current component instance.
|
|
4
|
+
*
|
|
5
|
+
* @returns The `$x` object from the current component instance.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function use$x(): XComponentAPI;
|
|
10
|
+
//# sourceMappingURL=use-$x.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-$x.d.ts","sourceRoot":"","sources":["../../../src/composables/use-$x.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,KAAK,IAAI,aAAa,CAErC"}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC"}
|
package/types/utils/string.d.ts
CHANGED
|
@@ -33,5 +33,5 @@ export declare function toKebabCase(str: string): string;
|
|
|
33
33
|
*
|
|
34
34
|
* @public
|
|
35
35
|
*/
|
|
36
|
-
export declare function capitalize(str:
|
|
36
|
+
export declare function capitalize<StrType extends string>(str: StrType): Capitalize<StrType>;
|
|
37
37
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAEpF"}
|