How to use the @stylable/core.valueMapping.states function in @stylable/core

To help you get started, we’ve selected a few @stylable/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix / stylable / packages / language-service / src / lib / provider.ts View on Github external
Object.values(defMeta.mappedSymbols).some(sym => {
            const symbolStates = sym._kind === 'class' && sym[valueMapping.states];
            // states
            return (
                sym._kind === 'class' &&
                symbolStates &&
                Object.keys(symbolStates).some(k => {
                    if (k === word && !!pos) {
                        const postcsspos = new ProviderPosition(pos.line + 1, pos.character);
                        const pfp = pathFromPosition(callingMeta.rawAst, postcsspos, [], true);
                        const selec = (pfp[pfp.length - 1] as postcss.Rule).selector;
                        // If called from -st-state, i.e. inside node, pos is not in selector.
                        // Use 1 and not 0 for selector that starts with'.'
                        const char = isInNode(postcsspos, pfp[pfp.length - 1]) ? 1 : pos.character;
                        const parsel = parseSelector(selec, char);
                        const t = parsel.target;
                        const arr = Array.isArray(t.focusChunk)
                            ? (t.focusChunk as SelectorQuery[])[t.index].text
github wix / stylable / packages / language-service / src / lib / completion-providers.ts View on Github external
const newStates = lastNode.resolved.reduce((acc, cur) => {
                let relPath = path.relative(path.dirname(meta.source), cur.meta.source);
                if (!relPath.startsWith('.')) {
                    relPath = './' + relPath;
                }
                const symbol = cur.symbol;
                if (symbol._kind === 'class') {
                    const symbolStates = symbol[valueMapping.states];

                    if (symbolStates) {
                        Object.keys(symbolStates).forEach(k => {
                            if (
                                !acc[k] &&
                                // selectoid is a substring of current state
                                (k.slice(0, -1).startsWith(lastSelectoid.replace(':', '')) ||
                                    // selectoid is a CSS native pseudo-sclass
                                    nativePseudoClasses.indexOf(lastSelectoid.replace(':', '')) !==
                                        -1 ||
                                    allStates.hasOwnProperty(lastSelectoid.replace(':', ''))) &&
                                chunkyStates.every(cs => cs !== k)
                            ) {
                                const symbolStates = symbol[valueMapping.states];
                                const stateDef = symbolStates && symbolStates[k];
github wix / stylable / packages / language-service / src / lib / provider.ts View on Github external
Object.values(meta.mappedSymbols).some(k => {
                if (k._kind === 'class') {
                    const symbolStates = k[valueMapping.states];

                    if (symbolStates && Object.keys(symbolStates).some(key => key === word)) {
                        const postcsspos = new ProviderPosition(
                            position.line + 1,
                            position.character
                        );
                        const pfp = pathFromPosition(callingMeta.rawAst, postcsspos, [], true);
                        const selec = (pfp[pfp.length - 1] as postcss.Rule).selector;

                        // If called from -st-state, i.e. inside node, pos is not in selector.
                        // Use 1 and not 0 for selector that starts with'.'
                        const char = isInNode(postcsspos, pfp[pfp.length - 1])
                            ? 1
                            : position.character;
                        const parsel = parseSelector(selec, char);
                        const t = parsel.target;
github wix / stylable / packages / language-service / src / lib / provider.ts View on Github external
symb.resolved.some(inner => {
                            if (inner.symbol._kind === 'class') {
                                const symbolStates = inner.symbol[valueMapping.states];

                                return (
                                    symbolStates &&
                                    inner.meta.source === defMeta.source &&
                                    Object.keys(symbolStates).indexOf(word) !== -1
                                );
                            }
                            return false;
                        })
                    ) {
github wix / stylable / packages / language-service / src / lib / completion-providers.ts View on Github external
const states = lastNode.resolved.reduce((acc, cur) => {
                if (cur.symbol._kind === 'class') {
                    const symbolStates = cur.symbol[valueMapping.states];
                    if (symbolStates) {
                        acc = acc.concat(Object.keys(symbolStates));
                    }
                }
                return acc;
            }, cssPseudoClasses);
github wix / stylable / packages / language-service / src / lib / completion-providers.ts View on Github external
Object.keys(symbolStates).forEach(k => {
                    const symbolStates = symbol[valueMapping.states];
                    if (symbolStates && symbolStates[k] !== undefined) {
                        acc[k] = symbolStates[k];
                    }
                });
            }