npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

xhq-core

v1.0.6

Published

Compressed core module for xhq project

Readme

xhq-core

一个用于将 JSON 配置转换为 React 组件的核心模块。

安装

npm install xhq-core

使用方法

基本用法

import React from 'react';
import { RenderJson, registerComponent } from 'xhq-core';
import { Button, Form, Input } from 'antd-mobile';

// 注册组件
registerComponent({
  Button,
  Form,
  'Form.Item': Form.Item,
  Input,
});

// JSON 配置
const jsonConfig = {
  widget: 'Form',
  jProps: {
    layout: 'horizontal',
  },
  jChildren: [
    {
      widget: 'Input',
      jProps: {
        placeholder: '请输入姓名',
        formItemProps: {
          name: 'name',
          label: '姓名',
          rules: [{ required: true, message: '请输入姓名' }],
        },
      },
    },
    {
      widget: 'Button',
      jProps: {
        color: 'primary',
        jFunction: {
          onClick: "console.log('按钮被点击')",
        },
      },
      jChildren: '提交',
    },
  ],
};

function App() {
  return (
    <div>
      <RenderJson render={jsonConfig} />
    </div>
  );
}

export default App;

高级用法

import { CustomRender, numToRem, addStyle, formatData } from 'xhq-core';

// 自定义渲染函数
const customComponent = CustomRender(jsonConfig, customState);

// 使用工具函数
const remValue = numToRem('r(32)'); // 转换为 rem 单位
addStyle('.custom-class { font-size: 16px; }'); // 动态添加样式
const formattedData = formatData(jsonConfig); // 格式化数据

API

RenderJson

主要的渲染组件,接收 render 属性作为 JSON 配置。

CustomRender

自定义渲染函数,可以在任何地方使用。

registerComponent

注册可用的组件库,必须在使用前调用。

工具函数

numToRem

将设计稿中的 r() 函数值转换为 rem 单位,支持响应式设计。

addStyle

动态添加 CSS 样式到页面中。

formatData

格式化 JSON 配置数据,处理样式单位转换等。

特性

  • 🚀 高性能 JSON 到 React 组件转换
  • 🎨 支持动态样式和响应式设计
  • 🔧 支持自定义函数和事件处理
  • 📱 支持表单验证和组件引用
  • 🎯 支持组件隐藏和条件渲染

依赖

  • React >= 16.8.0
  • React DOM >= 16.8.0
  • lodash
  • use-deep-compare-effect

许可证

MIT

交流与支持

商用授权声明

如将本项目用于商业用途,请先联系作者获取授权;未经授权的商用行为将依法维权。