1 line
5.2 KiB
JSON
1 line
5.2 KiB
JSON
|
{"ast":null,"code":"import * as React from 'react';\nconst EMPTY_KEYS = [];\nfunction filterKeys(keys, dataKeys) {\n const filteredKeys = keys.filter(key => dataKeys.has(key));\n return keys.length === filteredKeys.length ? keys : filteredKeys;\n}\nfunction flattenKeys(keys) {\n return Array.from(keys).join(';');\n}\nexport default function useSelection(leftDataSource, rightDataSource) {\n let selectedKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_KEYS;\n // Prepare `dataSource` keys\n const [leftKeys, rightKeys] = React.useMemo(() => [new Set(leftDataSource.map(src => src.key)), new Set(rightDataSource.map(src => src.key))], [leftDataSource, rightDataSource]);\n // Selected Keys\n const [sourceSelectedKeys, setSourceSelectedKeys] = React.useState(() => filterKeys(selectedKeys, leftKeys));\n const [targetSelectedKeys, setTargetSelectedKeys] = React.useState(() => filterKeys(selectedKeys, rightKeys));\n // Fill selected keys\n React.useEffect(() => {\n setSourceSelectedKeys(filterKeys(selectedKeys, leftKeys));\n setTargetSelectedKeys(filterKeys(selectedKeys, rightKeys));\n }, [selectedKeys]);\n // Reset when data changed\n React.useEffect(() => {\n setSourceSelectedKeys(filterKeys(sourceSelectedKeys, leftKeys));\n setTargetSelectedKeys(filterKeys(targetSelectedKeys, rightKeys));\n }, [flattenKeys(leftKeys), flattenKeys(rightKeys)]);\n return [\n // Keys\n sourceSelectedKeys, targetSelectedKeys,\n // Updater\n setSourceSelectedKeys, setTargetSelectedKeys];\n}","map":{"version":3,"names":["React","EMPTY_KEYS","filterKeys","keys","dataKeys","filteredKeys","filter","key","has","length","flattenKeys","Array","from","join","useSelection","leftDataSource","rightDataSource","selectedKeys","arguments","undefined","leftKeys","rightKeys","useMemo","Set","map","src","sourceSelectedKeys","setSourceSelectedKeys","useState","targetSelectedKeys","setTargetSelectedKeys","useEffect"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/transfer/hooks/useSelection.js"],"sourcesContent":["import * as React from 'react';\nconst EMPTY_KEYS = [];\nfunction filterKeys(keys, dataKeys) {\n const filteredKeys = keys.filter(key => dataKeys.has(key));\n return keys.length === filteredKeys.length ? keys : filteredKeys;\n}\nfunction flattenKeys(keys) {\n return Array.from(keys).join(';');\n}\nexport default function useSelection(leftDataSource, rightDataSource) {\n let selectedKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_KEYS;\n // Prepare `dataSource` keys\n const [leftKeys, rightKeys] = React.useMemo(() => [new Set(leftDataSource.map(src => src.key)), new Set(rightDataSource.map(src => src.key))], [leftDataSource, rightDataSource]);\n // Selected Keys\n const [sourceSelectedKeys, setSourceSelectedKeys] = React.useState(() => filterKeys(selectedKeys, leftKeys));\n const [targetSelectedKeys, setTargetSelectedKeys] = React.useState(() => filterKeys(selectedKeys, rightKeys));\n // Fill selected keys\n React.useEffect(() => {\n setSourceSelectedKeys(filterKeys(selectedKeys, leftKeys));\n setTargetSelectedKeys(filterKeys(selectedKeys, rightKeys));\n }, [selectedKeys]);\n // Reset when data changed\n React.useEffect(() => {\n setSourceSelectedKeys(filterKeys(sourceSelectedKeys, leftKeys));\n setTargetSelectedKeys(filterKeys(targetSelectedKeys, rightKeys));\n }, [flattenKeys(leftKeys), flattenKeys(rightKeys)]);\n return [\n // Keys\n sourceSelectedKeys, targetSelectedKeys,\n // Updater\n setSourceSelectedKeys, setTargetSelectedKeys];\n}"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,MAAMC,UAAU,GAAG,EAAE;AACrB,SAASC,UAAUA,CAACC,IAAI,EAAEC,QAAQ,EAAE;EAClC,MAAMC,YAAY,GAAGF,IAAI,CAACG,MAAM,CAACC,GAAG,IAAIH,QAAQ,CAACI,GAAG,CAACD,GAAG,CAAC,CAAC;EAC1D,OAAOJ,IAAI,CAACM,MAAM,KAAKJ,YAAY,CAACI,MAAM,GAAGN,IAAI,GAAGE,YAAY;AAClE;AACA,SAASK,WAAWA,CAACP,IAAI,EAAE;EACzB,OAAOQ,KAAK,CAACC,IAAI,CAACT,IAAI,CAAC,CAACU,IAAI,CAAC,GAAG,CAAC;AACnC;AACA,eAAe,SAASC,YAAYA,CAACC,cAAc,EAAEC,eAAe,EAAE;EACpE,IAAIC,YAAY,GAAGC
|