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

lifecycle-setting

v0.1.7

Published

React + Tailwind components for configuring lifecycle (retention/deletion) policies with hierarchical dependencies. It ships a composable dialog with inputs, policy preview, and action buttons so apps can enforce cascading rules across related resources (

Downloads

620

Readme

lifecycle-setting

React + Tailwind components for configuring lifecycle (retention/deletion) policies with hierarchical dependencies. It ships a composable dialog with inputs, policy preview, and action buttons so apps can enforce cascading rules across related resources (records, dialogs, media, etc.).

Features

  • Controlled lifecycle dialog with shared context for all sections
  • Dependency-aware inputs that prevent children from exceeding parent retention
  • Policy preview block with customizable copy
  • Tailwind-ready styles and a sharable preset (tailwind-preset.js) for matching tokens
  • TypeScript types for items, values, and component props

Installation

npm install lifecycle-setting

Peer requirements: react (>=18), react-dom (>=18), tailwindcss (>=3.4). The UI uses Headless UI and clsx, which are bundled as dependencies.

Quick start

Define your lifecycle items, keep the state controlled in your app, and compose the provided blocks inside LifecycleDialog.

import { useMemo, useState } from "react";
import {
  LifecycleDialog,
  LifecycleHeader,
  LifecycleInputs,
  LifecycleRules,
  LifecycleButtons,
  type LifecycleItemConfig,
  type LifecycleValues,
} from "lifecycle-setting";

const items: LifecycleItemConfig<"record" | "dialog" | "media">[] = [
  { type: "record", labels: { title: "Record" } },
  { type: "dialog", dependsOn: ["record"], labels: { title: "Dialog" } },
  { type: "media", dependsOn: ["record", "dialog"], labels: { title: "Media" } },
];

export function LifecycleModal({ open, onClose }: { open: boolean; onClose: () => void }) {
  const [values, setValues] = useState<LifecycleValues>({
    record: { value: 365, checked: true },
    dialog: { value: 365, checked: true },
    media: { value: 365, checked: true },
  });

  const dirty = useMemo(
    () => items.some((i) => values[i.type].checked !== true || values[i.type].value !== 365),
    [values]
  );

  return (
    <LifecycleDialog open={open} items={items} values={values} setValues={setValues}>
      <LifecycleHeader
        title="Lifecycle policy"
        desc="Changes apply within 24 hours and limit related features until data is removed."
      />
      <LifecycleRules
        rulesTitle="Current policy"
        enabledTemplate="{value} days after {title} is deleted"
        disabledText="kept forever"
      />
      <LifecycleInputs min={3} max={365} inputTitle="retention" />
      <LifecycleButtons
        handleClose={onClose}
        onSubmit={() => console.log("Submit lifecycle:", values)}
        disabled={!dirty}
        cancelText="Close"
        submitText="Save"
      />
    </LifecycleDialog>
  );
}

Dependency rules:

  • dependsOn controls hierarchy. A child cannot exceed the shortest checked parent period.
  • Unchecking a parent blocks unchecking of a child until all parents are off.
  • Changing a parent can auto-shrink dependent children so the tree stays consistent.

Component & type reference

  • LifecycleDialog: Shared provider for the lifecycle UI. Props: open, items, values, setValues, optional min/max, and children. Wrap all lifecycle sections inside this component.
  • LifecycleHeader: Text block at the top. Props: title, desc (Korean defaults are provided).
  • LifecycleRules: Read-only summary list. Props: rulesTitle, enabledTemplate (supports {value} and {title} tokens), disabledText.
  • LifecycleInputs: Checkbox + slider + number inputs for each item. Props: min, max, inputTitle. Uses the dialog context to read/write values and enforce dependencies.
  • LifecycleButtons: Action row. Props: handleClose, onSubmit, disabled, optional cancelText, submitText. The submit button is also disabled until an input is edited inside the dialog.
  • Types: LifecycleItemConfig (defines type, optional dependsOn, and labels), LifecycleValue (value, checked), LifecycleValues (map keyed by type).

Styling

Components are built with Tailwind utility classes. To get the same palette, pull in the provided preset:

// tailwind.config.js
const preset = require("lifecycle-setting/tailwind-preset");

module.exports = {
  presets: [preset],
  content: ["./src/**/*.{ts,tsx,js,jsx}"],
};

Ensure your app bundles Tailwind’s base/components/utilities so the class names resolve. The library does not inject global CSS.

Local development

npm install
npm run dev      # starts the sample app (Vite)
npm run lint     # eslint
npm run build    # type-check + bundle + d.ts

License

MIT