How to use @lskjs/utils - 10 common examples

To help you get started, we’ve selected a few @lskjs/utils 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 lskjs / ux / packages / button / src / UrlButton / UrlButton.jsx View on Github external
render() {
    const { componentClass, ...props } = this.props;
    const buttonProps = omit(props, ['url', 'api', 'onSuccess']);
    return (
      
    );
  }
}
github lskjs / ux / packages / button / src / UrlButton / UrlButton.jsx View on Github external
render() {
    const { componentClass, ...props } = this.props;
    const buttonProps = omit(props, ['url', 'api', 'onSuccess']);
    return (
      
    );
  }
}
github lskjs / lskjs / packages / auth / src / server / Api / AuthApi.js View on Github external
getUserFields(req) {
    const params = req.allParams();
    // console.log({ params });
    if (params.login) {
      if (!params.username) {
        params.username = params.login;
      }
      if (!params.email && validateEmail(params.login)) {
        params.email = params.login;
      } // if email
    }
    if (params.username) params.username = canonizeUsername(params.username);
    if (params.email) params.email = canonize(params.email);
    // console.log({ params });
    return params;
  }
github lskjs / lskjs / packages / auth / src / server / controller / controller.js View on Github external
controller.getUserFields = function (req) {
    const params = req.allParams();
    // console.log({ params });
    if (params.login) {
      if (!params.username) {
        params.username = params.login;
      }
      if (!params.email && validateEmail(params.login)) {
        params.email = params.login;
      } // if email
    }
    if (params.username) params.username = canonizeUsername(params.username);
    if (params.email) params.email = canonize(params.email);
    // console.log({ params });
    return params;
  };
  controller.getUserCriteria = function (req) {
github lskjs / lskjs / packages / mobx / src / stores / FetchStore.js View on Github external
async find({ skip, limit, __cancelToken } = {}) {
    if (!this.api) throw '!api';
    if (!this.api.find) throw '!api.find';
    let params = getFindParams(this);
    if (this.getFindParams) params = this.getFindParams(this, params);
    const raw = await this.api.find({
      count: 1,
      ...omitEmpty(params),
      limit,
      skip,
      __cancelToken,
    });

    let items;
    let count;
    if (Array.isArray(raw)) {
      // console.warn('pack lost, raw != {data}');
      items = raw;
      count = raw.count >= 0 ? raw.count : null;
    } else {
      items = raw.data || raw.items || [];
      count = raw.count >= 0 ? raw.count : null;
    }
github lskjs / ux / packages / modal / src / Modal2.jsx View on Github external
isOpen={this.state.visible}
            onRequestClose={closable && this.close}
            bodyOpenClassName={bodyModalStyle}
            htmlOpenClassName={bodyModalStyle}
            style={merge(style, Modal2.defaultStyles)}
            {...pick(props, reactModalProps)}
          >
            <span style="{{">{this.state.counter}</span>
            <div aria-hidden="">
              {/*  */}
                
              {/*  */}
              
                
              
            </div>
          
          
            {trigger}
          
        
      
    );
github lskjs / ux / packages / modal / src / Modal2.jsx View on Github external
} : noop}
            isOpen={this.state.visible}
            onRequestClose={closable &amp;&amp; this.close}
            bodyOpenClassName={bodyModalStyle}
            htmlOpenClassName={bodyModalStyle}
            style={merge(style, Modal2.defaultStyles)}
            {...pick(props, reactModalProps)}
          &gt;
            <span style="{{">{this.state.counter}</span>
            <div aria-hidden="">
              {/*  */}
                
              {/*  */}
              
                
              
            </div>
          
          
            {trigger}
github lskjs / ux / packages / modal / src / Modal2.jsx View on Github external
}
            } : noop}
            isOpen={this.state.visible}
            onRequestClose={closable &amp;&amp; this.close}
            bodyOpenClassName={bodyModalStyle}
            htmlOpenClassName={bodyModalStyle}
            style={merge(style, Modal2.defaultStyles)}
            {...pick(props, reactModalProps)}
          &gt;
            <span style="{{">{this.state.counter}</span>
            <div aria-hidden="">
              {/*  */}
                
              {/*  */}
              
                
              
            </div>
          
          
            {trigger}
github lskjs / ux / packages / ui / src / Link / Link.jsx View on Github external
handleClick(e) {
    const { onClick, target, to, href, qs } = this.props;
    const { linkProvider, history } = this.context;
    if (isMiddleClickEvent(e)) {
      return;
    }

    if (onClick) onClick(e);
    if (e.defaultPrevented === true) return;
    if (isModifiedEvent(e) || !isLeftClickEvent(e)) return;
    const url = composeUrl({ url: to || href, qs });
    if (url == null) return;
    if (target === '_blank' || isAbsoluteUrl(url)) return;
    e.preventDefault();

    if (history) {
      history.push(url);
    } else if (linkProvider) {
      linkProvider.onClick(url, e);
    } else {
      console.error('Link without linkProvider (history)'); // eslint-disable-line no-console
      window.location = url;
    }
  }
github lskjs / lskjs / packages / build-locales / src / build-locales.js View on Github external
locales.forEach((locale) => {
    const dirname = path.join(destination, locale);
    try {
      mkdirp.sync(dirname);
    } catch (err) {
      console.error(err);
    }
    fs.writeFileSync(`${dirname}.json`, JSON.stringify(getKeyValJson(localesRows, locale), null, 2)); // eslint-disable-line max-len
    // fs.writeFileSync(`${dirname}/translation.json`, JSON.stringify(getKeyValJson(localesRows, locale), null, 2)); // eslint-disable-line max-len
    const namespaces = groupBy(localesRows, 'ns');
    forEach(namespaces, (rows, ns) => {
      if (!ns) return;
      fs.writeFileSync(`${dirname}/${ns}.json`, JSON.stringify(getKeyValJson(rows, locale), null, 2));
    });
  });
};