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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@giteeteam/formik

v0.0.4

Published

Build forms in React, without the tears (giteeteam fork of [email protected] with external-store support)

Downloads

450

Readme

@giteeteam/formik

Build forms in React, without the tears —— [email protected] 的企业 fork,为 Proxima 表单 runtime 增加 external-store 直连能力。

  • 上游:jaredpalmer/formik 2.4.6(commit c798145e2307b0273ea4d9c6bfd8250f28d95be9),详见 docs/provenance.md
  • 不传 externalStore 时,行为与上游 2.4.6 完全一致(由未修改的上游全量测试保证)
  • 许可证:Apache-2.0(见 LICENSE)

安装

pnpm add @giteeteam/formik

react 为 peer dependency,要求 >=16.8.0。

用法

与上游一致的部分

<Formik> / useFormik / <Field> / <FastField> / <FieldArray> / <ErrorMessage> / connect / withFormik 等 API 与 formik 2.4.6 完全相同,官方文档 同样适用。

externalStore:把表单状态托管到自己的存储

FormikConfig 新增可选 prop externalStore。传入后状态由你的 store 持有,formik 经 useSyncExternalStore(官方 shim,React 18+ 走原生实现)订阅它:

import { Formik, Field, Form } from '@giteeteam/formik';
import type { FormikExternalStore } from '@giteeteam/formik';

function ItemForm({ store }: { store: FormikExternalStore<Values> }) {
  return (
    <Formik
      initialValues={{ title: '' }}
      externalStore={store}
      onSubmit={values => save(values)}
    >
      <Form>
        <Field name="title" />
      </Form>
    </Formik>
  );
}

store 需实现的契约(FormikExternalStore<Values>):

| 成员 | 要求 | | --- | --- | | getSnapshot() | 返回当前 FormikExternalSnapshot;同一版本必须返回同一引用(useSyncExternalStore 约定)| | subscribe(listener) | 注册变更通知,返回取消订阅函数 | | update(updater, metadata) | 同步执行一次 updater 并接管其结果;updater 不得原地修改入参 state | | reset(nextState, initialState?) | 响应 RESET_FORM | | flush() | 返回一份已稳定的快照(submitForm 在提交前调用)|

快照字段:state(对外可写视图)、initialState、comparisonState / comparisonInitialState(仅用于 diff 的内部不可变真值)、version(状态版本)、validationVersion(数据版本,字段值变化时递增)。

使用约定:

  • 原生 reducer 仍是唯一状态写入口:所有变更都经 store.update(s => formikReducer(s, action), metadata),RESET_FORM 走 store.reset()。
  • store 的身份在同一表单会话内必须稳定,更换 store 即重置会话。
  • dirty 以 comparisonInitialState 为基线计算;命令式读取(values / errors / touched)直接同步读当前存储,initial* 以初始基线为准。
  • 校验带竞态防护,过期结果会被丢弃;submitForm 先取稳定快照再校验,版本漂移时重取快照重校(最多 3 次),仍不稳定则拒绝提交并抛错。
  • 参考实现见 test/externalStore.test.tsx 的 createStore;完整实现细节与不变量见 docs/external-store.md(不随 npm 包发布)。

相对上游 2.4.6 的改动

| 改动 | 落点 | | --- | --- | | 新增导出类型 FormikExternalSnapshot / FormikExternalUpdateMetadata / FormikExternalStore,FormikConfig 新增 externalStore | src/types.tsx | | useFormik 订阅外部存储,dispatch 路由到 store.update() / store.reset() | src/Formik.tsx | | 校验竞态防护(inputVersion / baseline token / pendingValidations)与 submitForm 稳定快照协议 | src/Formik.tsx | | 新增依赖 use-sync-external-store(经 shim 兼容 React 16.8 / 17)| package.json |

回归测试 test/externalStore.test.tsx 为新增文件,未改动任何上游测试文件。

本地开发

在根仓库(giteeteam-packages)执行:

nvm use 18                                    # 本包工具链按 node 18 验证
pnpm install                                  # 依赖由根 pnpm-lock.yaml 统一管理
pnpm --filter @giteeteam/formik run test      # tsdx test --env=jsdom:9 套件 / 268 用例
pnpm --filter @giteeteam/formik run build     # tsdx build -> packages/formik/dist/
pnpm --filter @giteeteam/formik exec tsdx test --env=jsdom --coverage   # 带覆盖率(pnpm 10 的 run 转发 -- 会引入字面量 --,故用 exec 形式)
cd packages/formik && pnpm pack --pack-destination /tmp   # 检查发布产物

不发布到公网仓库时请忽略 publishConfig;本包不自动发布。

文档

| 文档 | 内容 | 随 npm 发布 | | --- | --- | --- | | README.md | 本文件:安装、用法、与上游的差异 | ✅ | | LICENSE | Apache-2.0 全文 | ✅ | | docs/provenance.md | 来源记录(上游 commit / tag / 导入范围)| ❌ | | docs/external-store.md | externalStore 集成实现细节与协议契约 | ❌ | | docs/workspace-notes.md | 工作区成员化调整(依赖、pnpm overrides、lint 适配)| ❌ | | docs/upstream-README.md | 上游 README 原文(归档)| ❌ | | CHANGELOG.md | 上游 changelog 原文(未追加 fork 条目)| ❌ |

标 ❌ 的文件不在 npm 包内,故此表格只以代码形式给出路径、不提供链接;在仓库内阅读时按包内相对路径打开。

许可证

Apache-2.0,上游 LICENSE 完整保留。基于 formik(Copyright Jared Palmer)修改,继续以 Apache-2.0 发布。