diff --git a/dist/index.cjs b/dist/index.cjs index a5c0b25..abaac15 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -1,72 +1,52 @@ 'use strict'; -var createScope = function createScope(getData) { - return function (event) { - var ctx = event.context; - - var find = function find(i) { - return i._id === ctx.itemId; - }; - - return { - $item: $w.at(ctx), - - get itemData() { - return getData().find(find); - }, - - get index() { - return getData().findIndex(find); - }, - - get data() { - return getData(); - } - - }; +const createScope = getData => event => { + const ctx = event.context; + const find = i => i._id === ctx.itemId; + return { + $item: $w.at(ctx), + get itemData() { + return getData().find(find); + }, + get index() { + return getData().findIndex(find); + }, + get data() { + return getData(); + } }; }; -var getRepeater = function getRepeater(event) { - var node = event.target; - +const getRepeater = event => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let node = event.target; if (event.context.type !== 'COMPONENT_SCOPE') { - console.error("repeater-scope: \"#" + node.id + "\" outside of any $w.Repeater context"); + console.error(`repeater-scope: "#${node.id}" outside of any $w.Repeater context`); } - while ((node = node.parent).type !== '$w.Repeater') { /**/ } - return node; }; -var useScope = function useScope(event) { - var ctx = event.context; - - var find = function find(i) { - return i._id === ctx.itemId; - }; - +const useScope = event => { + const ctx = event.context; + const find = i => i._id === ctx.itemId; return { $item: $w.at(ctx), - get itemData() { return getRepeater(event).data.find(find); }, - get index() { return getRepeater(event).data.findIndex(find); }, - get data() { return getRepeater(event).data; } - }; }; -var updateItem = function updateItem(event, callback) { +const updateItem = (event, callback) => { getRepeater(event).forItems([event.context.itemId], callback); }; diff --git a/dist/index.js b/dist/index.js index 70285a0..34f7f44 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,70 +1,50 @@ -var createScope = function createScope(getData) { - return function (event) { - var ctx = event.context; - - var find = function find(i) { - return i._id === ctx.itemId; - }; - - return { - $item: $w.at(ctx), - - get itemData() { - return getData().find(find); - }, - - get index() { - return getData().findIndex(find); - }, - - get data() { - return getData(); - } - - }; +const createScope = getData => event => { + const ctx = event.context; + const find = i => i._id === ctx.itemId; + return { + $item: $w.at(ctx), + get itemData() { + return getData().find(find); + }, + get index() { + return getData().findIndex(find); + }, + get data() { + return getData(); + } }; }; -var getRepeater = function getRepeater(event) { - var node = event.target; - +const getRepeater = event => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let node = event.target; if (event.context.type !== 'COMPONENT_SCOPE') { - console.error("repeater-scope: \"#" + node.id + "\" outside of any $w.Repeater context"); + console.error(`repeater-scope: "#${node.id}" outside of any $w.Repeater context`); } - while ((node = node.parent).type !== '$w.Repeater') { /**/ } - return node; }; -var useScope = function useScope(event) { - var ctx = event.context; - - var find = function find(i) { - return i._id === ctx.itemId; - }; - +const useScope = event => { + const ctx = event.context; + const find = i => i._id === ctx.itemId; return { $item: $w.at(ctx), - get itemData() { return getRepeater(event).data.find(find); }, - get index() { return getRepeater(event).data.findIndex(find); }, - get data() { return getRepeater(event).data; } - }; }; -var updateItem = function updateItem(event, callback) { +const updateItem = (event, callback) => { getRepeater(event).forItems([event.context.itemId], callback); }; diff --git a/src/getRepeater.ts b/src/getRepeater.ts index 69b6767..c9020b8 100644 --- a/src/getRepeater.ts +++ b/src/getRepeater.ts @@ -1,4 +1,5 @@ export const getRepeater = (event: $w.Event): $w.Repeater => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any let node: any = event.target; if (event.context.type !== 'COMPONENT_SCOPE') {