ember-velcro 1.0.0 → 1.1.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 +7 -1
- package/addon-main.js +5 -0
- package/dist/_app_/components/velcro/index.js +1 -0
- package/dist/_app_/modifiers/velcro.js +1 -0
- package/dist/components/velcro/index.d.ts +46 -0
- package/dist/components/velcro/index.d.ts.map +1 -0
- package/dist/components/velcro/index.js +90 -0
- package/dist/components/velcro/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/modifiers/velcro.d.ts +26 -0
- package/dist/modifiers/velcro.js +65 -0
- package/dist/modifiers/velcro.js.map +1 -0
- package/glint.d.ts +11 -0
- package/package.json +67 -44
- package/CHANGELOG.md +0 -36
- package/addon/components/velcro/index.hbs +0 -16
- package/addon/components/velcro/index.js +0 -23
- package/addon/middleware/velcro-data.js +0 -11
- package/addon/modifiers/velcro.js +0 -71
- package/app/components/velcro.js +0 -1
- package/app/modifiers/velcro.js +0 -1
- package/commitlint.config.cjs +0 -33
- package/config/environment.js +0 -5
- package/index.js +0 -5
- package/tailwind.config.js +0 -12
package/README.md
CHANGED
@@ -92,7 +92,13 @@ Installation
|
|
92
92
|
------------------------------------------------------------------------------
|
93
93
|
|
94
94
|
```
|
95
|
-
|
95
|
+
npm install ember-velcro
|
96
|
+
# or
|
97
|
+
yarn install ember-velcro
|
98
|
+
# or
|
99
|
+
pnpm install ember-velcro
|
100
|
+
# or
|
101
|
+
ember install ember-velcro
|
96
102
|
```
|
97
103
|
|
98
104
|
Contributing
|
package/addon-main.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "ember-velcro/components/velcro/index";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "ember-velcro/modifiers/velcro";
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import Component from '@glimmer/component';
|
2
|
+
import VelcroModifier from "../../modifiers/velcro";
|
3
|
+
import { Signature as ModifierSignature } from "../../modifiers/velcro";
|
4
|
+
import { MiddlewareArguments } from '@floating-ui/dom';
|
5
|
+
import { ModifierLike } from '@glint/template';
|
6
|
+
type ModifierArgs = ModifierSignature['Args']['Named'];
|
7
|
+
interface Signature {
|
8
|
+
Args: {
|
9
|
+
middleware?: ModifierArgs['middleware'];
|
10
|
+
placement?: ModifierArgs['placement'];
|
11
|
+
strategy?: ModifierArgs['strategy'];
|
12
|
+
flipOptions?: ModifierArgs['flipOptions'];
|
13
|
+
hideOptions?: ModifierArgs['hideOptions'];
|
14
|
+
shiftOptions?: ModifierArgs['shiftOptions'];
|
15
|
+
offsetOptions?: ModifierArgs['offsetOptions'];
|
16
|
+
};
|
17
|
+
Blocks: {
|
18
|
+
default: [
|
19
|
+
velcro: {
|
20
|
+
hook: ModifierLike<HookSignature>;
|
21
|
+
loop: ModifierLike<{
|
22
|
+
Element: HTMLElement;
|
23
|
+
}>;
|
24
|
+
data: MiddlewareArguments;
|
25
|
+
}
|
26
|
+
];
|
27
|
+
};
|
28
|
+
}
|
29
|
+
interface HookSignature {
|
30
|
+
Element: HTMLElement | SVGElement;
|
31
|
+
}
|
32
|
+
declare class VelcroComponent extends Component<Signature> {
|
33
|
+
hook?: HTMLElement | SVGElement;
|
34
|
+
velcroData?: MiddlewareArguments;
|
35
|
+
setVelcroData: (data: MiddlewareArguments) => MiddlewareArguments;
|
36
|
+
velcroHook: import("ember-modifier").FunctionBasedModifier<{
|
37
|
+
Element: HTMLElement | SVGElement;
|
38
|
+
Args: {
|
39
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
40
|
+
Positional: [];
|
41
|
+
};
|
42
|
+
}>;
|
43
|
+
velcroLoop: typeof VelcroModifier;
|
44
|
+
}
|
45
|
+
export { VelcroComponent as default };
|
46
|
+
//# sourceMappingURL=components/velcro/index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"components/velcro/index.d.ts","sourceRoot":"","sources":["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
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import { setComponentTemplate } from '@ember/component';
|
2
|
+
import { hbs } from 'ember-cli-htmlbars';
|
3
|
+
import Component from '@glimmer/component';
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
5
|
+
import { modifier } from 'ember-modifier';
|
6
|
+
import VelcroModifier from '../../modifiers/velcro.js';
|
7
|
+
|
8
|
+
function _initializerDefineProperty(target, property, descriptor, context) {
|
9
|
+
if (!descriptor) return;
|
10
|
+
Object.defineProperty(target, property, {
|
11
|
+
enumerable: descriptor.enumerable,
|
12
|
+
configurable: descriptor.configurable,
|
13
|
+
writable: descriptor.writable,
|
14
|
+
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
function _defineProperty(obj, key, value) {
|
19
|
+
if (key in obj) {
|
20
|
+
Object.defineProperty(obj, key, {
|
21
|
+
value: value,
|
22
|
+
enumerable: true,
|
23
|
+
configurable: true,
|
24
|
+
writable: true
|
25
|
+
});
|
26
|
+
} else {
|
27
|
+
obj[key] = value;
|
28
|
+
}
|
29
|
+
return obj;
|
30
|
+
}
|
31
|
+
|
32
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
|
33
|
+
var desc = {};
|
34
|
+
Object.keys(descriptor).forEach(function (key) {
|
35
|
+
desc[key] = descriptor[key];
|
36
|
+
});
|
37
|
+
desc.enumerable = !!desc.enumerable;
|
38
|
+
desc.configurable = !!desc.configurable;
|
39
|
+
if ('value' in desc || desc.initializer) {
|
40
|
+
desc.writable = true;
|
41
|
+
}
|
42
|
+
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
|
43
|
+
return decorator(target, property, desc) || desc;
|
44
|
+
}, desc);
|
45
|
+
if (context && desc.initializer !== void 0) {
|
46
|
+
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
|
47
|
+
desc.initializer = undefined;
|
48
|
+
}
|
49
|
+
if (desc.initializer === void 0) {
|
50
|
+
Object.defineProperty(target, property, desc);
|
51
|
+
desc = null;
|
52
|
+
}
|
53
|
+
return desc;
|
54
|
+
}
|
55
|
+
|
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
|
+
|
58
|
+
var _class, _descriptor, _descriptor2;
|
59
|
+
let VelcroComponent = (_class = class VelcroComponent extends Component {
|
60
|
+
constructor(...args) {
|
61
|
+
super(...args);
|
62
|
+
_initializerDefineProperty(this, "hook", _descriptor, this);
|
63
|
+
_initializerDefineProperty(this, "velcroData", _descriptor2, this);
|
64
|
+
_defineProperty(this, "setVelcroData", data => this.velcroData = data);
|
65
|
+
_defineProperty(this, "velcroHook", modifier(element => {
|
66
|
+
this.hook = element;
|
67
|
+
}, {
|
68
|
+
eager: false
|
69
|
+
}));
|
70
|
+
_defineProperty(this, "velcroLoop", VelcroModifier);
|
71
|
+
}
|
72
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "hook", [tracked], {
|
73
|
+
configurable: true,
|
74
|
+
enumerable: true,
|
75
|
+
writable: true,
|
76
|
+
initializer: function () {
|
77
|
+
return undefined;
|
78
|
+
}
|
79
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "velcroData", [tracked], {
|
80
|
+
configurable: true,
|
81
|
+
enumerable: true,
|
82
|
+
writable: true,
|
83
|
+
initializer: function () {
|
84
|
+
return undefined;
|
85
|
+
}
|
86
|
+
})), _class);
|
87
|
+
setComponentTemplate(TEMPLATE, VelcroComponent);
|
88
|
+
|
89
|
+
export { VelcroComponent as default };
|
90
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +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 VelcroComponent 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","VelcroComponent","Component","data","velcroData","modifier","element","hook","eager","VelcroModifier","tracked"],"mappings":";;;;;;;AAAe,SAASA,0BAA0B,CAACC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACxF,IAAI,CAACD,UAAU,EAAE,OAAA;AACjBE,EAAAA,MAAM,CAACC,cAAc,CAACL,MAAM,EAAEC,QAAQ,EA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M,IAAI,CAACC,UAAU,GAAGD,IAAK,CAAA,CAAA;IAAA,eAE1DE,CAAAA,IAAAA,EAAAA,YAAAA,EAAAA,QAAQ,CAClBC,OAAO,IAAK;MACX,IAAI,CAACC,IAAI,GAAGD,OAAO,CAAA;AACrB,KAAC,EACD;AAAEE,MAAAA,KAAK,EAAE,KAAA;AAAM,KAAC,CACjB,CAAA,CAAA;AAAA,IAAA,eAAA,CAAA,IAAA,EAAA,YAAA,EAEYC,cAAc,CAAA,CAAA;AAAA,GAAA;AAC7B,CAAC,sEAfEC,OAAO,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,YAAA;AAAA,IAAA,OAAmCX,SAAS,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA,EAAA,YAAA,GAAA,yBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,YAAA,EAAA,CAGnDW,OAAO,CAAA,EAAA;AAAA,EAAA,YAAA,EAAA,IAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,QAAA,EAAA,IAAA;AAAA,EAAA,WAAA,EAAA,YAAA;AAAA,IAAA,OAAoCX,SAAS,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA,GAAA,MAAA,EAAA;AAJnB,oBAAA,CAAA,QAAA,EAAA,eAAA,CAAA;;;;"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import Modifier from 'ember-modifier';
|
2
|
+
import { Middleware, Placement, Strategy } from '@floating-ui/dom';
|
3
|
+
/**
|
4
|
+
* TODO: figure out how to get the real types out of @floating-ui/dom
|
5
|
+
*/
|
6
|
+
type TODO = any;
|
7
|
+
interface Signature {
|
8
|
+
Element: HTMLElement;
|
9
|
+
Args: {
|
10
|
+
Positional: [referenceElement: string | HTMLElement | SVGElement];
|
11
|
+
Named: {
|
12
|
+
strategy?: Strategy;
|
13
|
+
offsetOptions?: TODO;
|
14
|
+
placement?: Placement;
|
15
|
+
flipOptions?: TODO;
|
16
|
+
shiftOptions?: TODO;
|
17
|
+
hideOptions?: TODO;
|
18
|
+
middleware?: Middleware[];
|
19
|
+
setVelcroData?: Middleware['fn'];
|
20
|
+
};
|
21
|
+
};
|
22
|
+
}
|
23
|
+
declare class VelcroModifier extends Modifier<Signature> {
|
24
|
+
modify(floatingElement: Signature['Element'], [_referenceElement]: Signature['Args']['Positional'], { strategy, offsetOptions, placement, flipOptions, shiftOptions, middleware, setVelcroData, }: Signature['Args']['Named']): void;
|
25
|
+
}
|
26
|
+
export { Signature, VelcroModifier as default };
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { assert } from '@ember/debug';
|
2
|
+
import { registerDestructor } from '@ember/destroyable';
|
3
|
+
import { autoUpdate, computePosition, offset, flip, shift, hide } from '@floating-ui/dom';
|
4
|
+
import Modifier from 'ember-modifier';
|
5
|
+
|
6
|
+
function velcroData() {
|
7
|
+
return {
|
8
|
+
name: 'metadata',
|
9
|
+
fn: data => {
|
10
|
+
// https://floating-ui.com/docs/middleware#always-return-an-object
|
11
|
+
return {
|
12
|
+
data
|
13
|
+
};
|
14
|
+
}
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
class VelcroModifier extends Modifier {
|
19
|
+
modify(floatingElement, [_referenceElement], {
|
20
|
+
strategy = 'fixed',
|
21
|
+
offsetOptions = 0,
|
22
|
+
placement = 'bottom',
|
23
|
+
flipOptions,
|
24
|
+
shiftOptions,
|
25
|
+
middleware = [],
|
26
|
+
setVelcroData
|
27
|
+
}) {
|
28
|
+
const referenceElement = typeof _referenceElement === 'string' ? document.querySelector(_referenceElement) : _referenceElement;
|
29
|
+
assert('no reference element defined', referenceElement instanceof HTMLElement || referenceElement instanceof SVGElement);
|
30
|
+
assert('no floating element defined', floatingElement instanceof HTMLElement || _referenceElement instanceof SVGElement);
|
31
|
+
assert('reference and floating elements cannot be the same element', floatingElement !== _referenceElement);
|
32
|
+
assert('@middleware must be an array of one or more objects', Array.isArray(middleware));
|
33
|
+
Object.assign(floatingElement.style, {
|
34
|
+
position: strategy,
|
35
|
+
top: '0',
|
36
|
+
left: '0'
|
37
|
+
});
|
38
|
+
let update = async () => {
|
39
|
+
let {
|
40
|
+
x,
|
41
|
+
y,
|
42
|
+
middlewareData
|
43
|
+
} = await computePosition(referenceElement, floatingElement, {
|
44
|
+
middleware: [offset(offsetOptions), flip(flipOptions), shift(shiftOptions), ...middleware, hide({
|
45
|
+
strategy: 'referenceHidden'
|
46
|
+
}), hide({
|
47
|
+
strategy: 'escaped'
|
48
|
+
}), velcroData()],
|
49
|
+
placement,
|
50
|
+
strategy
|
51
|
+
});
|
52
|
+
Object.assign(floatingElement.style, {
|
53
|
+
strategy,
|
54
|
+
transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,
|
55
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
56
|
+
});
|
57
|
+
setVelcroData?.(middlewareData.metadata);
|
58
|
+
};
|
59
|
+
let cleanup = autoUpdate(referenceElement, floatingElement, update);
|
60
|
+
registerDestructor(this, cleanup);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
export { VelcroModifier as default };
|
65
|
+
//# sourceMappingURL=velcro.js.map
|
@@ -0,0 +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, middlewareData } = 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 Object.assign(floatingElement.style, {\n strategy,\n transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,\n visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible',\n });\n\n setVelcroData?.(middlewareData.metadata);\n };\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","x","y","middlewareData","computePosition","offset","flip","shift","hide","transform","Math","round","visibility","referenceHidden","metadata","cleanup","autoUpdate","registerDestructor"],"mappings":";;;;;AAEO,SAASA,UAAU,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;;ACqBe,MAAMC,cAAc,SAASC,QAAQ,CAAY;AAC9DC,EAAAA,MAAM,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,UAAU,CAClF,CAAA;IAEDF,MAAM,CACJ,6BAA6B,EAC7BZ,eAAe,YAAYa,WAAW,IAAIZ,iBAAiB,YAAYa,UAAU,CACl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GAAGkB,cAAc,CAACW,QAAQ,CAAC,CAAA;KACzC,CAAA;IAED,IAAIC,OAAO,GAAGC,UAAU,CAAC9B,gBAAgB,EAAET,eAAe,EAAEuB,MAAM,CAAC,CAAA;AAEnEiB,IAAAA,kBAAkB,CAAC,IAAI,EAAEF,OAAO,CAAC,CAAA;AACnC,GAAA;AACF;;;;"}
|
package/glint.d.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import '@glint/environment-ember-loose';
|
2
|
+
|
3
|
+
import type VelcroComponent from './dist/components/velcro';
|
4
|
+
import type VelcroModifier from './dist/modifiers/velcro';
|
5
|
+
|
6
|
+
declare module '@glint/environment-ember-loose/registry' {
|
7
|
+
export default interface Registry {
|
8
|
+
Velcro: typeof VelcroComponent;
|
9
|
+
velcro: typeof VelcroModifier;
|
10
|
+
}
|
11
|
+
}
|
package/package.json
CHANGED
@@ -1,66 +1,89 @@
|
|
1
1
|
{
|
2
2
|
"name": "ember-velcro",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.0",
|
4
4
|
"description": "Ember Velcro sticks one element to another with Floating UI.",
|
5
5
|
"keywords": [
|
6
6
|
"ember-addon"
|
7
7
|
],
|
8
|
+
"bugs": {
|
9
|
+
"url": "https://github.com/CrowdStrike/ember-velcro/issues"
|
10
|
+
},
|
11
|
+
"homepage": "https://github.com/CrowdStrike/ember-velcro#readme",
|
8
12
|
"repository": {
|
9
13
|
"type": "git",
|
10
|
-
"url": "git+https://
|
14
|
+
"url": "git+https://CrowdStrike@github.com/CrowdStrike/ember-velcro.git",
|
15
|
+
"directory": "ember-velcro"
|
11
16
|
},
|
12
17
|
"license": "MIT",
|
13
|
-
"author": "
|
18
|
+
"author": "CrowdStrike UX Team",
|
14
19
|
"directories": {
|
15
20
|
"test": "tests"
|
16
21
|
},
|
22
|
+
"exports": {
|
23
|
+
".": "./dist/index.js",
|
24
|
+
"./*": "./dist/*",
|
25
|
+
"./addon-main": "./addon-main.js"
|
26
|
+
},
|
27
|
+
"typesVersions": {
|
28
|
+
"*": {
|
29
|
+
"glint": [
|
30
|
+
"./glint.d.ts"
|
31
|
+
],
|
32
|
+
"*": [
|
33
|
+
"./dist/*"
|
34
|
+
]
|
35
|
+
}
|
36
|
+
},
|
37
|
+
"files": [
|
38
|
+
"addon-main.js",
|
39
|
+
"dist",
|
40
|
+
"glint.d.ts"
|
41
|
+
],
|
17
42
|
"scripts": {
|
18
|
-
"build": "
|
19
|
-
"lint": "npm
|
20
|
-
"lint:fix": "npm
|
21
|
-
"lint:hbs": "ember-template-lint .",
|
22
|
-
"lint:hbs:fix": "ember-template-lint . --fix",
|
43
|
+
"build": "rollup --config ./rollup.config.js",
|
44
|
+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
45
|
+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
46
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
23
47
|
"lint:js": "eslint . --cache",
|
48
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
24
49
|
"lint:js:fix": "eslint . --fix",
|
25
|
-
"start": "
|
26
|
-
"test": "
|
27
|
-
"
|
28
|
-
|
50
|
+
"start": "rollup --config --watch",
|
51
|
+
"test": "echo 'A v2 addon does not have tests, run tests in test-app'",
|
52
|
+
"prepack": "rollup --config ./rollup.config.js"
|
53
|
+
},
|
54
|
+
"peerDependencies": {
|
55
|
+
"@glint/environment-ember-loose": "^0.9.4",
|
56
|
+
"@glint/template": "^0.9.5"
|
29
57
|
},
|
30
58
|
"dependencies": {
|
59
|
+
"@embroider/addon-shim": "^1.0.0",
|
31
60
|
"@floating-ui/dom": "^1.0.1",
|
32
|
-
"ember-
|
33
|
-
"ember-cli-babel": "^7.26.11",
|
34
|
-
"ember-cli-htmlbars": "^6.1.0",
|
61
|
+
"ember-functions-as-helper-polyfill": "^2.1.1",
|
35
62
|
"ember-modifier": "^3.2.7"
|
36
63
|
},
|
37
64
|
"devDependencies": {
|
38
|
-
"@
|
39
|
-
"@
|
40
|
-
"@
|
65
|
+
"@babel/core": "^7.19.3",
|
66
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
67
|
+
"@babel/plugin-proposal-decorators": "^7.19.3",
|
68
|
+
"@babel/preset-typescript": "^7.18.6",
|
69
|
+
"@babel/runtime": "^7.19.4",
|
70
|
+
"@embroider/addon-dev": "^2.0.0",
|
41
71
|
"@glimmer/component": "^1.1.2",
|
42
72
|
"@glimmer/tracking": "^1.1.2",
|
73
|
+
"@glint/environment-ember-loose": "^0.9.5",
|
74
|
+
"@glint/template": "^0.9.5",
|
43
75
|
"@nullvoxpopuli/eslint-configs": "^2.2.58",
|
76
|
+
"@rollup/plugin-babel": "^5.3.1",
|
44
77
|
"@semantic-release/changelog": "^6.0.0",
|
45
78
|
"@semantic-release/git": "^10.0.0",
|
79
|
+
"@types/ember__debug": "^4.0.1",
|
80
|
+
"@types/ember__destroyable": "^4.0.0",
|
46
81
|
"babel-eslint": "^10.1.0",
|
47
82
|
"broccoli-asset-rev": "^3.0.0",
|
48
|
-
"
|
49
|
-
"ember-cli-
|
50
|
-
"ember-cli-inject-live-reload": "^2.1.0",
|
51
|
-
"ember-cli-postcss": "^8.2.0",
|
52
|
-
"ember-cli-sri": "^2.1.1",
|
53
|
-
"ember-cli-terser": "^4.0.2",
|
54
|
-
"ember-disable-prototype-extensions": "^1.1.3",
|
55
|
-
"ember-functions-as-helper-polyfill": "^2.1.1",
|
56
|
-
"ember-load-initializers": "^2.1.2",
|
57
|
-
"ember-page-title": "^7.0.0",
|
58
|
-
"ember-qunit": "^5.1.5",
|
59
|
-
"ember-resolver": "^8.0.3",
|
83
|
+
"concurrently": "^7.4.0",
|
84
|
+
"ember-cli-htmlbars": "^6.1.0",
|
60
85
|
"ember-source": "~4.7.0",
|
61
|
-
"ember-source-channel-url": "^3.0.0",
|
62
86
|
"ember-template-lint": "^4.10.1",
|
63
|
-
"ember-try": "^2.0.0",
|
64
87
|
"eslint": "^7.0.0",
|
65
88
|
"eslint-config-prettier": "^8.5.0",
|
66
89
|
"eslint-plugin-decorator-position": "^5.0.1",
|
@@ -69,14 +92,13 @@
|
|
69
92
|
"eslint-plugin-node": "^11.1.0",
|
70
93
|
"eslint-plugin-prettier": "^4.2.1",
|
71
94
|
"eslint-plugin-qunit": "^7.3.1",
|
72
|
-
"loader.js": "^4.7.0",
|
73
95
|
"npm-run-all": "^4.1.5",
|
74
96
|
"prettier": "^2.7.1",
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
97
|
+
"rollup": "^2.79.1",
|
98
|
+
"rollup-plugin-copy": "^3.4.0",
|
99
|
+
"rollup-plugin-ts": "^3.0.2",
|
78
100
|
"semantic-release": "^19.0.0",
|
79
|
-
"
|
101
|
+
"typescript": "^4.8.4",
|
80
102
|
"webpack": "^5.74.0"
|
81
103
|
},
|
82
104
|
"engines": {
|
@@ -86,7 +108,13 @@
|
|
86
108
|
"edition": "octane"
|
87
109
|
},
|
88
110
|
"ember-addon": {
|
89
|
-
"
|
111
|
+
"version": 2,
|
112
|
+
"type": "addon",
|
113
|
+
"main": "addon-main.js",
|
114
|
+
"app-js": {
|
115
|
+
"./components/velcro/index.js": "./dist/_app_/components/velcro/index.js",
|
116
|
+
"./modifiers/velcro.js": "./dist/_app_/modifiers/velcro.js"
|
117
|
+
}
|
90
118
|
},
|
91
119
|
"release": {
|
92
120
|
"branches": [
|
@@ -101,10 +129,5 @@
|
|
101
129
|
"@semantic-release/github",
|
102
130
|
"@semantic-release/git"
|
103
131
|
]
|
104
|
-
}
|
105
|
-
"main": "index.js",
|
106
|
-
"bugs": {
|
107
|
-
"url": "https://github.com/camskene/ember-velcro/issues"
|
108
|
-
},
|
109
|
-
"homepage": "https://github.com/camskene/ember-velcro#readme"
|
132
|
+
}
|
110
133
|
}
|
package/CHANGELOG.md
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# 1.0.0 (2022-09-27)
|
2
|
-
|
3
|
-
|
4
|
-
### Bug Fixes
|
5
|
-
|
6
|
-
* cleanup popper ([da193d9](https://github.com/camskene/ember-velcro/commit/da193d97e696d12a2c5ba44f63d1c7a1d09e926c))
|
7
|
-
* cleanup ResizeObserver ([5a05ff2](https://github.com/camskene/ember-velcro/commit/5a05ff26fb8981a1ba28401dc66cb80508ffb834))
|
8
|
-
* **release:** add semantic release config to package.json ([e3f9ccb](https://github.com/camskene/ember-velcro/commit/e3f9ccbb412d37c095e654fa3857b9b648227709))
|
9
|
-
* remove unused dependency ([3fa4854](https://github.com/camskene/ember-velcro/commit/3fa4854505d7309d4f9615eb8281cf05299a5f21))
|
10
|
-
* rename offset args ([8fdf4e1](https://github.com/camskene/ember-velcro/commit/8fdf4e18a5737f44211b4ee9a6f09f73678f4dca))
|
11
|
-
* update readme and package details ([21dd7f6](https://github.com/camskene/ember-velcro/commit/21dd7f6744be5efa5708c8e476e9266b1eb1f5d6))
|
12
|
-
* update to Ember v4.6.0 ([a529ef0](https://github.com/camskene/ember-velcro/commit/a529ef09a9370f974304b8e9debf1880eb5ffe7b))
|
13
|
-
|
14
|
-
|
15
|
-
* feat!: add velcro modifier ([4724a30](https://github.com/camskene/ember-velcro/commit/4724a30e4f3326a3909efede31124cc3cced2862))
|
16
|
-
|
17
|
-
|
18
|
-
### Features
|
19
|
-
|
20
|
-
* add modifiers, strategy, and onFirstUpdate to args ([0a12c39](https://github.com/camskene/ember-velcro/commit/0a12c3948fdebe59388d1c25b129a1b199efc465))
|
21
|
-
* add offsetX, offsetY, and placement to args ([0dfa444](https://github.com/camskene/ember-velcro/commit/0dfa4440063a0e2d6ee74fd0ceb42879c92630ce))
|
22
|
-
* add options for flip and shift middleware ([2229496](https://github.com/camskene/ember-velcro/commit/2229496be892572a0953ab113541f0eda490787d))
|
23
|
-
* add velcro component ([b5e6f31](https://github.com/camskene/ember-velcro/commit/b5e6f313a38b0eb359bdc7d5d6ce96d38295c6f1))
|
24
|
-
* basic demo ([1484983](https://github.com/camskene/ember-velcro/commit/148498338e5eac273eb2f16da0f7a72e68152a1e))
|
25
|
-
* create popper and yield modifiers ([50cc8bc](https://github.com/camskene/ember-velcro/commit/50cc8bc2118ea1202ad24f200b957d728fab2b51))
|
26
|
-
* handle targetElement or popoverElement resize ([1398f89](https://github.com/camskene/ember-velcro/commit/1398f89a9586b901248e85490a6427df67a4e50c))
|
27
|
-
* migrate from popperjs to floating-ui ([06d6e90](https://github.com/camskene/ember-velcro/commit/06d6e90cd706159b6b189d644d0bc8a65229c5c4))
|
28
|
-
|
29
|
-
|
30
|
-
### BREAKING CHANGES
|
31
|
-
|
32
|
-
* arguments to middleware are now composed of the
|
33
|
-
middleware name + 'Options'.
|
34
|
-
|
35
|
-
eg `@offset` -> `@offsetOptions`
|
36
|
-
* https://floating-ui.com/docs/migration
|
@@ -1,16 +0,0 @@
|
|
1
|
-
{{yield (hash
|
2
|
-
hook=this.velcroHook
|
3
|
-
loop=(if this.hook (modifier this.velcroLoop
|
4
|
-
this.hook
|
5
|
-
flipOptions=@flipOptions
|
6
|
-
hideOptions=@hideOptions
|
7
|
-
middleware=@middleware
|
8
|
-
offsetOptions=@offsetOptions
|
9
|
-
placement=@placement
|
10
|
-
shiftOptions=@shiftOptions
|
11
|
-
strategy=@strategy
|
12
|
-
setVelcroData=this.setVelcroData
|
13
|
-
))
|
14
|
-
data=this.velcroData
|
15
|
-
)}}
|
16
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import Component from '@glimmer/component';
|
2
|
-
import { tracked } from '@glimmer/tracking';
|
3
|
-
|
4
|
-
import { modifier } from 'ember-modifier';
|
5
|
-
import VelcroModifier from 'ember-velcro/modifiers/velcro';
|
6
|
-
|
7
|
-
export default class VelcroComponent extends Component {
|
8
|
-
@tracked hook = undefined;
|
9
|
-
|
10
|
-
// set by VelcroModifier
|
11
|
-
@tracked velcroData = undefined;
|
12
|
-
|
13
|
-
setVelcroData = (data) => (this.velcroData = data);
|
14
|
-
|
15
|
-
velcroHook = modifier(
|
16
|
-
(element) => {
|
17
|
-
this.hook = element;
|
18
|
-
},
|
19
|
-
{ eager: false }
|
20
|
-
);
|
21
|
-
|
22
|
-
velcroLoop = VelcroModifier;
|
23
|
-
}
|
@@ -1,71 +0,0 @@
|
|
1
|
-
import { assert } from '@ember/debug';
|
2
|
-
import { registerDestructor } from '@ember/destroyable';
|
3
|
-
|
4
|
-
import { autoUpdate, computePosition, flip, hide, offset, shift } from '@floating-ui/dom';
|
5
|
-
import Modifier from 'ember-modifier';
|
6
|
-
import { velcroData } from 'ember-velcro/middleware/velcro-data';
|
7
|
-
|
8
|
-
export default class VelcroModifier extends Modifier {
|
9
|
-
modify(
|
10
|
-
floatingElement,
|
11
|
-
[referenceElement],
|
12
|
-
{
|
13
|
-
strategy = 'fixed',
|
14
|
-
offsetOptions = 0,
|
15
|
-
placement = 'bottom',
|
16
|
-
flipOptions,
|
17
|
-
shiftOptions,
|
18
|
-
middleware = [],
|
19
|
-
setVelcroData,
|
20
|
-
}
|
21
|
-
) {
|
22
|
-
if (typeof referenceElement === 'string') {
|
23
|
-
referenceElement = document.querySelector(referenceElement);
|
24
|
-
}
|
25
|
-
|
26
|
-
assert('no reference element defined', referenceElement instanceof HTMLElement);
|
27
|
-
|
28
|
-
assert('no floating element defined', floatingElement instanceof HTMLElement);
|
29
|
-
|
30
|
-
assert(
|
31
|
-
'reference and floating elements cannot be the same element',
|
32
|
-
floatingElement !== referenceElement
|
33
|
-
);
|
34
|
-
|
35
|
-
assert('@middleware must be an array of one or more objects', Array.isArray(middleware));
|
36
|
-
|
37
|
-
Object.assign(floatingElement.style, {
|
38
|
-
position: strategy,
|
39
|
-
top: '0',
|
40
|
-
left: '0',
|
41
|
-
});
|
42
|
-
|
43
|
-
let update = async () => {
|
44
|
-
let { x, y, middlewareData } = await computePosition(referenceElement, floatingElement, {
|
45
|
-
middleware: [
|
46
|
-
offset(offsetOptions),
|
47
|
-
flip(flipOptions),
|
48
|
-
shift(shiftOptions),
|
49
|
-
...middleware,
|
50
|
-
hide({ strategy: 'referenceHidden' }),
|
51
|
-
hide({ strategy: 'escaped' }),
|
52
|
-
velcroData(),
|
53
|
-
],
|
54
|
-
placement,
|
55
|
-
strategy,
|
56
|
-
});
|
57
|
-
|
58
|
-
Object.assign(floatingElement.style, {
|
59
|
-
strategy,
|
60
|
-
transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,
|
61
|
-
visibility: middlewareData.hide.referenceHidden ? 'hidden' : 'visible',
|
62
|
-
});
|
63
|
-
|
64
|
-
setVelcroData?.(middlewareData.metadata);
|
65
|
-
};
|
66
|
-
|
67
|
-
let cleanup = autoUpdate(referenceElement, floatingElement, update);
|
68
|
-
|
69
|
-
registerDestructor(this, cleanup);
|
70
|
-
}
|
71
|
-
}
|
package/app/components/velcro.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { default } from 'ember-velcro/components/velcro';
|
package/app/modifiers/velcro.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { default } from 'ember-velcro/modifiers/velcro';
|
package/commitlint.config.cjs
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* The goal of commitlint in this repo is not to enforce
|
5
|
-
* eerily similar commit messages across comitters, but
|
6
|
-
* to give juuust enough enformation for automated releasing.
|
7
|
-
*
|
8
|
-
* Beyond major/minor/patch indicators, most of the commit
|
9
|
-
* message's conventions are irrelevant, and should instead be
|
10
|
-
* focused on content / release notes.
|
11
|
-
*
|
12
|
-
* And for contributors to the repository, following convential commits
|
13
|
-
* is not needed. The maintainer of ember-headless-table merging a PR
|
14
|
-
* can specify chore/feat/fix/breaking in the merge commit in the GitHub
|
15
|
-
* UI.
|
16
|
-
*/
|
17
|
-
module.exports = {
|
18
|
-
extends: ['@commitlint/config-conventional'],
|
19
|
-
// https://commitlint.js.org/#/reference-rules
|
20
|
-
// Level [0..2]: 0 disables the rule. For 1 it will be considered a warning for 2 an error.
|
21
|
-
// Applicable always|never: never inverts the rule.
|
22
|
-
// Value: value to use for this rule.
|
23
|
-
rules: {
|
24
|
-
// 72, the default, is a little short
|
25
|
-
'header-max-length': [1, 'always', 100],
|
26
|
-
// Let people use caps
|
27
|
-
'header-case': [0],
|
28
|
-
// Let people write sentences
|
29
|
-
'header-full-stop': [0],
|
30
|
-
// Casing doesn't really matter
|
31
|
-
'subject-case': [0],
|
32
|
-
},
|
33
|
-
};
|
package/config/environment.js
DELETED
package/index.js
DELETED
package/tailwind.config.js
DELETED