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 🙏

© 2024 – Pkg Stats / Ryan Hefner

popups-file-dialog

v1.6.2

Published

popups file dialog build in c on top of lib called tinyfiledialogs and ported for node

Downloads

23

Readme

Popups File Dialog

NPM version NPM downloads MIT License

This is a simple file dialog 0 dependencies for windows, linux and macos.build on library in c language called tinyfiledialogs. sence it is build in c , so this lib is super fast unlike any library build in python i saw on npm

now listen, sense node is not natively have a file dialog so i build this lib as a wrapper for the (tinyfiledialogs library build in c). i made the cli version of the tinyfiledialogs library. after that i build this lib as a wrapper for the cli version of the tinyfiledialogs library. i did think of making the tinyfiledialogs library as a node addon, but this is too much work. so i go for the easy way, and make the cli version of the tinyfiledialogs library. still have a lot of work to do i recently build the lib for windows and linux i am to lazy to download macos and build the lib for macos so if you have a macos and want to help me build the lib for macos feel free to contribute to this lib. compile and test the lib/vendors/src/cli.c for macos

demo

const fileDialog = require("popups-file-dialog");
(async () => {
  const result = await fileDialog.openFile({
      title: 'Open File',
      startPath: './',
      filterPatterns: ['*'],
      filterPatternsDescription: 'all files',
      allowMultipleSelects: true,
})
  console.log(result);
})();

windows:

multiple select windows

linux:

multiple select linux

(async () => {
const result = await fileDialog.openDirectory({
        title: "select folder please",
    })
    console.log(result);
})();

windows:

select folder windows

linux:

select folder linux

Installation

npm install popups-file-dialog
yarn add popups-file-dialog

or

git clone https://github.com/native-toolkit/popups-file-dialog.git
cd popups-file-dialog

Change log

1.6.0

  • added the saveFile method
  • fixed the startPath option for supporting directories with spaces in the name
  • some formatting and refactoring

1.5.1

  • add support for linux (finally)
  • fixed some bugs (a lot of bugs)
  • added the openDirectory method to select a folder
  • some formatting and refactoring

Usage

const fileDialog = require("../file-dialog");

const main = async () => {
  console.log(fileDialog.config.vendorPath); // check for the path of the vendor folder if the os is supported
  const result = await fileDialog.openFile({
    title: "Open File",
    startPath: "C:\\Users\\",
    filterPatterns: ["*.exe", "*.txt"],
    filterPatternsDescription: "exe files,txt files",
    allowMultipleSelects: true,
  });
  console.log(result);

  const result2 = await fileDialog.messageBox({
    title: "Message Box",
    message: "Hello World",
    dialogType: "yesNoCancel",
    iconType: "info",
    defaultSelected: "yes",
  });
  console.log(result2);
};
main();

table of content

API

fileDialog.config

super important, and big object, that contain all the config of the lib all the flags with the commands and the path of the vendor folder part of it:

config = {
  vendorPath: path.join(
    __dirname,
    "lib",
    "vendors",
    "bin",
    `${process.platform}${process.platform === "win32" ? ".exe" : ".app"}`
  ),
  availableCommand: {
    open: {
      name: "-open-file",
      flags: {
        title: {
          name: "--title",
          defaultValue: "open",
        },
        startPath: {
          name: "--startPath",
          defaultValue: path.resolve("./"),
        },
        filterPatterns: {
          name: "--filterPatterns",
          defaultValue: "*",
        },
        filterPatternsDescription: {
          name: "--filterPatternsDescription",
          defaultValue: "",
        },
        allowMultipleSelects: {
          name: "--allowMultipleSelects",
          defaultValue: "0",
        },
      },
    },
  },
};

fileDialog.openFile(options)

open file dialog menu

example :

multiple select example:

const result = await fileDialog.openFile({
        title: "Open File",
        startPath: "./",
        filterPatterns: ["*"],
        filterPatternsDescription: "all files",
        allowMultipleSelects: true
    })
    console.log(result);

image on windows 10:

multiple select

expected result:

[
  'C:\\Users\\pc\\Desktop\\workingdir\\projects\\popups-file-dialog\\.gitignore',
  'C:\\Users\\pc\\Desktop\\workingdir\\projects\\popups-file-dialog\\.npmignore',
  'C:\\Users\\pc\\Desktop\\workingdir\\projects\\popups-file-dialog\\file-dialog.js'
]

options

| option | type | default | description |example| | --- | --- | --- | --- |--- | | title |string| "open" | title of the dialog | "Open File" | | startPath | string | path.resolve("./") | start path of the dialog | "C:\Users\" | | filterPatterns | string[] | ["*"] | filter patterns of the dialog | ["*.exe", "*.txt"] | | filterPatternsDescription | string | "" | filter patterns description of the dialog | "exe files,txt files" | | allowMultipleSelects | boolean | false | allow multiple selects of the dialog | true |

fileDialog.saveFile(options)

save file dialog menu

example :

const result5 = await fileDialog.saveFile({
      title: 'Save File',
      startPath: 'C:\\Users\\pc\\Desktop\\New folder (36)\\test.txt',
      filterPatterns: ['*'],
      filterPatternsDescription: "all",
   })
   console.log(result5)

image on windows 10:

save file

expected result:

"C:\\Users\\pc\\Desktop\\New folder (36)\\test.txt"

options

| option | type | default | description |example| | --- | --- | --- | --- |--- | | title |string| "save" | title of the dialog | "Save File" | | startPath | string | path.resolve("./default.txt") | start path and file name | "C:\Users\someFile.txt" | | filterPatterns | string[] | ["*"] | filter patterns of the dialog | ["*.exe", "*.txt"] | | filterPatternsDescription | string | "" | filter patterns description of the dialog | "exe files,txt files" |

fileDialog.openDirectory(options)

open folder dialog menu

example :

const result = await fileDialog.openDirectory({
        title: "Message Box",
    })
    console.log(result);

image on windows 10:

select folder

expected result:

"C:\\Users\\pc\\Documents\\Adobe"

options

| option | type | default | description |example| | --- | --- | --- | --- |--- | | title |string| "open" | title of the dialog | "Open Folder" |

fileDialog.messageBox(options)

promote message box

example 1:

const result = await fileDialog.messageBox({
        title: "Message Box",
        message: "Hello World",
        dialogType: "yesNoCancel",
        iconType: "info",
        defaultSelected: "yes"
    })
    console.log(result);

image on windows 10:

message box

expected result:

yes -> 1
no -> 2
cancel -> 0

example 2:

const result = await fileDialog.messageBox({
        title: "Message Box",
        message: "Hello World",
        dialogType: "okCancel",
        iconType: "info",
        defaultSelected: "ok"
    })
    console.log(result);

expected result:

ok -> 1
cancel -> 0

example 3:

const result = await fileDialog.messageBox({
        title: "Message Box",
        message: "Hello World",
        dialogType: "yesNo",
        iconType: "info",
        defaultSelected: "ok"
    })
    console.log(result);

expected result:

yes -> 1
no -> 0

options

| option | type | default | description |example| available options | | --- | --- | --- | --- |--- | --- | | title |string| "message" | title of the dialog | "Message Box" | | | message | string | "message" | message of the dialog | "Hello World" | | | dialogType | string | "ok" | dialog type of the dialog | "okCancel" | "ok", "okCancel", "yesNo", "yesNoCancel" | | iconType | string | "info" | icon type of the dialog | "info" | "info", "warning", "error","question" | | defaultSelected | string | "ok" | default selected of the dialog | "ok" | "ok", "cancel", "yes", "no" |