@eliseubatista99/react-scaffold-core

中文文档
2.0.2发布于 2026/10/30MITTypeScriptESM + CJS近 30 天下载 2086

A library which provides basic components, hooks, helpers and providers to easily build a React application and avoid repeating the usual code.

原始使用文档
文档目录13 节
  1. Requirements
  2. Installation
  3. Quick start
  4. API overview
  5. Components
  6. Hooks
  7. Providers and navigation
  8. Helpers
  9. Shared types
  10. Accessibility and usage notes
  11. API reference
  12. Development
  13. License

@eliseubatista99/react-scaffold-core

Reusable React components, hooks, providers, and utilities for common application needs. The package is written in TypeScript, ships its type declarations, and keeps React and router dependencies external so your application can share its own React and routing context.

Requirements

Peer dependencySupported versionUsed for
react^19.1.0Components and hooks
react-dom^19.1.0React DOM rendering
react-router-dom^7.6.3Navigation provider and hook
react-slick^0.31.0Carousel
dayjs^1.11.19TimeHelper

Install compatible peer dependencies in your application. lodash is installed as a package dependency. The package bundles the styles it needs from slick-carousel; you do not need to add slick-carousel to your application.

Installation

npm install @eliseubatista99/react-scaffold-core \
  react@^19.1.0 react-dom@^19.1.0 \
  react-router-dom@^7.6.3 react-slick@^0.31.0 dayjs@^1.11.19

Import the package stylesheet once from your application entry point. It provides the Slick styles used by Carousel.

import "@eliseubatista99/react-scaffold-core/dist/react-scaffold-core.css";

Quick start

Wrap the application in FeedbackProvider to use Modal, Drawer, Toast, Loader, or useFeedback. Use NavigationRoutes inside the router your application already owns.

import {
  Button,
  FeedbackProvider,
  Modal,
  NavigationRoutes,
  useFeedback,
} from "@eliseubatista99/react-scaffold-core";
import { BrowserRouter } from "react-router-dom";

function Home() {
  const { showItem, hideItem } = useFeedback();

  return (
    <>
      <Button onClick={() => showItem("welcome")}>Open dialog</Button>
      <Modal
        id="welcome"
        aria-label="Welcome"
        onClickOutsideModal={() => hideItem("welcome")}
      >
        <p>Welcome to the app.</p>
        <Button onClick={() => hideItem("welcome")}>Close</Button>
      </Modal>
    </>
  );
}

export function App() {
  return (
    <FeedbackProvider>
      <BrowserRouter>
        <NavigationRoutes routes={[{ path: "/", render: <Home /> }]} />
      </BrowserRouter>
    </FeedbackProvider>
  );
}

NavigationProvider is also available as a convenience wrapper that creates a BrowserRouter. Prefer NavigationRoutes when router setup belongs to your application, or when using a router such as MemoryRouter.

API overview

All public exports are available from the package root:

import { Button, useFetch, TimeHelper } from "@eliseubatista99/react-scaffold-core";

Components

Button, Carousel, Checkbox, Drawer, Form, Image, InputField, Loader, Modal, NumericInputField, PageLayout, ProgressBar, RadioButton, SvgImage, TextAreaField, Toast, and Typography.

Components export their associated prop types, including CarouselSlideProps, DrawerHandleProps, FormSubmitButton, FormSubmitSection, and PageLayoutHeaderAndFooterProps.

Hooks

  • useDidMount — effect helper for mount-time setup and cleanup.
  • useDrag — pointer-based element dragging.
  • useFetch — typed get, post, put, patch, and delete methods.
  • useOnScreen — observe an element with IntersectionObserver.
  • usePointer — observe primary pointer position and pressed state.
  • useResponsive — read viewport dimensions and a configurable breakpoint.
  • useTranslations — resolve a translation from a supplied language and dictionary.

Call the hook at the top level of a component or custom hook, then use its methods from an event handler or effect:

function UsersButton() {
  const { get } = useFetch();

  const loadUsers = async () => {
    const response = await get<User[]>("/api/users", { active: true });
    // Handle response.result, response.statusCode, and response.error.
  };

  return <Button onClick={loadUsers}>Load users</Button>;
}

