ember-velcro 2.1.1 → 2.1.3
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/dist/components/velcro/index.d.ts +3 -4
- package/dist/components/velcro/index.js +4 -4
- package/dist/components/velcro/index.js.map +1 -1
- package/dist/modifiers/velcro.js +13 -5
- package/dist/modifiers/velcro.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/velcro/index.d.ts.map +0 -1
@@ -29,10 +29,10 @@ interface Signature {
|
|
29
29
|
interface HookSignature {
|
30
30
|
Element: HTMLElement | SVGElement;
|
31
31
|
}
|
32
|
-
declare class
|
32
|
+
declare class Velcro extends Component<Signature> {
|
33
33
|
hook?: HTMLElement | SVGElement;
|
34
34
|
velcroData?: MiddlewareArguments;
|
35
|
-
setVelcroData:
|
35
|
+
setVelcroData: any;
|
36
36
|
velcroHook: import("ember-modifier").FunctionBasedModifier<{
|
37
37
|
Element: HTMLElement | SVGElement;
|
38
38
|
Args: {
|
@@ -42,5 +42,4 @@ declare class VelcroComponent extends Component<Signature> {
|
|
42
42
|
}>;
|
43
43
|
velcroLoop: typeof VelcroModifier;
|
44
44
|
}
|
45
|
-
export {
|
46
|
-
//# sourceMappingURL=components/velcro/index.d.ts.map
|
45
|
+
export { Velcro as default };
|
@@ -56,7 +56,7 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
|
|
56
56
|
var TEMPLATE = hbs("{{yield (hash\n hook=this.velcroHook\n loop=(if this.hook (modifier this.velcroLoop\n this.hook\n flipOptions=@flipOptions\n hideOptions=@hideOptions\n middleware=@middleware\n offsetOptions=@offsetOptions\n placement=@placement\n shiftOptions=@shiftOptions\n strategy=@strategy\n setVelcroData=this.setVelcroData\n ))\n data=this.velcroData\n)}}\n\n");
|
57
57
|
|
58
58
|
var _class, _descriptor, _descriptor2;
|
59
|
-
let
|
59
|
+
let Velcro = (_class = class Velcro extends Component {
|
60
60
|
constructor(...args) {
|
61
61
|
super(...args);
|
62
62
|
_initializerDefineProperty(this, "hook", _descriptor, this);
|
@@ -68,7 +68,7 @@ let VelcroComponent = (_class = class VelcroComponent extends Component {
|
|
68
68
|
eager: false
|
69
69
|
}));
|
70
70
|
_defineProperty(this, "velcroLoop", VelcroModifier);
|
71
|
-
}
|
71
|
+
} // set by VelcroModifier
|
72
72
|
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "hook", [tracked], {
|
73
73
|
configurable: true,
|
74
74
|
enumerable: true,
|
@@ -84,7 +84,7 @@ let VelcroComponent = (_class = class VelcroComponent extends Component {
|
|
84
84
|
return undefined;
|
85
85
|
}
|
86
86
|
})), _class);
|
87
|
-
setComponentTemplate(TEMPLATE,
|
87
|
+
setComponentTemplate(TEMPLATE, Velcro);
|
88
88
|
|
89
|
-
export {
|
89
|
+
export { Velcro as default };
|
90
90
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../node_modules/.pnpm/@babel+runtime@7.19.4/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../../../../node_modules/.pnpm/@babel+runtime@7.19.4/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../../../../node_modules/.pnpm/@babel+runtime@7.19.4/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js","../../../src/components/velcro/index.hbs.js","../../../src/components/velcro/index.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {\n var desc = {};\n Object.keys(descriptor).forEach(function (key) {\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer) {\n desc.writable = true;\n }\n desc = decorators.slice().reverse().reduce(function (desc, decorator) {\n return decorator(target, property, desc) || desc;\n }, desc);\n if (context && desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(target, property, desc);\n desc = null;\n }\n return desc;\n}","import { hbs } from 'ember-cli-htmlbars';\nexport default hbs(\"{{yield (hash\\n hook=this.velcroHook\\n loop=(if this.hook (modifier this.velcroLoop\\n this.hook\\n flipOptions=@flipOptions\\n hideOptions=@hideOptions\\n middleware=@middleware\\n offsetOptions=@offsetOptions\\n placement=@placement\\n shiftOptions=@shiftOptions\\n strategy=@strategy\\n setVelcroData=this.setVelcroData\\n ))\\n data=this.velcroData\\n)}}\\n\\n\")","import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\n\nimport { modifier } from 'ember-modifier';\n\nimport VelcroModifier from '../../modifiers/velcro';\n\nimport type { Signature as ModifierSignature } from '../../modifiers/velcro';\nimport type { MiddlewareArguments } from '@floating-ui/dom';\nimport type { ModifierLike } from '@glint/template';\n\ntype ModifierArgs = ModifierSignature['Args']['Named'];\n\ninterface Signature {\n Args: {\n middleware?: ModifierArgs['middleware'];\n placement?: ModifierArgs['placement'];\n strategy?: ModifierArgs['strategy'];\n flipOptions?: ModifierArgs['flipOptions'];\n hideOptions?: ModifierArgs['hideOptions'];\n shiftOptions?: ModifierArgs['shiftOptions'];\n offsetOptions?: ModifierArgs['offsetOptions'];\n };\n Blocks: {\n default: [\n velcro: {\n hook: ModifierLike<HookSignature>;\n loop: ModifierLike<{\n Element: HTMLElement;\n }>;\n data: MiddlewareArguments;\n }\n ];\n };\n}\n\ninterface HookSignature {\n Element: HTMLElement | SVGElement;\n}\n\nexport default class
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../node_modules/.pnpm/@babel+runtime@7.19.4/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../../../../node_modules/.pnpm/@babel+runtime@7.19.4/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../../../../node_modules/.pnpm/@babel+runtime@7.19.4/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js","../../../src/components/velcro/index.hbs.js","../../../src/components/velcro/index.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {\n var desc = {};\n Object.keys(descriptor).forEach(function (key) {\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer) {\n desc.writable = true;\n }\n desc = decorators.slice().reverse().reduce(function (desc, decorator) {\n return decorator(target, property, desc) || desc;\n }, desc);\n if (context && desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(target, property, desc);\n desc = null;\n }\n return desc;\n}","import { hbs } from 'ember-cli-htmlbars';\nexport default hbs(\"{{yield (hash\\n hook=this.velcroHook\\n loop=(if this.hook (modifier this.velcroLoop\\n this.hook\\n flipOptions=@flipOptions\\n hideOptions=@hideOptions\\n middleware=@middleware\\n offsetOptions=@offsetOptions\\n placement=@placement\\n shiftOptions=@shiftOptions\\n strategy=@strategy\\n setVelcroData=this.setVelcroData\\n ))\\n data=this.velcroData\\n)}}\\n\\n\")","import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\n\nimport { modifier } from 'ember-modifier';\n\nimport VelcroModifier from '../../modifiers/velcro';\n\nimport type { Signature as ModifierSignature } from '../../modifiers/velcro';\nimport type { MiddlewareArguments } from '@floating-ui/dom';\nimport type { ModifierLike } from '@glint/template';\n\ntype ModifierArgs = ModifierSignature['Args']['Named'];\n\ninterface Signature {\n Args: {\n middleware?: ModifierArgs['middleware'];\n placement?: ModifierArgs['placement'];\n strategy?: ModifierArgs['strategy'];\n flipOptions?: ModifierArgs['flipOptions'];\n hideOptions?: ModifierArgs['hideOptions'];\n shiftOptions?: ModifierArgs['shiftOptions'];\n offsetOptions?: ModifierArgs['offsetOptions'];\n };\n Blocks: {\n default: [\n velcro: {\n hook: ModifierLike<HookSignature>;\n loop: ModifierLike<{\n Element: HTMLElement;\n }>;\n data: MiddlewareArguments;\n }\n ];\n };\n}\n\ninterface HookSignature {\n Element: HTMLElement | SVGElement;\n}\n\nexport default class Velcro extends Component<Signature> {\n @tracked hook?: HTMLElement | SVGElement = undefined;\n\n // set by VelcroModifier\n @tracked velcroData?: MiddlewareArguments = undefined;\n\n setVelcroData = (data: MiddlewareArguments) => (this.velcroData = data);\n\n velcroHook = modifier<HookSignature>(\n (element) => {\n this.hook = element;\n },\n { eager: false }\n );\n\n velcroLoop = VelcroModifier;\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","_defineProperty","obj","key","_applyDecoratedDescriptor","decorators","desc","keys","forEach","slice","reverse","reduce","decorator","undefined","hbs","Velcro","_class","Component","constructor","args","_descriptor","_descriptor2","data","velcroData","modifier","element","hook","eager","VelcroModifier","prototype","tracked","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;AAAe,SAASA,0BAA0BA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACxF,IAAI,CAACD,UAAU,EAAE,OAAA;AACjBE,EAAAA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,IAAM,IAAI,CAACC,UAAU,GAAGD,IAAK,CAAA,CAAA;AAAArB,IAAAA,eAAA,CAE1DuB,IAAAA,EAAAA,YAAAA,EAAAA,QAAQ,CAClBC,OAAO,IAAK;MACX,IAAI,CAACC,IAAI,GAAGD,OAAO,CAAA;AACrB,KAAC,EACD;AAAEE,MAAAA,KAAK,EAAE,KAAA;AAAM,KACjB,CAAC,CAAA,CAAA;AAAA1B,IAAAA,eAAA,qBAEY2B,cAAc,CAAA,CAAA;GAZ3B;AAaF,CAAC,GAAAR,WAAA,GAAAhB,yBAAA,CAAAY,MAAA,CAAAa,SAAA,EAAA,MAAA,EAAA,CAfEC,OAAO,CAAA,EAAA;EAAAlC,YAAA,EAAA,IAAA;EAAAD,UAAA,EAAA,IAAA;EAAAE,QAAA,EAAA,IAAA;AAAAE,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAmCc,SAAS,CAAA;AAAA,GAAA;AAAA,CAAAQ,CAAAA,EAAAA,YAAA,GAAAjB,yBAAA,CAAAY,MAAA,CAAAa,SAAA,iBAGnDC,OAAO,CAAA,EAAA;EAAAlC,YAAA,EAAA,IAAA;EAAAD,UAAA,EAAA,IAAA;EAAAE,QAAA,EAAA,IAAA;AAAAE,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAoCc,SAAS,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA,GAAAG,MAAA,EAAA;AAJ5Be,oBAAA,CAAAC,QAAA,EAAAjB,MAAA,CAAA;;;;"}
|
package/dist/modifiers/velcro.js
CHANGED
@@ -15,6 +15,9 @@ function velcroData() {
|
|
15
15
|
};
|
16
16
|
}
|
17
17
|
|
18
|
+
/**
|
19
|
+
* TODO: figure out how to get the real types out of @floating-ui/dom
|
20
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
18
21
|
class VelcroModifier extends Modifier {
|
19
22
|
modify(floatingElement, [_referenceElement], {
|
20
23
|
strategy = 'fixed',
|
@@ -37,9 +40,9 @@ class VelcroModifier extends Modifier {
|
|
37
40
|
});
|
38
41
|
let update = async () => {
|
39
42
|
let {
|
43
|
+
middlewareData,
|
40
44
|
x,
|
41
|
-
y
|
42
|
-
middlewareData
|
45
|
+
y
|
43
46
|
} = await computePosition(referenceElement, floatingElement, {
|
44
47
|
middleware: [offset(offsetOptions), flip(flipOptions), shift(shiftOptions), ...middleware, hide({
|
45
48
|
strategy: 'referenceHidden'
|
@@ -49,13 +52,18 @@ class VelcroModifier extends Modifier {
|
|
49
52
|
placement,
|
50
53
|
strategy
|
51
54
|
});
|
55
|
+
const {
|
56
|
+
referenceHidden
|
57
|
+
} = middlewareData.hide;
|
52
58
|
Object.assign(floatingElement.style, {
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
top: `${y}px`,
|
60
|
+
left: `${x}px`,
|
61
|
+
margin: 0,
|
62
|
+
visibility: referenceHidden ? 'hidden' : 'visible'
|
56
63
|
});
|
57
64
|
setVelcroData?.(middlewareData.metadata);
|
58
65
|
};
|
66
|
+
update();
|
59
67
|
let cleanup = autoUpdate(referenceElement, floatingElement, update);
|
60
68
|
registerDestructor(this, cleanup);
|
61
69
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"velcro.js","sources":["../../src/middleware/velcro-data.ts","../../src/modifiers/velcro.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\n\nexport function velcroData(): Middleware {\n return {\n name: 'metadata',\n fn: (data) => {\n // https://floating-ui.com/docs/middleware#always-return-an-object\n return {\n data,\n };\n },\n };\n}\n","import { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\n\nimport { autoUpdate, computePosition, flip, hide, offset, shift } from '@floating-ui/dom';\nimport Modifier from 'ember-modifier';\n\nimport { velcroData } from '../middleware/velcro-data';\n\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\n\n/**\n * TODO: figure out how to get the real types out of @floating-ui/dom\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TODO = any;\n\nexport interface Signature {\n Element: HTMLElement;\n Args: {\n Positional: [referenceElement: string | HTMLElement | SVGElement];\n Named: {\n strategy?: Strategy;\n offsetOptions?: TODO;\n placement?: Placement;\n flipOptions?: TODO;\n shiftOptions?: TODO;\n hideOptions?: TODO;\n middleware?: Middleware[];\n setVelcroData?: Middleware['fn'];\n };\n };\n}\n\nexport default class VelcroModifier extends Modifier<Signature> {\n modify(\n floatingElement: Signature['Element'],\n [_referenceElement]: Signature['Args']['Positional'],\n {\n strategy = 'fixed',\n offsetOptions = 0,\n placement = 'bottom',\n flipOptions,\n shiftOptions,\n middleware = [],\n setVelcroData,\n }: Signature['Args']['Named']\n ) {\n const referenceElement: null | HTMLElement | SVGElement =\n typeof _referenceElement === 'string'\n ? document.querySelector(_referenceElement)\n : _referenceElement;\n\n assert(\n 'no reference element defined',\n referenceElement instanceof HTMLElement || referenceElement instanceof SVGElement\n );\n\n assert(\n 'no floating element defined',\n floatingElement instanceof HTMLElement || _referenceElement instanceof SVGElement\n );\n\n assert(\n 'reference and floating elements cannot be the same element',\n floatingElement !== _referenceElement\n );\n\n assert('@middleware must be an array of one or more objects', Array.isArray(middleware));\n\n Object.assign(floatingElement.style, {\n position: strategy,\n top: '0',\n left: '0',\n });\n\n let update = async () => {\n let { x, y
|
1
|
+
{"version":3,"file":"velcro.js","sources":["../../src/middleware/velcro-data.ts","../../src/modifiers/velcro.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\n\nexport function velcroData(): Middleware {\n return {\n name: 'metadata',\n fn: (data) => {\n // https://floating-ui.com/docs/middleware#always-return-an-object\n return {\n data,\n };\n },\n };\n}\n","import { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\n\nimport { autoUpdate, computePosition, flip, hide, offset, shift } from '@floating-ui/dom';\nimport Modifier from 'ember-modifier';\n\nimport { velcroData } from '../middleware/velcro-data';\n\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\n\n/**\n * TODO: figure out how to get the real types out of @floating-ui/dom\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TODO = any;\n\nexport interface Signature {\n Element: HTMLElement;\n Args: {\n Positional: [referenceElement: string | HTMLElement | SVGElement];\n Named: {\n strategy?: Strategy;\n offsetOptions?: TODO;\n placement?: Placement;\n flipOptions?: TODO;\n shiftOptions?: TODO;\n hideOptions?: TODO;\n middleware?: Middleware[];\n setVelcroData?: Middleware['fn'];\n };\n };\n}\n\nexport default class VelcroModifier extends Modifier<Signature> {\n modify(\n floatingElement: Signature['Element'],\n [_referenceElement]: Signature['Args']['Positional'],\n {\n strategy = 'fixed',\n offsetOptions = 0,\n placement = 'bottom',\n flipOptions,\n shiftOptions,\n middleware = [],\n setVelcroData,\n }: Signature['Args']['Named']\n ) {\n const referenceElement: null | HTMLElement | SVGElement =\n typeof _referenceElement === 'string'\n ? document.querySelector(_referenceElement)\n : _referenceElement;\n\n assert(\n 'no reference element defined',\n referenceElement instanceof HTMLElement || referenceElement instanceof SVGElement\n );\n\n assert(\n 'no floating element defined',\n floatingElement instanceof HTMLElement || _referenceElement instanceof SVGElement\n );\n\n assert(\n 'reference and floating elements cannot be the same element',\n floatingElement !== _referenceElement\n );\n\n assert('@middleware must be an array of one or more objects', Array.isArray(middleware));\n\n Object.assign(floatingElement.style, {\n position: strategy,\n top: '0',\n left: '0',\n });\n\n let update = async () => {\n let { middlewareData, x, y } = await computePosition(referenceElement, floatingElement, {\n middleware: [\n offset(offsetOptions),\n flip(flipOptions),\n shift(shiftOptions),\n ...middleware,\n hide({ strategy: 'referenceHidden' }),\n hide({ strategy: 'escaped' }),\n velcroData(),\n ],\n placement,\n strategy,\n });\n\n const { referenceHidden } = middlewareData.hide;\n\n Object.assign(floatingElement.style, {\n top: `${y}px`,\n left: `${x}px`,\n margin: 0,\n visibility: referenceHidden ? 'hidden' : 'visible',\n });\n\n setVelcroData?.(middlewareData.metadata);\n };\n\n update();\n\n let cleanup = autoUpdate(referenceElement, floatingElement, update);\n\n registerDestructor(this, cleanup);\n }\n}\n"],"names":["velcroData","name","fn","data","VelcroModifier","Modifier","modify","floatingElement","_referenceElement","strategy","offsetOptions","placement","flipOptions","shiftOptions","middleware","setVelcroData","referenceElement","document","querySelector","assert","HTMLElement","SVGElement","Array","isArray","Object","assign","style","position","top","left","update","middlewareData","x","y","computePosition","offset","flip","shift","hide","referenceHidden","margin","visibility","metadata","cleanup","autoUpdate","registerDestructor"],"mappings":";;;;;AAEO,SAASA,UAAUA,GAAe;EACvC,OAAO;AACLC,IAAAA,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAGC,IAAI,IAAK;AACZ;MACA,OAAO;AACLA,QAAAA,IAAAA;OACD,CAAA;AACH,KAAA;GACD,CAAA;AACH;;ACFA;AACA;AACA;AAqBe,MAAMC,cAAc,SAASC,QAAQ,CAAY;AAC9DC,EAAAA,MAAMA,CACJC,eAAqC,EACrC,CAACC,iBAAiB,CAAkC,EACpD;AACEC,IAAAA,QAAQ,GAAG,OAAO;AAClBC,IAAAA,aAAa,GAAG,CAAC;AACjBC,IAAAA,SAAS,GAAG,QAAQ;IACpBC,WAAW;IACXC,YAAY;AACZC,IAAAA,UAAU,GAAG,EAAE;AACfC,IAAAA,aAAAA;AAC0B,GAAC,EAC7B;AACA,IAAA,MAAMC,gBAAiD,GACrD,OAAOR,iBAAiB,KAAK,QAAQ,GACjCS,QAAQ,CAACC,aAAa,CAACV,iBAAiB,CAAC,GACzCA,iBAAiB,CAAA;IAEvBW,MAAM,CACJ,8BAA8B,EAC9BH,gBAAgB,YAAYI,WAAW,IAAIJ,gBAAgB,YAAYK,UACzE,CAAC,CAAA;IAEDF,MAAM,CACJ,6BAA6B,EAC7BZ,eAAe,YAAYa,WAAW,IAAIZ,iBAAiB,YAAYa,UACzE,CAAC,CAAA;AAEDF,IAAAA,MAAM,CACJ,4DAA4D,EAC5DZ,eAAe,KAAKC,iBACtB,CAAC,CAAA;IAEDW,MAAM,CAAC,qDAAqD,EAAEG,KAAK,CAACC,OAAO,CAACT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,GAAGC,UAAU,CAAC5B,gBAAgB,EAAET,eAAe,EAAEuB,MAAM,CAAC,CAAA;AAEnEe,IAAAA,kBAAkB,CAAC,IAAI,EAAEF,OAAO,CAAC,CAAA;AACnC,GAAA;AACF;;;;"}
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"components/velcro/index.d.ts","sourceRoot":"","sources":["../src/components/velcro/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAK3C,OAAO,cAAc,+BAA+B;;AAGpD,OAAO,uBAA4B,MAAM,kBAAkB,CAAC;AAC5D,OAAO,gBAAqB,MAAM,iBAAiB,CAAC;AAEpD,KAAK,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAEvD,UAAU,SAAS;IACjB,IAAI,EAAE;QACJ,UAAU,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;QACxC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;QACtC,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;QACpC,WAAW,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;QAC1C,WAAW,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;QAC1C,YAAY,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;QAC5C,aAAa,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC,CAAC;KAC/C,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;gBAClC,IAAI,EAAE,YAAY,CAAC;oBACjB,OAAO,EAAE,WAAW,CAAC;iBACtB,CAAC,CAAC;gBACH,IAAI,EAAE,mBAAmB,CAAC;aAC3B;SACF,CAAC;KACH,CAAC;CACH;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,WAAW,GAAG,U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