@frontile/utilities 0.17.0-beta.10 → 0.17.0-beta.11
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/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/utils/ref.d.ts +6 -3
- package/declarations/utils/ref.d.ts.map +1 -1
- package/declarations/utils/toggle.d.ts +9 -0
- package/declarations/utils/toggle.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime-BPCpkOf1-K_uh_M6B.js +53 -0
- package/dist/runtime-BPCpkOf1-K_uh_M6B.js.map +1 -0
- package/dist/utils/ref.js +22 -67
- package/dist/utils/ref.js.map +1 -1
- package/dist/utils/toggle.js +46 -0
- package/dist/utils/toggle.js.map +1 -0
- package/package.json +2 -2
package/declarations/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qCAAqC,CAAC;AAE7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qCAAqC,CAAC;AAE7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
1
|
+
declare class Ref<T extends Element = Element> {
|
|
2
|
+
#private;
|
|
3
|
+
current: T | undefined;
|
|
4
|
+
constructor(onChange?: (el: T | undefined) => void);
|
|
3
5
|
setup: import("ember-modifier").FunctionBasedModifier<{
|
|
4
6
|
Args: {
|
|
5
7
|
Positional: unknown[];
|
|
@@ -7,6 +9,7 @@ declare function ref<T extends Element = Element>(): {
|
|
|
7
9
|
};
|
|
8
10
|
Element: T;
|
|
9
11
|
}>;
|
|
10
|
-
}
|
|
12
|
+
}
|
|
13
|
+
declare function ref<T extends Element = Element>(onChange?: (el: T | undefined) => void): Ref<T>;
|
|
11
14
|
export { ref };
|
|
12
15
|
//# sourceMappingURL=ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/utils/ref.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/utils/ref.ts"],"names":[],"mappings":"AAGA,cAAM,GAAG,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO;;IAC1B,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC;gBAGpB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI;IAIlD,KAAK;;;;;;OAYF;CACJ;AAED,iBAAS,GAAG,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EACtC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GACrC,GAAG,CAAC,CAAC,CAAC,CAER;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare class ToggleState {
|
|
2
|
+
#private;
|
|
3
|
+
current: boolean;
|
|
4
|
+
constructor(initialValue?: boolean, onChange?: (val: boolean) => void);
|
|
5
|
+
toggle: (input?: boolean | Event) => void;
|
|
6
|
+
}
|
|
7
|
+
declare function toggleState(initialValue?: boolean, onChange?: (val: boolean) => void): ToggleState;
|
|
8
|
+
export { toggleState };
|
|
9
|
+
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/utils/toggle.ts"],"names":[],"mappings":"AAEA,cAAM,WAAW;;IACN,OAAO,UAAS;gBAGb,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI;IAOrE,MAAM,WAAY,OAAO,GAAG,KAAK,KAAG,IAAI,CAiBtC;CAYH;AAED,iBAAS,WAAW,CAClB,YAAY,CAAC,EAAE,OAAO,EACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAChC,WAAW,CAEb;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,5 @@ export { Collapsible } from './components/collapsible.js';
|
|
|
5
5
|
export { Divider } from './components/divider.js';
|
|
6
6
|
export { Spinner } from './components/spinner.js';
|
|
7
7
|
export { ref } from './utils/ref.js';
|
|
8
|
+
export { toggleState } from './utils/toggle.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/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":";;;;;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const deferred = /* @__PURE__ */new WeakMap();
|
|
2
|
+
function deferDecorator(proto, prop, desc) {
|
|
3
|
+
let map = deferred.get(proto);
|
|
4
|
+
if (!map) {
|
|
5
|
+
map = /* @__PURE__ */new Map();
|
|
6
|
+
deferred.set(proto, map);
|
|
7
|
+
}
|
|
8
|
+
map.set(prop, desc);
|
|
9
|
+
}
|
|
10
|
+
function findDeferredDecorator(target, prop) {
|
|
11
|
+
var _a;
|
|
12
|
+
let cursor = target.prototype;
|
|
13
|
+
while (cursor) {
|
|
14
|
+
let desc = (_a = deferred.get(cursor)) == null ? undefined : _a.get(prop);
|
|
15
|
+
if (desc) {
|
|
16
|
+
return desc;
|
|
17
|
+
}
|
|
18
|
+
cursor = cursor.prototype;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function decorateFieldV2(prototype, prop, decorators, initializer) {
|
|
22
|
+
let desc = {
|
|
23
|
+
configurable: true,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
initializer: null
|
|
27
|
+
};
|
|
28
|
+
if (initializer) {
|
|
29
|
+
desc.initializer = initializer;
|
|
30
|
+
}
|
|
31
|
+
for (let decorator of decorators) {
|
|
32
|
+
desc = decorator(prototype, prop, desc) || desc;
|
|
33
|
+
}
|
|
34
|
+
if (desc.initializer === undefined) {
|
|
35
|
+
Object.defineProperty(prototype, prop, desc);
|
|
36
|
+
} else {
|
|
37
|
+
deferDecorator(prototype, prop, desc);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function initializeDeferredDecorator(target, prop) {
|
|
41
|
+
let desc = findDeferredDecorator(target.constructor, prop);
|
|
42
|
+
if (desc) {
|
|
43
|
+
Object.defineProperty(target, prop, {
|
|
44
|
+
enumerable: desc.enumerable,
|
|
45
|
+
configurable: desc.configurable,
|
|
46
|
+
writable: desc.writable,
|
|
47
|
+
value: desc.initializer ? desc.initializer.call(target) : undefined
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { decorateFieldV2 as d, initializeDeferredDecorator as i };
|
|
53
|
+
//# sourceMappingURL=runtime-BPCpkOf1-K_uh_M6B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-BPCpkOf1-K_uh_M6B.js","sources":["../../../node_modules/.pnpm/decorator-transforms@2.3.0_@babel+core@7.26.7/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js"],"sourcesContent":["const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = cursor.prototype;\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV2 as a,\n decorateMethodV1 as b,\n decorateMethodV2 as c,\n decorateFieldV1 as d,\n decorateClass as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime-BPCpkOf1.js.map\n"],"names":["deferred","WeakMap","deferDecorator","proto","prop","desc","map","get","Map","set","findDeferredDecorator","target","_a","cursor","prototype","decorateFieldV2","decorators","initializer","configurable","enumerable","writable","decorator","Object","defineProperty","initializeDeferredDecorator","constructor","value","call"],"mappings":"AAuBA,MAAMA,QAAA,sBAGEC,OAAA,EAAA;AAER,SAASC,eACPC,KAAA,EACAC,IAAA,EACAC,IAAA,EACM;AACF,EAAA,IAAAC,GAAA,GAAMN,QAAA,CAASO,GAAA,CAAIJ,KAAK,CAAA;EAC5B,IAAI,CAACG,GAAA,EAAK;AACRA,IAAAA,GAAA,sBAAUE,GAAA,EAAA;AACDR,IAAAA,QAAA,CAAAS,GAAA,CAAIN,KAAA,EAAOG,GAAG,CAAA;AACzB;AACIA,EAAAA,GAAA,CAAAG,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,qBAAA,CAAsBC,MAAA,CAAOc,WAAA,EAAarB,IAAI,CAAA;AACzD,EAAA,IAAIC,IAAA,EAAM;AACDiB,IAAAA,MAAA,CAAAC,cAAA,CAAeZ,MAAA,EAAQP,IAAA,EAAM;MAClCe,UAAA,EAAYd,IAAA,CAAKc,UAAA;MACjBD,YAAA,EAAcb,IAAA,CAAKa,YAAA;MACnBE,QAAA,EAAUf,IAAA,CAAKe,QAAA;AACfM,MAAAA,KAAA,EAAOrB,IAAA,CAAKY,WAAA,GAAcZ,IAAA,CAAKY,WAAA,CAAYU,IAAA,CAAKhB,MAAM,CAAI,GAAA;KAC3D,CAAA;AACH;AACF;;;;","x_google_ignoreList":[0]}
|
package/dist/utils/ref.js
CHANGED
|
@@ -1,76 +1,31 @@
|
|
|
1
1
|
import { tracked } from '@glimmer/tracking';
|
|
2
2
|
import { modifier } from 'ember-modifier';
|
|
3
|
+
import { d as decorateFieldV2, i as initializeDeferredDecorator } from '../runtime-BPCpkOf1-K_uh_M6B.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
function deferDecorator(proto, prop, desc) {
|
|
6
|
-
let map = deferred.get(proto);
|
|
7
|
-
if (!map) {
|
|
8
|
-
map = /* @__PURE__ */new Map();
|
|
9
|
-
deferred.set(proto, map);
|
|
10
|
-
}
|
|
11
|
-
map.set(prop, desc);
|
|
12
|
-
}
|
|
13
|
-
function findDeferredDecorator(target, prop) {
|
|
14
|
-
var _a;
|
|
15
|
-
let cursor = target.prototype;
|
|
16
|
-
while (cursor) {
|
|
17
|
-
let desc = (_a = deferred.get(cursor)) == null ? undefined : _a.get(prop);
|
|
18
|
-
if (desc) {
|
|
19
|
-
return desc;
|
|
20
|
-
}
|
|
21
|
-
cursor = cursor.prototype;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function decorateFieldV2(prototype, prop, decorators, initializer) {
|
|
25
|
-
let desc = {
|
|
26
|
-
configurable: true,
|
|
27
|
-
enumerable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
initializer: null
|
|
30
|
-
};
|
|
31
|
-
if (initializer) {
|
|
32
|
-
desc.initializer = initializer;
|
|
33
|
-
}
|
|
34
|
-
for (let decorator of decorators) {
|
|
35
|
-
desc = decorator(prototype, prop, desc) || desc;
|
|
36
|
-
}
|
|
37
|
-
if (desc.initializer === undefined) {
|
|
38
|
-
Object.defineProperty(prototype, prop, desc);
|
|
39
|
-
} else {
|
|
40
|
-
deferDecorator(prototype, prop, desc);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function initializeDeferredDecorator(target, prop) {
|
|
44
|
-
let desc = findDeferredDecorator(target.constructor, prop);
|
|
45
|
-
if (desc) {
|
|
46
|
-
Object.defineProperty(target, prop, {
|
|
47
|
-
enumerable: desc.enumerable,
|
|
48
|
-
configurable: desc.configurable,
|
|
49
|
-
writable: desc.writable,
|
|
50
|
-
value: desc.initializer ? desc.initializer.call(target) : undefined
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class State {
|
|
5
|
+
class Ref {
|
|
56
6
|
static {
|
|
57
|
-
decorateFieldV2(this.prototype, "
|
|
7
|
+
decorateFieldV2(this.prototype, "current", [tracked]);
|
|
8
|
+
}
|
|
9
|
+
#current = (initializeDeferredDecorator(this, "current"), undefined);
|
|
10
|
+
#onChange;
|
|
11
|
+
constructor(onChange) {
|
|
12
|
+
this.#onChange = onChange;
|
|
58
13
|
}
|
|
59
|
-
|
|
14
|
+
setup = modifier(el => {
|
|
15
|
+
this.current = el;
|
|
16
|
+
if (this.#onChange) {
|
|
17
|
+
this.#onChange(el);
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
this.current = undefined;
|
|
21
|
+
if (this.#onChange) {
|
|
22
|
+
this.#onChange(undefined);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
60
26
|
}
|
|
61
|
-
function ref() {
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
get element() {
|
|
65
|
-
return state.element;
|
|
66
|
-
},
|
|
67
|
-
setup: modifier(el => {
|
|
68
|
-
state.element = el;
|
|
69
|
-
return () => {
|
|
70
|
-
state.element = undefined;
|
|
71
|
-
};
|
|
72
|
-
})
|
|
73
|
-
};
|
|
27
|
+
function ref(onChange) {
|
|
28
|
+
return new Ref(onChange);
|
|
74
29
|
}
|
|
75
30
|
|
|
76
31
|
export { ref };
|
package/dist/utils/ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","sources":["
|
|
1
|
+
{"version":3,"file":"ref.js","sources":["../../src/utils/ref.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\n\nclass Ref<T extends Element = Element> {\n @tracked current: T | undefined;\n #onChange?: (el: T | undefined) => void;\n\n constructor(onChange?: (el: T | undefined) => void) {\n this.#onChange = onChange;\n }\n\n setup = modifier((el: T) => {\n this.current = el;\n if (this.#onChange) {\n this.#onChange(el);\n }\n\n return (): void => {\n this.current = undefined;\n if (this.#onChange) {\n this.#onChange(undefined);\n }\n };\n });\n}\n\nfunction ref<T extends Element = Element>(\n onChange?: (el: T | undefined) => void\n): Ref<T> {\n return new Ref(onChange);\n}\n\nexport { ref };\n"],"names":["Ref","g","prototype","tracked","i","void 0","constructor","onChange","setup","modifier","el","current","undefined","ref"],"mappings":";;;;AAGA,MAAMA,GAAG,CAA8B;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACpCC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,SAAA;AACR,EAAA,SAAS;EAETC,WAAWA,CAACC,QAAsC,EAAE;AAClD,IAAA,IAAI,CAAC,SAAS,GAAGA,QAAQ;AAC3B;AAEAC,EAAAA,KAAK,GAAGC,QAAQ,CAAEC,EAAK,IAAK;IAC1B,IAAI,CAACC,OAAO,GAAGD,EAAE;AACjB,IAAA,IAAI,IAAI,CAAC,SAAS,EAAE;AAClB,MAAA,IAAI,CAAC,SAAS,CAACA,EAAE,CAAC;AACpB;AAEA,IAAA,OAAO,MAAY;MACjB,IAAI,CAACC,OAAO,GAAGC,SAAS;AACxB,MAAA,IAAI,IAAI,CAAC,SAAS,EAAE;AAClB,QAAA,IAAI,CAAC,SAAS,CAACA,SAAS,CAAC;AAC3B;KACD;AACH,GAAC,CAAC;AACJ;AAEA,SAASC,GAAGA,CACVN,QAAsC,EAC9B;AACR,EAAA,OAAO,IAAIP,GAAG,CAACO,QAAQ,CAAC;AAC1B;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { tracked } from '@glimmer/tracking';
|
|
2
|
+
import { d as decorateFieldV2, i as initializeDeferredDecorator } from '../runtime-BPCpkOf1-K_uh_M6B.js';
|
|
3
|
+
|
|
4
|
+
class ToggleState {
|
|
5
|
+
static {
|
|
6
|
+
decorateFieldV2(this.prototype, "current", [tracked], function () {
|
|
7
|
+
return false;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
#current = (initializeDeferredDecorator(this, "current"), undefined);
|
|
11
|
+
#onChange;
|
|
12
|
+
constructor(initialValue, onChange) {
|
|
13
|
+
this.#onChange = onChange;
|
|
14
|
+
if (initialValue !== undefined) {
|
|
15
|
+
this.current = initialValue;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
toggle = input => {
|
|
19
|
+
if (typeof input === 'boolean') {
|
|
20
|
+
this.#set(input);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Handle checkbox input
|
|
25
|
+
if (input instanceof Event && input.currentTarget && input.currentTarget instanceof HTMLInputElement) {
|
|
26
|
+
this.#set(input.currentTarget.checked);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.#set(!this.current);
|
|
30
|
+
};
|
|
31
|
+
#set(val) {
|
|
32
|
+
this.current = val;
|
|
33
|
+
this.#callback();
|
|
34
|
+
}
|
|
35
|
+
#callback() {
|
|
36
|
+
if (this.#onChange) {
|
|
37
|
+
this.#onChange(this.current);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function toggleState(initialValue, onChange) {
|
|
42
|
+
return new ToggleState(initialValue, onChange);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { toggleState };
|
|
46
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.js","sources":["../../src/utils/toggle.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\n\nclass ToggleState {\n @tracked current = false;\n #onChange?: (val: boolean) => void;\n\n constructor(initialValue?: boolean, onChange?: (val: boolean) => void) {\n this.#onChange = onChange;\n if (initialValue !== undefined) {\n this.current = initialValue;\n }\n }\n\n toggle = (input?: boolean | Event): void => {\n if (typeof input === 'boolean') {\n this.#set(input);\n return;\n }\n\n // Handle checkbox input\n if (\n input instanceof Event &&\n input.currentTarget &&\n input.currentTarget instanceof HTMLInputElement\n ) {\n this.#set(input.currentTarget.checked);\n return;\n }\n\n this.#set(!this.current);\n };\n\n #set(val: boolean): void {\n this.current = val;\n this.#callback();\n }\n\n #callback() {\n if (this.#onChange) {\n this.#onChange(this.current);\n }\n }\n}\n\nfunction toggleState(\n initialValue?: boolean,\n onChange?: (val: boolean) => void\n): ToggleState {\n return new ToggleState(initialValue, onChange);\n}\n\nexport { toggleState };\n"],"names":["ToggleState","g","prototype","tracked","i","void 0","constructor","initialValue","onChange","undefined","current","toggle","input","Event","currentTarget","HTMLInputElement","checked","#set","val","#callback","toggleState"],"mappings":";;;AAEA,MAAMA,WAAW,CAAC;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACfC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAW,KAAK;AAAA,KAAA,CAA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
4
|
"description": "Component Library for Ember Octane apps: Utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"./components/visually-hidden.js": "./dist/_app_/components/visually-hidden.js"
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "018bd653db02bd420e446498ba1175a33e5d9697"
|
|
111
111
|
}
|