useFetch returns HTTP status codes rather than rejecting for HTTP error responses. Network errors reject the promise; check statusCode and error when handling the result.

Providers and navigation

  • FeedbackProvider, useFeedback, and useFeedbackActions manage visibility by string ID. useFeedback and useFeedbackActions must be called beneath FeedbackProvider.
  • NavigationRoutes declares routes inside an existing React Router and observes navigation history after it mounts.
  • NavigationProvider provides the legacy convenience setup with a BrowserRouter.
  • useNavigation provides currentPath, observed history, goTo, goBack, and searchParams. Call it inside a compatible React Router.

Feedback overlays are controlled by their ID: call showItem(id) and hideItem(id) to open and close them. Modal and Drawer require an accessible name via aria-label or aria-labelledby. They invoke their close callbacks but do not hide themselves; the callback should call hideItem(id). Toast hides itself after its configured duration.

Helpers

  • EmailHelper — email masking.
  • FormsHelper — look up and read values from form output.
  • NumberHelper — numeric clamping.
  • ObjectsHelper — deep equality comparison.
  • ScrollHelper — inspect, disable, and restore document scrolling.
  • TextHelper — common string checks and formatting.
  • TimeHelper — date/time helpers and asynchronous waits.

Shared types

The package exports FormFieldConfiguration, FormFieldInputData, and FormFieldOutputData, plus public component, hook, and provider types. TypeScript declaration files are included in the published package.

Accessibility and usage notes

  • Give Modal and Drawer an accessible name with aria-label or aria-labelledby.
  • Use Button for actions; it defaults to type="button". Set type="submit" explicitly when submitting a native form.
  • Form collects named native inputs, textareas, and selects. Validation reports hasErrors to onSubmit; it does not prevent the callback from running, so check that argument before continuing with a submission.
  • RadioButton is a visual button control, not a native radio input, and is not collected by Form.
  • NavigationRoutes can only track navigation observed after it mounts. Its history is not a copy of the browser's complete history stack.

API reference

The focused package references document component props and behavior, hook signatures, helper methods, providers, shared types, and build conventions:

Development

Run these commands from src/packages/core:

npm install
npm run build
npm test
npm run typecheck
npm run lint

npm run build generates ESM and CommonJS bundles, TypeScript declarations, and the package stylesheet in dist/. npm run test:package builds the package and runs a smoke test against its published-style bundles and router integration.

License

MIT

版本与发布记录

@eliseubatista99/react-scaffold-core 共发布 161 个版本,首次发布于 2025/07/22;过去 12 个月发布了 145 个版本。

版本发布日期距今
2.0.2latest2026/10/3014 天前
2.0.12026/10/2915 天前
2.0.02026/10/2915 天前
1.2.142026/10/2915 天前
1.2.132026/10/2915 天前
1.2.122026/10/2916 天前

关于 @eliseubatista99/react-scaffold-core 的常见问题

@eliseubatista99/react-scaffold-core 是什么?

A library which provides basic components, hooks, helpers and providers to easily build a React application and avoid repeating the usual code.

如何安装 @eliseubatista99/react-scaffold-core?

在项目目录运行 npm install @eliseubatista99/react-scaffold-core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:dayjs(^1.11.19)、react(^19.1.0)、react-dom(^19.1.0)、react-slick(^0.31.0)、react-router-dom(^7.6.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@eliseubatista99/react-scaffold-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@eliseubatista99/react-scaffold-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@eliseubatista99/react-scaffold-core 可以商用吗?

@eliseubatista99/react-scaffold-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eliseubatista99/react-scaffold-core 的下载量有多少?

根据 npm 官方下载统计,@eliseubatista99/react-scaffold-core 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,086 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eliseubatista99/react-scaffold-core 还在维护吗?

最新版本 2.0.2 发布于 2026/10/30(14 天前);至今共发布 161 个版本,其中过去 12 个月发布了 145 个;首次发布于 2025/07/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。